Commit 32c17034 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

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

parent 739f3304
......@@ -1293,11 +1293,11 @@ static void MMSYSTDRV_WaveIn_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR*
* ================================= */
/**************************************************************************
* MMDRV_WaveOut_Map16To32W [internal]
* MMSYSTDRV_WaveOut_Map16To32W [internal]
*/
static WINMM_MapType MMDRV_WaveOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
static MMSYSTEM_MapType MMSYSTDRV_WaveOut_Map16To32W (UINT wMsg, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2)
{
WINMM_MapType ret = WINMM_MAP_MSGERROR;
MMSYSTEM_MapType ret = MMSYSTEM_MAP_MSGERROR;
switch (wMsg) {
/* nothing to do */
......@@ -1310,7 +1310,7 @@ static WINMM_MapType MMDRV_WaveOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
case WODM_SETPITCH:
case WODM_SETPLAYBACKRATE:
case WODM_SETVOLUME:
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
break;
case WODM_GETPITCH:
......@@ -1331,9 +1331,9 @@ static WINMM_MapType MMDRV_WaveOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
*lpParam1 = (DWORD)woc32;
*lpParam2 = sizeof(WAVEOUTCAPSW);
ret = WINMM_MAP_OKMEM;
ret = MMSYSTEM_MAP_OKMEM;
} else {
ret = WINMM_MAP_NOMEM;
ret = MMSYSTEM_MAP_NOMEM;
}
}
break;
......@@ -1350,9 +1350,9 @@ static WINMM_MapType MMDRV_WaveOut_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;
......@@ -1376,9 +1376,9 @@ static WINMM_MapType MMDRV_WaveOut_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;
......@@ -1396,12 +1396,12 @@ static WINMM_MapType MMDRV_WaveOut_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 WODM_MAPPER_STATUS:
*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);
......@@ -1411,11 +1411,11 @@ static WINMM_MapType MMDRV_WaveOut_Map16To32W (UINT wMsg, DWORD_PTR *lpdwUser,
}
/**************************************************************************
* MMDRV_WaveOut_UnMap16To32W [internal]
* MMSYSTDRV_WaveOut_UnMap16To32W [internal]
*/
static WINMM_MapType MMDRV_WaveOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret)
static MMSYSTEM_MapType MMSYSTDRV_WaveOut_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) {
/* nothing to do */
......@@ -1429,7 +1429,7 @@ static WINMM_MapType MMDRV_WaveOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
case WODM_SETPLAYBACKRATE:
case WODM_SETVOLUME:
case WODM_MAPPER_STATUS:
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
break;
case WODM_GETPITCH:
......@@ -1453,7 +1453,7 @@ static WINMM_MapType MMDRV_WaveOut_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser,
woc16->wChannels = woc32->wChannels;
woc16->dwSupport = woc32->dwSupport;
HeapFree(GetProcessHeap(), 0, (LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16));
ret = WINMM_MAP_OK;
ret = MMSYSTEM_MAP_OK;
}
break;
case WODM_GETPOS:
......@@ -1463,7 +1463,7 @@ static WINMM_MapType MMDRV_WaveOut_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 WODM_PREPARE:
......@@ -1484,7 +1484,7 @@ static WINMM_MapType MMDRV_WaveOut_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:
......@@ -1832,6 +1832,32 @@ static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dw
MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2);
}
/**************************************************************************
* MMDRV_WaveOut_Callback [internal]
*/
static void MMSYSTDRV_WaveOut_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dwParam1, DWORD_PTR* dwParam2)
{
switch (uMsg) {
case WOM_OPEN:
case WOM_CLOSE:
/* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
break;
case WOM_DONE:
{
/* 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;
}
break;
default:
ERR("Unknown msg %u\n", uMsg);
}
}
/* =================================
* M A P P E R S H A N D L I N G
* ================================= */
......@@ -2644,6 +2670,8 @@ static WINMM_MapType MMDRV_UnMap16To32W(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_P
#define MMDRV_MidiOut_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_WaveIn_Map16To32W MMDRV_Map16To32W
#define MMDRV_WaveIn_UnMap16To32W MMDRV_UnMap16To32W
#define MMDRV_WaveOut_Map16To32W MMDRV_Map16To32W
#define MMDRV_WaveOut_UnMap16To32W MMDRV_UnMap16To32W
void MMDRV_Init16(void)
{
......@@ -2703,6 +2731,7 @@ static struct MMSYSTDRV_Type
{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},
{MMSYSTDRV_WaveOut_Map16To32W, MMSYSTDRV_WaveOut_UnMap16To32W, MMSYSTDRV_WaveOut_MapCB},
};
/******************************************************************
......
......@@ -1100,18 +1100,32 @@ UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
LPCWAVEFORMATEX lpFormat, DWORD dwCallback,
DWORD dwInstance, DWORD dwFlags)
{
HANDLE hWaveOut;
UINT ret;
HWAVEOUT hWaveOut;
UINT ret;
struct mmsystdrv_thunk* thunk;
if (!(thunk = MMSYSTDRV_AddThunk(dwCallback, MMSYSTDRV_WAVEOUT)))
{
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(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEOUT, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
ret = waveOutOpen(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
lpFormat, dwCallback, dwInstance, dwFlags);
if (lphWaveOut != NULL) *lphWaveOut = HWAVEOUT_16(hWaveOut);
if (ret == MMSYSERR_NOERROR)
{
if (lphWaveOut != NULL) *lphWaveOut = HWAVEOUT_16(hWaveOut);
MMSYSTDRV_SetHandle(thunk, (void*)hWaveOut);
}
else MMSYSTDRV_DeleteThunk(thunk);
return ret;
}
......@@ -1126,6 +1140,8 @@ UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
ReleaseThunkLock(&level);
ret = waveOutClose(HWAVEOUT_32(hWaveOut));
RestoreThunkLock(level);
if (ret == MMSYSERR_NOERROR)
MMSYSTDRV_CloseHandle((void*)HWAVEOUT_32(hWaveOut));
return ret;
}
......@@ -1136,7 +1152,6 @@ UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
SEGPTR lpsegWaveOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
UINT16 result;
......@@ -1144,11 +1159,8 @@ UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
if ((result = MMDRV_Message(wmld, WODM_PREPARE, lpsegWaveOutHdr,
uSize, FALSE)) != MMSYSERR_NOTSUPPORTED)
if ((result = MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut), WODM_PREPARE, lpsegWaveOutHdr,
uSize)) != MMSYSERR_NOTSUPPORTED)
return result;
if (lpWaveOutHdr->dwFlags & WHDR_INQUEUE)
......@@ -1167,7 +1179,6 @@ UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
SEGPTR lpsegWaveOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
TRACE("(%04X, %08x, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
......@@ -1176,10 +1187,7 @@ UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WODM_UNPREPARE, lpsegWaveOutHdr, uSize, FALSE);
return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut), WODM_UNPREPARE, lpsegWaveOutHdr, uSize);
}
/**************************************************************************
......@@ -1189,14 +1197,9 @@ UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, /* [in] */
LPWAVEHDR lpsegWaveOutHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WODM_WRITE, (DWORD_PTR)lpsegWaveOutHdr, uSize, FALSE);
return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut), WODM_WRITE, (DWORD_PTR)lpsegWaveOutHdr, uSize);
}
/**************************************************************************
......@@ -1338,24 +1341,18 @@ UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16* lpuDeviceID)
DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04x, %u, %d, %d)\n", hWaveOut, uMessage, dwParam1, dwParam2);
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL) {
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, 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)hWaveOut < waveOutGetNumDevs())
{
if (uMessage == DRV_QUERYDRVENTRY || uMessage == DRV_QUERYDEVNODE)
dwParam1 = (DWORD)MapSL(dwParam1);
}
/* from M$ KB */
if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
else if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
/* from M$ KB */
return MMSYSERR_INVALPARAM;
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
return MMSYSTDRV_Message(HWAVEOUT_32(hWaveOut), uMessage, dwParam1, dwParam2);
}
/**************************************************************************
......
......@@ -203,10 +203,6 @@ LPSTR MCI_strdupWtoA(LPCWSTR str);
BOOL WINMM_CheckForMMSystem(void);
const char* WINMM_ErrorToString(MMRESULT error);
UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
void TIME_MMTimeStop(void);
/* Global variables */
......
......@@ -2024,18 +2024,18 @@ MMRESULT WINAPI midiStreamStop(HMIDISTRM hMidiStrm)
return ret;
}
UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32)
static UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags)
{
HANDLE handle;
LPWINE_MLD wmld;
DWORD dwRet = MMSYSERR_NOERROR;
WAVEOPENDESC wod;
TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08X, %d);\n",
TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08X);\n",
lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback,
dwInstance, dwFlags, bFrom32?32:16);
dwInstance, dwFlags);
if (dwFlags & WAVE_FORMAT_QUERY)
TRACE("WAVE_FORMAT_QUERY requested !\n");
......@@ -2056,7 +2056,7 @@ UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
lpFormat->nAvgBytesPerSec, lpFormat->nBlockAlign, lpFormat->wBitsPerSample);
if ((wmld = MMDRV_Alloc(sizeof(WINE_WAVE), uType, &handle,
&dwFlags, &dwCallback, &dwInstance, bFrom32)) == NULL) {
&dwFlags, &dwCallback, &dwInstance, TRUE)) == NULL) {
WARN("no memory\n");
return MMSYSERR_NOMEM;
}
......@@ -2215,7 +2215,7 @@ MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
DWORD_PTR dwInstance, DWORD dwFlags)
{
return WAVE_Open((HANDLE*)lphWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
dwCallback, dwInstance, dwFlags, TRUE);
dwCallback, dwInstance, dwFlags);
}
/**************************************************************************
......@@ -2581,11 +2581,11 @@ UINT WINAPI waveInGetDevCapsA(UINT_PTR uDeviceID, LPWAVEINCAPSA lpCaps, UINT uSi
* waveInOpen [WINMM.@]
*/
MMRESULT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags)
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD_PTR dwInstance, DWORD dwFlags)
{
return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
dwCallback, dwInstance, dwFlags, TRUE);
dwCallback, dwInstance, dwFlags);
}
/**************************************************************************
......
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