winecoreaudio.drv : create only one MIDIOutPort and one MIDIInPort
for all destinations and sources
Emmanuel Maillard
mahanuu at free.fr
Mon Apr 30 09:25:25 CDT 2007
Changelog :
- create only one MIDIOutPort and one MIDIInPort for all
destinations and sources
-------------- next part --------------
From 4212bfb75d4ff241c8f350a2c6949b4341d9dacd Mon Sep 17 00:00:00 2001
From: Emmanuel Maillard <mahanuu at free.fr>
Date: Mon, 30 Apr 2007 14:37:33 +0200
Subject: [PATCH] - create only one MIDIOutPort and one MIDIInPort for all destinations and sources
---
dlls/winecoreaudio.drv/coremidi.c | 2 +-
dlls/winecoreaudio.drv/midi.c | 38 +++++++++++++++++++++---------------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c
index 6c47c87..282d958 100644
--- a/dlls/winecoreaudio.drv/coremidi.c
+++ b/dlls/winecoreaudio.drv/coremidi.c
@@ -63,7 +63,7 @@ void MIDIIn_ReadProc(const MIDIPacketLis
MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
for (i = 0; i < pktlist->numPackets; ++i) {
- msg.devID = *((UInt16 *)refCon);
+ msg.devID = *((UInt16 *)connRefCon);
msg.length = packet->length;
memcpy(msg.data, packet->data, sizeof(packet->data));
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index ba6c40e..30c9a14 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -59,14 +59,16 @@ typedef struct tagMIDIDestination {
AUGraph graph;
AudioUnit synth;
- MIDIPortRef port;
+ MIDIEndpointRef dest;
+
MIDIOUTCAPSW caps;
MIDIOPENDESC midiDesc;
WORD wFlags;
} MIDIDestination;
typedef struct tagMIDISource {
- MIDIPortRef port;
+ MIDIEndpointRef source;
+
WORD wDevID;
int state; /* 0 is no recording started, 1 in recording, bit 2 set if in sys exclusive recording */
MIDIINCAPSW caps;
@@ -81,6 +83,9 @@ static CFStringRef MIDIInThreadPortName
static DWORD WINAPI MIDIIn_MessageThread(LPVOID p);
+static MIDIPortRef MIDIInPort = NULL;
+static MIDIPortRef MIDIOutPort = NULL;
+
#define MAX_MIDI_SYNTHS 1
MIDIDestination *destinations;
@@ -123,23 +128,28 @@ LONG CoreAudio_MIDIInit(void)
InitializeCriticalSection(&midiInLock);
MIDIInThreadPortName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("MIDIInThreadPortName.%u"), getpid());
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 */
for (i = 0; i < MIDIIn_NumDevs; i++)
{
- MIDIEndpointRef endpoint = MIDIGetSource(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));
- name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("WineInputPort.%d.%u"), i, getpid());
- MIDIInputPortCreate(wineMIDIClient, name, MIDIIn_ReadProc, &sources[i].wDevID, &sources[i].port);
- CFRelease(name);
-
- MIDIPortConnectSource(sources[i].port, endpoint, NULL);
+ MIDIPortConnectSource(MIDIInPort, sources[i].source, &sources[i].wDevID);
sources[i].state = 0;
/* FIXME */
@@ -168,15 +178,11 @@ LONG CoreAudio_MIDIInit(void)
/* initialise available destinations */
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));
- 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.wChannelMask = 0xFFFF;
--
1.4.4
More information about the wine-patches
mailing list