Commit 739f3304 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

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

parent 2d235de3
......@@ -777,18 +777,18 @@ static void MMSYSTDRV_MidiOut_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dw
* ================================= */
/**************************************************************************
* MMDRV_WaveIn_Map16To32W [internal]
* MMSYSTDRV_WaveIn_Map16To32W [internal]
*/
static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
static MMSYSTEM_MapType MMSYSTDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
{
WINMM_MapType ret = WINMM_MAP_MSGERROR;
MMSYSTEM_MapType ret = MMSYSTEM_MAP_MSGERROR;
switch (wMsg) {
case WIDM_GETNUMDEVS:
case WIDM_RESET:
case WIDM_START:
case WIDM_STOP:
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
break;
case WIDM_OPEN:
case WIDM_CLOSE:
......@@ -805,9 +805,9 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)wic32;
*lpParam2 = sizeof(WAVEINCAPSW);
ret = WINMM_MAP_OKMEM;
ret = MMSYSTEM_MAP_OKMEM;
} else {
ret = WINMM_MAP_NOMEM;
ret = MMSYSTEM_MAP_NOMEM;
}
}
break;
......@@ -824,9 +824,9 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)mmt32;
*lpParam2 = sizeof(MMTIME);
ret = WINMM_MAP_OKMEM;
ret = MMSYSTEM_MAP_OKMEM;
} else {
ret = WINMM_MAP_NOMEM;
ret = MMSYSTEM_MAP_NOMEM;
}
}
break;
......@@ -850,9 +850,9 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)wh32;
*lpParam2 = sizeof(WAVEHDR);
ret = WINMM_MAP_OKMEM;
ret = MMSYSTEM_MAP_OKMEM;
} else {
ret = WINMM_MAP_NOMEM;
ret = MMSYSTEM_MAP_NOMEM;
}
}
break;
......@@ -870,13 +870,13 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
wh32->dwBufferLength, wh16->dwBufferLength);
} else
wh32->dwBufferLength = wh16->dwBufferLength;
ret = WINMM_MAP_OKMEM;
ret = MMSYSTEM_MAP_OKMEM;
}
break;
case WIDM_MAPPER_STATUS:
/* just a single DWORD */
*lpParam2 = (DWORD)MapSL(*lpParam2);
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
break;
default:
FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2);
......@@ -886,11 +886,11 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
}
/**************************************************************************
* MMDRV_WaveIn_UnMap16To32W [internal]
* MMSYSTDRV_WaveIn_UnMap16To32W [internal]
*/
static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
static MMSYSTEM_MapType MMSYSTDRV_WaveIn_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) {
case WIDM_GETNUMDEVS:
......@@ -898,7 +898,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
case WIDM_START:
case WIDM_STOP:
case WIDM_MAPPER_STATUS:
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
break;
case WIDM_OPEN:
case WIDM_CLOSE:
......@@ -917,7 +917,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
wic16->dwFormats = wic32->dwFormats;
wic16->wChannels = wic32->wChannels;
HeapFree(GetProcessHeap(), 0, (LPSTR)wic32 - sizeof(LPWAVEINCAPS16));
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
}
break;
case WIDM_GETPOS:
......@@ -927,7 +927,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
MMSYSTEM_MMTIME32to16(mmt16, mmt32);
HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16));
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
}
break;
case WIDM_ADDBUFFER:
......@@ -948,7 +948,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR));
wh16->lpNext = 0;
}
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
}
break;
default:
......@@ -1261,6 +1261,33 @@ static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwI
MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
}
/**************************************************************************
* MMSYSTDRV_WaveIn_MapCB [internal]
*/
static void MMSYSTDRV_WaveIn_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dwParam1, DWORD_PTR* dwParam2)
{
switch (uMsg) {
case WIM_OPEN:
case WIM_CLOSE:
/* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
break;
case WIM_DATA:
{
/* initial map is: 16 => 32 */
LPWAVEHDR wh32 = (LPWAVEHDR)(*dwParam1);
SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR));
LPWAVEHDR wh16 = MapSL(segwh16);
*dwParam1 = (DWORD)segwh16;
wh16->dwFlags = wh32->dwFlags;
wh16->dwBytesRecorded = wh32->dwBytesRecorded;
}
break;
default:
ERR("Unknown msg %u\n", uMsg);
}
}
/* =================================
* W A V E O U T M A P P E R S
* ================================= */
......@@ -2615,6 +2642,8 @@ static WINMM_MapType MMDRV_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_P
#define MMDRV_MidiIn_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_MidiOut_Map16To32W MMDRV_Map16To32W
#define MMDRV_MidiOut_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_WaveIn_Map16To32W MMDRV_Map16To32W
#define MMDRV_WaveIn_UnMap16To32W MMDRV_UnMap16To32W
void MMDRV_Init16(void)
{
......@@ -2673,6 +2702,7 @@ static struct MMSYSTDRV_Type
{MMSYSTDRV_Mixer_Map16To32W, MMSYSTDRV_Mixer_UnMap16To32W, MMSYSTDRV_Mixer_MapCB},
{MMSYSTDRV_MidiIn_Map16To32W, MMSYSTDRV_MidiIn_UnMap16To32W, MMSYSTDRV_MidiIn_MapCB},
{MMSYSTDRV_MidiOut_Map16To32W, MMSYSTDRV_MidiOut_UnMap16To32W, MMSYSTDRV_MidiOut_MapCB},
{MMSYSTDRV_WaveIn_Map16To32W, MMSYSTDRV_WaveIn_UnMap16To32W, MMSYSTDRV_WaveIn_MapCB},
};
/******************************************************************
......
......@@ -1398,18 +1398,32 @@ UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
LPCWAVEFORMATEX lpFormat, DWORD dwCallback,
DWORD dwInstance, DWORD dwFlags)
{
HANDLE hWaveIn;
UINT ret;
HWAVEIN hWaveIn;
UINT ret;
struct mmsystdrv_thunk* thunk;
if (!(thunk = MMSYSTDRV_AddThunk(dwCallback, MMSYSTDRV_WAVEIN)))
{
return MMSYSERR_NOMEM;
}
if ((dwFlags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION)
{
dwCallback = (DWORD)thunk;
}
/* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
* call the 32 bit version
* however, we need to promote correctly the wave mapper id
* (0xFFFFFFFF and not 0x0000FFFF)
*/
ret = WAVE_Open(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEIN, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
ret = waveInOpen(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
lpFormat, dwCallback, dwInstance, dwFlags);
if (lphWaveIn != NULL) *lphWaveIn = HWAVEIN_16(hWaveIn);
if (ret == MMSYSERR_NOERROR)
{
if (lphWaveIn != NULL) *lphWaveIn = HWAVEIN_16(hWaveIn);
MMSYSTDRV_SetHandle(thunk, (void*)hWaveIn);
}
else MMSYSTDRV_DeleteThunk(thunk);
return ret;
}
......@@ -1424,6 +1438,8 @@ UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
ReleaseThunkLock(&level);
ret = waveInClose(HWAVEIN_32(hWaveIn));
RestoreThunkLock(level);
if (ret == MMSYSERR_NOERROR)
MMSYSTDRV_CloseHandle((void*)HWAVEIN_32(hWaveIn));
return ret;
}
......@@ -1434,19 +1450,15 @@ UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
SEGPTR lpsegWaveInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
UINT16 ret;
TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
lpWaveInHdr->dwBytesRecorded = 0;
ret = MMDRV_Message(wmld, WIDM_PREPARE, lpsegWaveInHdr, uSize, FALSE);
ret = MMSYSTDRV_Message(HWAVEIN_32(hWaveIn), WIDM_PREPARE, lpsegWaveInHdr, uSize);
return ret;
}
......@@ -1457,7 +1469,6 @@ UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
SEGPTR lpsegWaveInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
TRACE("(%04X, %08x, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
......@@ -1468,10 +1479,7 @@ UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WIDM_UNPREPARE, lpsegWaveInHdr, uSize, FALSE);
return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn), WIDM_UNPREPARE, lpsegWaveInHdr, uSize);
}
/**************************************************************************
......@@ -1481,15 +1489,11 @@ UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn, /* [in] */
WAVEHDR* lpsegWaveInHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
if (lpsegWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD_PTR)lpsegWaveInHdr, uSize, FALSE);
return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn), WIDM_ADDBUFFER, (DWORD_PTR)lpsegWaveInHdr, uSize);
}
/**************************************************************************
......@@ -1569,24 +1573,18 @@ UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16* lpuDeviceID)
DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04x, %u, %d, %d)\n", hWaveIn, uMessage, dwParam1, dwParam2);
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL) {
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, TRUE)) != NULL) {
if (uMessage == DRV_QUERYDRVENTRY || uMessage == DRV_QUERYDEVNODE)
dwParam1 = (DWORD)MapSL(dwParam1);
return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
}
return MMSYSERR_INVALHANDLE;
if ((DWORD_PTR)hWaveIn < waveInGetNumDevs())
{
if (uMessage == DRV_QUERYDRVENTRY || uMessage == DRV_QUERYDEVNODE)
dwParam1 = (DWORD)MapSL(dwParam1);
}
else if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
/* from M$ KB */
return MMSYSERR_INVALPARAM;
/* from M$ KB */
if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
return MMSYSERR_INVALPARAM;
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
return MMSYSTDRV_Message(HWAVEIN_32(hWaveIn), uMessage, dwParam1, dwParam2);
}
/* ###################################################
......
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