Commit 84efa19e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

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

parent 8aa64672
......@@ -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},
};
/******************************************************************
......
......@@ -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);
}
/**************************************************************************
......
......@@ -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);
......
......@@ -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;
......@@ -1265,15 +1268,6 @@ UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback,
}
/**************************************************************************
* 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.@]
*/
UINT WINAPI midiInClose(HMIDIIN hMidiIn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment