Commit dea9878c authored by Emmanuel Maillard's avatar Emmanuel Maillard Committed by Alexandre Julliard

winecoreaudio.drv: Create only one MIDIOutPort and one MIDIInPort for all destinations and sources.

parent 41b8a570
...@@ -63,7 +63,7 @@ void MIDIIn_ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefC ...@@ -63,7 +63,7 @@ void MIDIIn_ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefC
MIDIPacket *packet = (MIDIPacket *)pktlist->packet; MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
for (i = 0; i < pktlist->numPackets; ++i) { for (i = 0; i < pktlist->numPackets; ++i) {
msg.devID = *((UInt16 *)refCon); msg.devID = *((UInt16 *)connRefCon);
msg.length = packet->length; msg.length = packet->length;
memcpy(msg.data, packet->data, sizeof(packet->data)); memcpy(msg.data, packet->data, sizeof(packet->data));
......
...@@ -59,14 +59,16 @@ typedef struct tagMIDIDestination { ...@@ -59,14 +59,16 @@ typedef struct tagMIDIDestination {
AUGraph graph; AUGraph graph;
AudioUnit synth; AudioUnit synth;
MIDIPortRef port; MIDIEndpointRef dest;
MIDIOUTCAPSW caps; MIDIOUTCAPSW caps;
MIDIOPENDESC midiDesc; MIDIOPENDESC midiDesc;
WORD wFlags; WORD wFlags;
} MIDIDestination; } MIDIDestination;
typedef struct tagMIDISource { typedef struct tagMIDISource {
MIDIPortRef port; MIDIEndpointRef source;
WORD wDevID; WORD wDevID;
int state; /* 0 is no recording started, 1 in recording, bit 2 set if in sys exclusive recording */ int state; /* 0 is no recording started, 1 in recording, bit 2 set if in sys exclusive recording */
MIDIINCAPSW caps; MIDIINCAPSW caps;
...@@ -81,6 +83,9 @@ static CFStringRef MIDIInThreadPortName = NULL; ...@@ -81,6 +83,9 @@ static CFStringRef MIDIInThreadPortName = NULL;
static DWORD WINAPI MIDIIn_MessageThread(LPVOID p); static DWORD WINAPI MIDIIn_MessageThread(LPVOID p);
static MIDIPortRef MIDIInPort = NULL;
static MIDIPortRef MIDIOutPort = NULL;
#define MAX_MIDI_SYNTHS 1 #define MAX_MIDI_SYNTHS 1
MIDIDestination *destinations; MIDIDestination *destinations;
...@@ -123,23 +128,28 @@ LONG CoreAudio_MIDIInit(void) ...@@ -123,23 +128,28 @@ LONG CoreAudio_MIDIInit(void)
InitializeCriticalSection(&midiInLock); InitializeCriticalSection(&midiInLock);
MIDIInThreadPortName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("MIDIInThreadPortName.%u"), getpid()); MIDIInThreadPortName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("MIDIInThreadPortName.%u"), getpid());
CreateThread(NULL, 0, MIDIIn_MessageThread, NULL, 0, NULL); CreateThread(NULL, 0, MIDIIn_MessageThread, NULL, 0, NULL);
name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("WineInputPort.%u"), getpid());
MIDIInputPortCreate(wineMIDIClient, name, MIDIIn_ReadProc, NULL, &MIDIInPort);
CFRelease(name);
}
if (numDest > 0)
{
name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("WineOutputPort.%u"), getpid());
MIDIOutputPortCreate(wineMIDIClient, name, &MIDIOutPort);
CFRelease(name);
} }
/* initialize sources */ /* initialize sources */
for (i = 0; i < MIDIIn_NumDevs; i++) for (i = 0; i < MIDIIn_NumDevs; i++)
{ {
MIDIEndpointRef endpoint = MIDIGetSource(i);
sources[i].wDevID = i; sources[i].wDevID = i;
sources[i].source = MIDIGetSource(i);
CoreMIDI_GetObjectName(endpoint, szPname, sizeof(szPname)); CoreMIDI_GetObjectName(sources[i].source, szPname, sizeof(szPname));
MultiByteToWideChar(CP_ACP, 0, szPname, -1, sources[i].caps.szPname, sizeof(sources[i].caps.szPname)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, szPname, -1, sources[i].caps.szPname, sizeof(sources[i].caps.szPname)/sizeof(WCHAR));
name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("WineInputPort.%d.%u"), i, getpid()); MIDIPortConnectSource(MIDIInPort, sources[i].source, &sources[i].wDevID);
MIDIInputPortCreate(wineMIDIClient, name, MIDIIn_ReadProc, &sources[i].wDevID, &sources[i].port);
CFRelease(name);
MIDIPortConnectSource(sources[i].port, endpoint, NULL);
sources[i].state = 0; sources[i].state = 0;
/* FIXME */ /* FIXME */
...@@ -168,15 +178,11 @@ LONG CoreAudio_MIDIInit(void) ...@@ -168,15 +178,11 @@ LONG CoreAudio_MIDIInit(void)
/* initialise available destinations */ /* initialise available destinations */
for (i = MAX_MIDI_SYNTHS; i < numDest + MAX_MIDI_SYNTHS; i++) for (i = MAX_MIDI_SYNTHS; i < numDest + MAX_MIDI_SYNTHS; i++)
{ {
MIDIEndpointRef endpoint = MIDIGetDestination(i - MAX_MIDI_SYNTHS); destinations[i].dest = MIDIGetDestination(i - MAX_MIDI_SYNTHS);
CoreMIDI_GetObjectName(endpoint, szPname, sizeof(szPname)); CoreMIDI_GetObjectName(destinations[i].dest, szPname, sizeof(szPname));
MultiByteToWideChar(CP_ACP, 0, szPname, -1, destinations[i].caps.szPname, sizeof(destinations[i].caps.szPname)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, szPname, -1, destinations[i].caps.szPname, sizeof(destinations[i].caps.szPname)/sizeof(WCHAR));
name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("WineOutputPort.%d.%u"), i, getpid());
MIDIOutputPortCreate(wineMIDIClient, name, &destinations[i].port);
CFRelease(name);
destinations[i].caps.wTechnology = MOD_MIDIPORT; destinations[i].caps.wTechnology = MOD_MIDIPORT;
destinations[i].caps.wChannelMask = 0xFFFF; destinations[i].caps.wChannelMask = 0xFFFF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment