winmm: Move the 16bit management of midi out driver type to the new 16=>32 thunking scheme.

This commit is contained in:
Eric Pouech 2009-10-22 22:10:05 +02:00 committed by Alexandre Julliard
parent 84efa19e90
commit 80b079e011
4 changed files with 79 additions and 58 deletions

View File

@ -314,18 +314,18 @@ static void MMSYSTDRV_MidiIn_MapCB(UINT uMsg, DWORD_PTR* dwUser, DW
* ================================= */ * ================================= */
/************************************************************************** /**************************************************************************
* MMDRV_MidiOut_Map16To32W [internal] * MMSYSTDRV_MidiOut_Map16To32W [internal]
*/ */
static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) static MMSYSTEM_MapType MMSYSTDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
{ {
WINMM_MapType ret = WINMM_MAP_MSGERROR; MMSYSTEM_MapType ret = MMSYSTEM_MAP_MSGERROR;
switch (wMsg) { switch (wMsg) {
case MODM_GETNUMDEVS: case MODM_GETNUMDEVS:
case MODM_DATA: case MODM_DATA:
case MODM_RESET: case MODM_RESET:
case MODM_SETVOLUME: case MODM_SETVOLUME:
ret = WINMM_MAP_OK; ret = MMSYSTEM_MAP_OK;
break; break;
case MODM_OPEN: case MODM_OPEN:
@ -345,9 +345,9 @@ static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)moc32; *lpParam1 = (DWORD)moc32;
*lpParam2 = sizeof(MIDIOUTCAPSW); *lpParam2 = sizeof(MIDIOUTCAPSW);
ret = WINMM_MAP_OKMEM; ret = MMSYSTEM_MAP_OKMEM;
} else { } else {
ret = WINMM_MAP_NOMEM; ret = MMSYSTEM_MAP_NOMEM;
} }
} }
break; break;
@ -373,9 +373,9 @@ static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)mh32; *lpParam1 = (DWORD)mh32;
*lpParam2 = sizeof(MIDIHDR); *lpParam2 = sizeof(MIDIHDR);
ret = WINMM_MAP_OKMEM; ret = MMSYSTEM_MAP_OKMEM;
} else { } else {
ret = WINMM_MAP_NOMEM; ret = MMSYSTEM_MAP_NOMEM;
} }
} }
break; break;
@ -393,7 +393,7 @@ static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
mh32->dwBufferLength, mh16->dwBufferLength); mh32->dwBufferLength, mh16->dwBufferLength);
} else } else
mh32->dwBufferLength = mh16->dwBufferLength; mh32->dwBufferLength = mh16->dwBufferLength;
ret = WINMM_MAP_OKMEM; ret = MMSYSTEM_MAP_OKMEM;
} }
break; break;
@ -407,18 +407,18 @@ static WINMM_MapType MMDRV_MidiOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
} }
/************************************************************************** /**************************************************************************
* MMDRV_MidiOut_UnMap16To32W [internal] * MMSYSTDRV_MidiOut_UnMap16To32W [internal]
*/ */
static WINMM_MapType MMDRV_MidiOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) static MMSYSTEM_MapType MMSYSTDRV_MidiOut_UnMap16To32W(UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
{ {
WINMM_MapType ret = WINMM_MAP_MSGERROR; MMSYSTEM_MapType ret = MMSYSTEM_MAP_MSGERROR;
switch (wMsg) { switch (wMsg) {
case MODM_GETNUMDEVS: case MODM_GETNUMDEVS:
case MODM_DATA: case MODM_DATA:
case MODM_RESET: case MODM_RESET:
case MODM_SETVOLUME: case MODM_SETVOLUME:
ret = WINMM_MAP_OK; ret = MMSYSTEM_MAP_OK;
break; break;
case MODM_OPEN: case MODM_OPEN:
@ -443,7 +443,7 @@ static WINMM_MapType MMDRV_MidiOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
moc16->wChannelMask = moc32->wChannelMask; moc16->wChannelMask = moc32->wChannelMask;
moc16->dwSupport = moc32->dwSupport; moc16->dwSupport = moc32->dwSupport;
HeapFree(GetProcessHeap(), 0, (LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16)); HeapFree(GetProcessHeap(), 0, (LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16));
ret = WINMM_MAP_OK; ret = MMSYSTEM_MAP_OK;
} }
break; break;
case MODM_PREPARE: case MODM_PREPARE:
@ -465,7 +465,7 @@ static WINMM_MapType MMDRV_MidiOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
HeapFree(GetProcessHeap(), 0, (LPSTR)mh32 - sizeof(LPMIDIHDR)); HeapFree(GetProcessHeap(), 0, (LPSTR)mh32 - sizeof(LPMIDIHDR));
mh16->lpNext = 0; mh16->lpNext = 0;
} }
ret = WINMM_MAP_OK; ret = MMSYSTEM_MAP_OK;
} }
break; break;
@ -739,6 +739,34 @@ static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dw
MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
} }
/******************************************************************
* MMSYSTDRV_MidiOut_MapCB
*/
static void MMSYSTDRV_MidiOut_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dwParam1, DWORD_PTR* dwParam2)
{
switch (uMsg) {
case MOM_OPEN:
case MOM_CLOSE:
/* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
break;
case MOM_DONE:
{
/* initial map is: 16 => 32 */
LPMIDIHDR mh32 = (LPMIDIHDR)(*dwParam1);
SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR));
LPMIDIHDR mh16 = MapSL(segmh16);
*dwParam1 = (DWORD)segmh16;
mh16->dwFlags = mh32->dwFlags;
if (mh16->reserved >= sizeof(MIDIHDR))
mh16->dwOffset = mh32->dwOffset;
}
break;
default:
ERR("Unknown msg %u\n", uMsg);
}
}
/* ================================= /* =================================
* W A V E I N M A P P E R S * W A V E I N M A P P E R S
* ================================= */ * ================================= */
@ -2580,6 +2608,8 @@ static WINMM_MapType MMDRV_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_P
#define MMDRV_Mixer_UnMap16To32W MMDRV_UnMap16To32W #define MMDRV_Mixer_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_MidiIn_Map16To32W MMDRV_Map16To32W #define MMDRV_MidiIn_Map16To32W MMDRV_Map16To32W
#define MMDRV_MidiIn_UnMap16To32W MMDRV_UnMap16To32W #define MMDRV_MidiIn_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_MidiOut_Map16To32W MMDRV_Map16To32W
#define MMDRV_MidiOut_UnMap16To32W MMDRV_UnMap16To32W
void MMDRV_Init16(void) void MMDRV_Init16(void)
{ {
@ -2637,6 +2667,7 @@ static struct MMSYSTDRV_Type
{ {
{MMSYSTDRV_Mixer_Map16To32W, MMSYSTDRV_Mixer_UnMap16To32W, MMSYSTDRV_Mixer_MapCB}, {MMSYSTDRV_Mixer_Map16To32W, MMSYSTDRV_Mixer_UnMap16To32W, MMSYSTDRV_Mixer_MapCB},
{MMSYSTDRV_MidiIn_Map16To32W, MMSYSTDRV_MidiIn_UnMap16To32W, MMSYSTDRV_MidiIn_MapCB}, {MMSYSTDRV_MidiIn_Map16To32W, MMSYSTDRV_MidiIn_UnMap16To32W, MMSYSTDRV_MidiIn_MapCB},
{MMSYSTDRV_MidiOut_Map16To32W, MMSYSTDRV_MidiOut_UnMap16To32W, MMSYSTDRV_MidiOut_MapCB},
}; };
/****************************************************************** /******************************************************************

View File

@ -595,12 +595,25 @@ UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID, UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
{ {
HMIDIOUT hmo; HMIDIOUT hmo;
UINT ret; UINT ret;
struct mmsystdrv_thunk* thunk;
ret = MIDI_OutOpen(&hmo, uDeviceID, dwCallback, dwInstance, dwFlags, FALSE); if (!(thunk = MMSYSTDRV_AddThunk(dwCallback, MMSYSTDRV_MIDIOUT)))
{
if (lphMidiOut != NULL) *lphMidiOut = HMIDIOUT_16(hmo); return MMSYSERR_NOMEM;
}
if ((dwFlags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION)
{
dwCallback = (DWORD)thunk;
}
ret = midiOutOpen(&hmo, uDeviceID, dwCallback, dwInstance, dwFlags);
if (ret == MMSYSERR_NOERROR)
{
if (lphMidiOut != NULL) *lphMidiOut = HMIDIOUT_16(hmo);
MMSYSTDRV_SetHandle(thunk, (void*)hmo);
}
else MMSYSTDRV_DeleteThunk(thunk);
return ret; return ret;
} }
@ -609,7 +622,11 @@ UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
*/ */
UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut) UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
{ {
return midiOutClose(HMIDIOUT_32(hMidiOut)); UINT ret = midiOutClose(HMIDIOUT_32(hMidiOut));
if (ret == MMSYSERR_NOERROR)
MMSYSTDRV_CloseHandle((void*)HMIDIOUT_32(hMidiOut));
return ret;
} }
/************************************************************************** /**************************************************************************
@ -619,14 +636,9 @@ UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
SEGPTR lpsegMidiOutHdr, /* [???] */ SEGPTR lpsegMidiOutHdr, /* [???] */
UINT16 uSize) /* [in] */ UINT16 uSize) /* [in] */
{ {
LPWINE_MLD wmld;
TRACE("(%04X, %08x, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize); TRACE("(%04X, %08x, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut), MODM_PREPARE, lpsegMidiOutHdr, uSize);
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_PREPARE, lpsegMidiOutHdr, uSize, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -636,7 +648,6 @@ UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
SEGPTR lpsegMidiOutHdr, /* [???] */ SEGPTR lpsegMidiOutHdr, /* [???] */
UINT16 uSize) /* [in] */ UINT16 uSize) /* [in] */
{ {
LPWINE_MLD wmld;
LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr); LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr);
TRACE("(%04X, %08x, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize); TRACE("(%04X, %08x, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
@ -645,10 +656,7 @@ UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
} }
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut), MODM_UNPREPARE, lpsegMidiOutHdr, uSize);
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_UNPREPARE, lpsegMidiOutHdr, uSize, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -666,14 +674,9 @@ UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut, /* [in] */
LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */ LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */ UINT16 uSize) /* [in] */
{ {
LPWINE_MLD wmld;
TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize); TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut), MODM_LONGDATA, (DWORD_PTR)lpsegMidiOutHdr, uSize);
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD_PTR)lpsegMidiOutHdr, uSize, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -739,13 +742,8 @@ UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16* lpuDeviceID)
DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage, DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2) DWORD dwParam1, DWORD dwParam2)
{ {
LPWINE_MLD wmld;
TRACE("(%04X, %04X, %08X, %08X)\n", hMidiOut, uMessage, dwParam1, dwParam2); TRACE("(%04X, %04X, %08X, %08X)\n", hMidiOut, uMessage, dwParam1, dwParam2);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
switch (uMessage) { switch (uMessage) {
case MODM_OPEN: case MODM_OPEN:
case MODM_CLOSE: case MODM_CLOSE:
@ -762,7 +760,7 @@ DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
case MODM_UNPREPARE: case MODM_UNPREPARE:
return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2); return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2);
} }
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE); return MMSYSTDRV_Message(HMIDIOUT_32(hMidiOut), uMessage, dwParam1, dwParam2);
} }
/************************************************************************** /**************************************************************************

View File

@ -203,8 +203,6 @@ LPSTR MCI_strdupWtoA(LPCWSTR str);
BOOL WINMM_CheckForMMSystem(void); BOOL WINMM_CheckForMMSystem(void);
const char* WINMM_ErrorToString(MMRESULT error); const char* WINMM_ErrorToString(MMRESULT error);
UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
DWORD cMidi, DWORD_PTR dwCallback, DWORD cMidi, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32); DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32);

View File

@ -931,8 +931,11 @@ static LPWINE_MIDI MIDI_OutAlloc(HMIDIOUT* lphMidiOut, DWORD_PTR* lpdwCallback,
return lpwm; return lpwm;
} }
UINT MIDI_OutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback, /**************************************************************************
DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32) * midiOutOpen [WINMM.@]
*/
UINT WINAPI midiOutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID,
DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
{ {
HMIDIOUT hMidiOut; HMIDIOUT hMidiOut;
LPWINE_MIDI lpwm; LPWINE_MIDI lpwm;
@ -944,7 +947,7 @@ UINT MIDI_OutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback,
if (lphMidiOut != NULL) *lphMidiOut = 0; if (lphMidiOut != NULL) *lphMidiOut = 0;
lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &dwFlags, lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &dwFlags,
0, NULL, bFrom32); 0, NULL, TRUE);
if (lpwm == NULL) if (lpwm == NULL)
return MMSYSERR_NOMEM; return MMSYSERR_NOMEM;
@ -964,15 +967,6 @@ UINT MIDI_OutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback,
return dwRet; return dwRet;
} }
/**************************************************************************
* midiOutOpen [WINMM.@]
*/
UINT WINAPI midiOutOpen(LPHMIDIOUT lphMidiOut, UINT uDeviceID,
DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
{
return MIDI_OutOpen(lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags, TRUE);
}
/************************************************************************** /**************************************************************************
* midiOutClose [WINMM.@] * midiOutClose [WINMM.@]
*/ */