Emmanuel Maillard : winecoreaudio: MIDIIn_MessageHandler: Fix non-SysEx messages parsing.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jul 13 08:30:37 CDT 2007


Module: wine
Branch: master
Commit: 6ccb6639535da6acd948eeba776b7f2b9753dca5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6ccb6639535da6acd948eeba776b7f2b9753dca5

Author: Emmanuel Maillard <mahanuu at free.fr>
Date:   Fri Jul 13 12:02:53 2007 +0200

winecoreaudio: MIDIIn_MessageHandler: Fix non-SysEx messages parsing.

---

 dlls/winecoreaudio.drv/midi.c |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index d5d82b7..9198460 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -851,6 +851,8 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD
     int i = 0;
     MIDISource *src = NULL;
     DWORD sendData = 0;
+    int pos = 0;
+    DWORD currentTime;
 
     switch (msgid)
     {
@@ -886,17 +888,32 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD
                 goto done;
             }
             EnterCriticalSection(&midiInLock);
-            if (msg->length == 3)
-            {
-                sendData = (msg->data[2] << 16) |
-                            (msg->data[1] <<  8) |
-                            (msg->data[0] <<  0);
-            }
-            if (msg->length == 2)
+            currentTime = GetTickCount() - src->startTime;
+
+            while (pos < msg->length)
             {
-                sendData = (msg->data[1] <<  8) | (msg->data[0] <<  0);
+                sendData = 0;
+                switch (msg->data[pos] & 0xF0)
+                {
+                    case 0xF0:
+                        sendData = (msg->data[pos] <<  0);
+                        pos++;
+                        break;
+
+                    case 0xC0:
+                    case 0xD0:
+                        sendData = (msg->data[pos + 1] <<  8) | (msg->data[pos] <<  0);
+                        pos += 2;
+                        break;
+                    default:
+                        sendData = (msg->data[pos + 2] << 16) |
+                                    (msg->data[pos + 1] <<  8) |
+                                    (msg->data[pos] <<  0);
+                        pos += 3;
+                        break;
+                }
+                MIDI_NotifyClient(msg->devID, MIM_DATA, sendData, currentTime);
             }
-            MIDI_NotifyClient(msg->devID, MIM_DATA, sendData, GetTickCount() - src->startTime);
             LeaveCriticalSection(&midiInLock);
             break;
         default:




More information about the wine-cvs mailing list