From 84efa19e90871327f237a92dc47a42efb6ae1eb0 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Thu, 22 Oct 2009 22:09:58 +0200 Subject: [PATCH] winmm: Move the 16bit management of midi in driver type to the new 16=>32 thunking scheme. --- dlls/winmm/message16.c | 49 ++++++++++++++++++++++++++++++++----- dlls/winmm/mmsystem.c | 55 ++++++++++++++++++++---------------------- dlls/winmm/winemm.h | 2 -- dlls/winmm/winmm.c | 18 +++++--------- 4 files changed, 75 insertions(+), 49 deletions(-) diff --git a/dlls/winmm/message16.c b/dlls/winmm/message16.c index 4bba7086fd5..b6041e269b7 100644 --- a/dlls/winmm/message16.c +++ b/dlls/winmm/message16.c @@ -192,19 +192,19 @@ static void MMSYSTDRV_Mixer_MapCB(DWORD uMsg, DWORD_PTR* dwUser * ================================= */ /************************************************************************** - * MMDRV_MidiIn_Map16To32W [internal] + * MMSYSTDRV_MidiIn_Map16To32W [internal] */ -static WINMM_MapType MMDRV_MidiIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) +static MMSYSTEM_MapType MMSYSTDRV_MidiIn_Map16To32W (UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) { - return WINMM_MAP_MSGERROR; + return MMSYSTEM_MAP_MSGERROR; } /************************************************************************** - * MMDRV_MidiIn_UnMap16To32W [internal] + * MMSYSTDRV_MidiIn_UnMap16To32W [internal] */ -static WINMM_MapType MMDRV_MidiIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) +static MMSYSTEM_MapType MMSYSTDRV_MidiIn_UnMap16To32W(UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) { - return WINMM_MAP_MSGERROR; + return MMSYSTEM_MAP_MSGERROR; } /************************************************************************** @@ -275,6 +275,40 @@ static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwI MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); } +/************************************************************************** + * MMSYSTDRV_MidiIn_MapCB [internal] + */ +static void MMSYSTDRV_MidiIn_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dwParam1, DWORD_PTR* dwParam2) +{ + switch (uMsg) { + case MIM_OPEN: + case MIM_CLOSE: + /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ + + case MIM_DATA: + case MIM_MOREDATA: + case MIM_ERROR: + /* dwParam1 & dwParam2 are data, nothing to do */ + break; + case MIM_LONGDATA: + case MIM_LONGERROR: + { + LPMIDIHDR mh32 = (LPMIDIHDR)(*dwParam1); + SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)); + LPMIDIHDR mh16 = MapSL(segmh16); + + *dwParam1 = (DWORD)segmh16; + mh16->dwFlags = mh32->dwFlags; + mh16->dwBytesRecorded = mh32->dwBytesRecorded; + if (mh16->reserved >= sizeof(MIDIHDR)) + mh16->dwOffset = mh32->dwOffset; + } + break; + default: + ERR("Unknown msg %u\n", uMsg); + } +} + /* ================================= * M I D I O U T M A P P E R S * ================================= */ @@ -2544,6 +2578,8 @@ static WINMM_MapType MMDRV_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_P } #define MMDRV_Mixer_Map16To32W MMDRV_Map16To32W #define MMDRV_Mixer_UnMap16To32W MMDRV_UnMap16To32W +#define MMDRV_MidiIn_Map16To32W MMDRV_Map16To32W +#define MMDRV_MidiIn_UnMap16To32W MMDRV_UnMap16To32W void MMDRV_Init16(void) { @@ -2600,6 +2636,7 @@ static struct MMSYSTDRV_Type } MMSYSTEM_DriversType[MMSYSTDRV_MAX] = { {MMSYSTDRV_Mixer_Map16To32W, MMSYSTDRV_Mixer_UnMap16To32W, MMSYSTDRV_Mixer_MapCB}, + {MMSYSTDRV_MidiIn_Map16To32W, MMSYSTDRV_MidiIn_UnMap16To32W, MMSYSTDRV_MidiIn_MapCB}, }; /****************************************************************** diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index 5c580657d75..564fbf41613 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -803,12 +803,25 @@ UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps, UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { - HMIDIIN xhmid; + HMIDIIN hmid; UINT ret; + struct mmsystdrv_thunk* thunk; - ret = MIDI_InOpen(&xhmid, uDeviceID, dwCallback, dwInstance, dwFlags, FALSE); - - if (lphMidiIn) *lphMidiIn = HMIDIIN_16(xhmid); + if (!(thunk = MMSYSTDRV_AddThunk(dwCallback, MMSYSTDRV_MIDIIN))) + { + return MMSYSERR_NOMEM; + } + if ((dwFlags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) + { + dwCallback = (DWORD)thunk; + } + ret = midiInOpen(&hmid, uDeviceID, dwCallback, dwInstance, dwFlags); + if (ret == MMSYSERR_NOERROR) + { + if (lphMidiIn) *lphMidiIn = HMIDIIN_16(hmid); + MMSYSTDRV_SetHandle(thunk, (void*)hmid); + } + else MMSYSTDRV_DeleteThunk(thunk); return ret; } @@ -817,7 +830,11 @@ UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID, */ UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn) { - return midiInClose(HMIDIIN_32(hMidiIn)); + UINT ret = midiInClose(HMIDIIN_32(hMidiIn)); + + if (ret == MMSYSERR_NOERROR) + MMSYSTDRV_CloseHandle((void*)HMIDIIN_32(hMidiIn)); + return ret; } /************************************************************************** @@ -827,14 +844,9 @@ UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn, /* [in] */ SEGPTR lpsegMidiInHdr, /* [???] */ UINT16 uSize) /* [in] */ { - LPWINE_MLD wmld; - TRACE("(%04X, %08x, %d)\n", hMidiIn, lpsegMidiInHdr, uSize); - if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMDRV_Message(wmld, MIDM_PREPARE, lpsegMidiInHdr, uSize, FALSE); + return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn), MIDM_PREPARE, lpsegMidiInHdr, uSize); } /************************************************************************** @@ -844,7 +856,6 @@ UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */ SEGPTR lpsegMidiInHdr, /* [???] */ UINT16 uSize) /* [in] */ { - LPWINE_MLD wmld; LPMIDIHDR16 lpMidiInHdr = MapSL(lpsegMidiInHdr); TRACE("(%04X, %08x, %d)\n", hMidiIn, lpsegMidiInHdr, uSize); @@ -853,10 +864,7 @@ UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */ return MMSYSERR_NOERROR; } - if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMDRV_Message(wmld, MIDM_UNPREPARE, lpsegMidiInHdr, uSize, FALSE); + return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn), MIDM_UNPREPARE, lpsegMidiInHdr, uSize); } /************************************************************************** @@ -866,14 +874,9 @@ UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn, /* [in] */ MIDIHDR16* lpsegMidiInHdr, /* [???] NOTE: SEGPTR */ UINT16 uSize) /* [in] */ { - LPWINE_MLD wmld; - TRACE("(%04X, %p, %d)\n", hMidiIn, lpsegMidiInHdr, uSize); - if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD_PTR)lpsegMidiInHdr, uSize, FALSE); + return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn), MIDM_ADDBUFFER, (DWORD_PTR)lpsegMidiInHdr, uSize); } /************************************************************************** @@ -920,8 +923,6 @@ UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID) DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage, DWORD dwParam1, DWORD dwParam2) { - LPWINE_MLD wmld; - TRACE("(%04X, %04X, %08X, %08X)\n", hMidiIn, uMessage, dwParam1, dwParam2); switch (uMessage) { @@ -939,11 +940,7 @@ DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage, case MIDM_ADDBUFFER: return midiInAddBuffer16(hMidiIn, MapSL(dwParam1), dwParam2); } - - if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE); + return MMSYSTDRV_Message(HMIDIIN_32(hMidiIn), uMessage, dwParam1, dwParam2); } /************************************************************************** diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 985c03bbde7..83eb2e499cd 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -205,8 +205,6 @@ const char* WINMM_ErrorToString(MMRESULT error); UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32); -UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback, - DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32); MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32); diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index f481941b55e..77f11d244b0 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -1229,8 +1229,11 @@ UINT WINAPI midiInGetDevCapsA(UINT_PTR uDeviceID, LPMIDIINCAPSA lpCaps, UINT uSi return ret; } -UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback, - DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32) +/************************************************************************** + * midiInOpen [WINMM.@] + */ +UINT WINAPI midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, + DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags) { HANDLE hMidiIn; LPWINE_MIDI lpwm; @@ -1242,7 +1245,7 @@ UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback, if (lphMidiIn != NULL) *lphMidiIn = 0; lpwm = (LPWINE_MIDI)MMDRV_Alloc(sizeof(WINE_MIDI), MMDRV_MIDIIN, &hMidiIn, - &dwFlags, &dwCallback, &dwInstance, bFrom32); + &dwFlags, &dwCallback, &dwInstance, TRUE); if (lpwm == NULL) return MMSYSERR_NOMEM; @@ -1264,15 +1267,6 @@ UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback, return dwRet; } -/************************************************************************** - * midiInOpen [WINMM.@] - */ -UINT WINAPI midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, - DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags) -{ - return MIDI_InOpen(lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags, TRUE); -} - /************************************************************************** * midiInClose [WINMM.@] */