Initial MIDI support on Mac OS X (2/8)
Emmanuel Maillard
mahanuu at free.fr
Tue Apr 24 18:26:04 CDT 2007
Changelog :
- implement MIDI_NotifyClient, MIDIOut_Open and MIDIOut_Close
-------------- next part --------------
From b852e21f74707c58d2da77396ed5c13d7495dd5d Mon Sep 17 00:00:00 2001
From: Emmanuel Maillard <mahanuu at free.fr>
Date: Wed, 25 Apr 2007 00:57:18 +0200
Subject: [PATCH] - implement MIDI_NotifyClient, MIDIOut_Open and MIDIOut_Close
---
dlls/winecoreaudio.drv/midi.c | 124 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 122 insertions(+), 2 deletions(-)
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index a72081a..4ec9e10 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -147,6 +147,125 @@ LONG CoreAudio_MIDIRelease(void)
return 1;
}
+
+/**************************************************************************
+ * MIDI_NotifyClient [internal]
+ */
+static DWORD MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD dwParam1, DWORD dwParam2)
+{
+ DWORD dwCallBack;
+ UINT uFlags;
+ HANDLE hDev;
+ DWORD dwInstance;
+
+ TRACE("wDevID=%d wMsg=%d dwParm1=%04X dwParam2=%04X\n", wDevID, wMsg, dwParam1, dwParam2);
+
+ switch (wMsg) {
+ case MOM_OPEN:
+ case MOM_CLOSE:
+ case MOM_DONE:
+ case MOM_POSITIONCB:
+ dwCallBack = destinations[wDevID].midiDesc.dwCallback;
+ uFlags = destinations[wDevID].wFlags;
+ hDev = destinations[wDevID].midiDesc.hMidi;
+ dwInstance = destinations[wDevID].midiDesc.dwInstance;
+ break;
+
+ case MIM_OPEN:
+ case MIM_CLOSE:
+ case MIM_DATA:
+ case MIM_LONGDATA:
+ case MIM_ERROR:
+ case MIM_LONGERROR:
+ case MIM_MOREDATA:
+ default:
+ WARN("Unsupported MSW-MIDI message %u\n", wMsg);
+ return MMSYSERR_ERROR;
+ }
+
+ return DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2) ?
+ MMSYSERR_NOERROR : MMSYSERR_ERROR;
+}
+
+static DWORD MIDIOut_Open(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
+{
+ MIDIDestination *dest;
+
+ TRACE("wDevID=%d lpDesc=%p dwFlags=%08x\n", wDevID, lpDesc, dwFlags);
+
+ if (lpDesc == NULL) {
+ WARN("Invalid Parameter\n");
+ return MMSYSERR_INVALPARAM;
+ }
+
+ if (wDevID >= MIDIOut_NumDevs) {
+ WARN("bad device ID : %d\n", wDevID);
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (destinations[wDevID].midiDesc.hMidi != 0) {
+ WARN("device already open !\n");
+ return MMSYSERR_ALLOCATED;
+ }
+
+ if ((dwFlags & ~CALLBACK_TYPEMASK) != 0) {
+ WARN("bad dwFlags\n");
+ return MMSYSERR_INVALFLAG;
+ }
+ dest = &destinations[wDevID];
+
+ if (dest->caps.wTechnology == MOD_SYNTH)
+ {
+ if (!SynthUnit_CreateDefaultSynthUnit(&dest->graph, &dest->synth))
+ {
+ ERR("SynthUnit_CreateDefaultSynthUnit dest=%p failed\n", dest);
+ return MMSYSERR_ERROR;
+ }
+
+ if (!SynthUnit_Initialize(dest->synth, dest->graph))
+ {
+ ERR("SynthUnit_Initialise dest=%p failed\n", dest);
+ return MMSYSERR_ERROR;
+ }
+ }
+ else
+ {
+ FIXME("MOD_MIDIPORT\n");
+ }
+ dest->wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
+ dest->midiDesc = *lpDesc;
+
+ return MIDI_NotifyClient(wDevID, MOM_OPEN, 0L, 0L);
+}
+
+static DWORD MIDIOut_Close(WORD wDevID)
+{
+ DWORD ret = MMSYSERR_NOERROR;
+
+ TRACE("wDevID=%d\n", wDevID);
+
+ if (wDevID >= MIDIOut_NumDevs) {
+ WARN("bad device ID : %d\n", wDevID);
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
+ SynthUnit_Close(destinations[wDevID].graph);
+ else
+ FIXME("MOD_MIDIPORT\n");
+
+ destinations[wDevID].graph = 0;
+ destinations[wDevID].synth = 0;
+
+ if (MIDI_NotifyClient(wDevID, MOM_CLOSE, 0L, 0L) != MMSYSERR_NOERROR) {
+ WARN("can't notify client !\n");
+ ret = MMSYSERR_INVALPARAM;
+ }
+ destinations[wDevID].midiDesc.hMidi = 0;
+
+ return ret;
+}
+
/**************************************************************************
* modMessage
*/
@@ -161,7 +280,9 @@ DWORD WINAPI CoreAudio_modMessage(UINT w
case DRVM_DISABLE:
return 0;
case MODM_OPEN:
+ return MIDIOut_Open(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2);
case MODM_CLOSE:
+ return MIDIOut_Close(wDevID);
case MODM_DATA:
case MODM_LONGDATA:
case MODM_PREPARE:
@@ -185,5 +306,4 @@ DWORD WINAPI CoreAudio_modMessage(UINT w
TRACE("%08x, %08x, %08x, %08x, %08x\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
return MMSYSERR_NOTENABLED;
}
-
-#endif
\ No newline at end of file
+#endif
--
1.4.4
More information about the wine-patches
mailing list