Initial MIDI support on Mac OS X (5/8)

Emmanuel Maillard mahanuu at free.fr
Tue Apr 24 18:28:37 CDT 2007


Changelog :
- implement MIDIOut_Data

-------------- next part --------------
From b526dc637577affd1b3c1857975f4c60e1d54b96 Mon Sep 17 00:00:00 2001
From: Emmanuel Maillard <mahanuu at free.fr>
Date: Wed, 25 Apr 2007 01:06:32 +0200
Subject: [PATCH] - implement MIDIOut_Data

---
 dlls/winecoreaudio.drv/coremidi.h |    3 +++
 dlls/winecoreaudio.drv/midi.c     |   36 ++++++++++++++++++++++++++++++++----
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/dlls/winecoreaudio.drv/coremidi.h b/dlls/winecoreaudio.drv/coremidi.h
index 137243b..83649d6 100644
--- a/dlls/winecoreaudio.drv/coremidi.h
+++ b/dlls/winecoreaudio.drv/coremidi.h
@@ -52,6 +52,9 @@ extern OSStatus MIDIObjectGetProperties(
 typedef void *AudioUnit;
 typedef void *AUGraph;
 
+extern OSStatus MusicDeviceMIDIEvent(AudioUnit au, UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame);
+extern OSStatus MusicDeviceSysEx(AudioUnit au, const UInt8 *inData, UInt32 inLength);
+
 #endif
 
 /* coremidi.c */
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index 4bc6107..a504ec3 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -77,8 +77,7 @@ LONG CoreAudio_MIDIInit(void)
 {
     int i;
     CHAR szPname[MAXPNAMELEN] = {0};
-    OSStatus err = noErr;
-    
+        
     int numDest = MIDIGetNumberOfDestinations();
     CFStringRef name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("wineMIDIClient.%d"), getpid());
     
@@ -266,6 +265,36 @@ static DWORD MIDIOut_Close(WORD wDevID)
     return ret;
 }
 
+static DWORD MIDIOut_Data(WORD wDevID, DWORD dwParam)
+{
+    WORD evt = LOBYTE(LOWORD(dwParam));
+    WORD d1  = HIBYTE(LOWORD(dwParam));
+    WORD d2  = LOBYTE(HIWORD(dwParam));
+    UInt8 chn = (evt & 0x0F);
+    OSStatus err = noErr;
+    
+    TRACE("wDevID=%d dwParam=%08X\n", wDevID, dwParam);
+    
+    if (wDevID >= MIDIOut_NumDevs) {
+        WARN("bad device ID : %d\n", wDevID);
+	return MMSYSERR_BADDEVICEID;
+    }
+
+    TRACE("evt=%08x d1=%04x d2=%04x (evt & 0xF0)=%04x chn=%d\n", evt, d1, d2, (evt & 0xF0), chn);
+
+    if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
+    {
+        err = MusicDeviceMIDIEvent(destinations[wDevID].synth, (evt & 0xF0) | chn, d1, d2, 0);
+        if (err != noErr)
+        {
+            ERR("MusicDeviceMIDIEvent(%p, %04x, %04x, %04x, %d) return %c%c%c%c\n", destinations[wDevID].synth, (evt & 0xF0) | chn, d1, d2, 0, (char) (err >> 24), (char) (err >> 16), (char) (err >> 8), (char) err);
+            return MMSYSERR_ERROR;
+        }
+    }
+    else FIXME("MOD_MIDIPORT\n");
+
+    return MMSYSERR_NOERROR;
+}
 
 /**************************************************************************
  * 			MIDIOut_Prepare				[internal]
@@ -359,6 +388,7 @@ DWORD WINAPI CoreAudio_modMessage(UINT w
         case MODM_CLOSE:
             return MIDIOut_Close(wDevID);
         case MODM_DATA:
+            return MIDIOut_Data(wDevID, dwParam1);
         case MODM_LONGDATA:
             TRACE("Unsupported message (08%x)\n", wMsg);
             return MMSYSERR_NOTSUPPORTED;
@@ -379,8 +409,6 @@ DWORD WINAPI CoreAudio_modMessage(UINT w
     return MMSYSERR_NOTSUPPORTED;
 }
 
-
-
 #else
 DWORD WINAPI CoreAudio_modMessage(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
 {
-- 
1.4.4



More information about the wine-patches mailing list