Commit d45f041e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed wave(In|Out)Open when called with WAVE_MAPPED flag; some minor

16/32 API call ordering.
parent 0bf1c246
......@@ -619,18 +619,18 @@ BOOL16 WINAPI sndPlaySound16(LPCSTR lpszSoundName, UINT16 uFlags)
/**************************************************************************
* mmsystemGetVersion [WINMM.@]
* mmsystemGetVersion [MMSYSTEM.5]
* return value borrowed from Win95 winmm.dll ;)
*/
UINT WINAPI mmsystemGetVersion(void)
UINT16 WINAPI mmsystemGetVersion16(void)
{
return mmsystemGetVersion16();
return mmsystemGetVersion();
}
/**************************************************************************
* mmsystemGetVersion [MMSYSTEM.5]
* return value borrowed from Win95 winmm.dll ;)
* mmsystemGetVersion [WINMM.@]
*/
UINT16 WINAPI mmsystemGetVersion16(void)
UINT WINAPI mmsystemGetVersion(void)
{
TRACE("3.10 (Win95?)\n");
return 0x030a;
......@@ -1538,17 +1538,17 @@ BOOL WINAPI mciGetErrorStringW(DWORD wError, LPWSTR lpstrBuffer, UINT uLength)
}
/**************************************************************************
* mciGetErrorStringA [WINMM.@]
* mciGetErrorString [MMSYSTEM.706]
*/
BOOL WINAPI mciGetErrorStringA(DWORD wError, LPSTR lpstrBuffer, UINT uLength)
BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
{
return mciGetErrorString16(wError, lpstrBuffer, uLength);
return mciGetErrorStringA(wError, lpstrBuffer, uLength);
}
/**************************************************************************
* mciGetErrorString [MMSYSTEM.706]
* mciGetErrorStringA [WINMM.@]
*/
BOOL16 WINAPI mciGetErrorString16(DWORD dwError, LPSTR lpstrBuffer, UINT16 uLength)
BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength)
{
BOOL16 ret = FALSE;
......@@ -3650,6 +3650,8 @@ static UINT WINAPI MMSYSTEM_waveOpen(HANDLE* lphndl, UINT uDeviceID, UINT uType,
if (dwFlags & WAVE_FORMAT_QUERY) TRACE("WAVE_FORMAT_QUERY requested !\n");
if (lpFormat == NULL) return WAVERR_BADFORMAT;
if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1))
return MMSYSERR_INVALPARAM;
TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
lpFormat->wFormatTag, lpFormat->nChannels, lpFormat->nSamplesPerSec,
......@@ -3663,19 +3665,22 @@ static UINT WINAPI MMSYSTEM_waveOpen(HANDLE* lphndl, UINT uDeviceID, UINT uType,
wod.lpFormat = lpFormat; /* should the struct be copied iso pointer? */
wod.dwCallback = dwCallback;
wod.dwInstance = dwInstance;
wod.uMappedDeviceID = 0;
wod.dnDevNode = 0L;
/* when called from 16 bit code, mapper will be 0x0000FFFF instead of 0xFFFFFFFF */
/* this should fix it */
wmld->uDeviceID = (uDeviceID == (UINT16)-1 && !bFrom32) ? (UINT)-1 : uDeviceID;
if (dwFlags & WAVE_MAPPED) {
wod.uMappedDeviceID = uDeviceID;
uDeviceID = WAVE_MAPPER;
} else {
wod.uMappedDeviceID = -1;
}
wmld->uDeviceID = uDeviceID;
dwRet = MMDRV_Open(wmld, (uType==MMDRV_WAVEOUT)?WODM_OPEN:WIDM_OPEN, (DWORD)&wod, dwFlags);
dwRet = MMDRV_Open(wmld, (uType == MMDRV_WAVEOUT) ? WODM_OPEN : WIDM_OPEN, (DWORD)&wod, dwFlags);
if ((dwFlags & WAVE_FORMAT_QUERY) || dwRet != MMSYSERR_NOERROR) {
MMDRV_Free(handle, wmld);
handle = 0;
}
}
if (lphndl != NULL) *lphndl = handle;
TRACE("=> %ld hWave=%04x\n", dwRet, handle);
......@@ -3848,9 +3853,11 @@ UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
/* 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 = MMSYSTEM_waveOpen(&hWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
dwCallback, dwInstance, dwFlags, FALSE);
ret = MMSYSTEM_waveOpen(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEOUT, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
if (lphWaveOut != NULL) *lphWaveOut = hWaveOut;
return ret;
......@@ -4489,9 +4496,11 @@ UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
/* 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 = MMSYSTEM_waveOpen(&hWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
dwCallback, dwInstance, dwFlags, FALSE);
ret = MMSYSTEM_waveOpen(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEIN, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
if (lphWaveIn != NULL) *lphWaveIn = hWaveIn;
return ret;
......
......@@ -111,7 +111,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
{
UINT nd = waveOutGetNumDevs();
UINT ndlo, ndhi;
UINT i;
WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
WAVEFORMATEX wfx;
......@@ -121,13 +121,22 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!wom)
return MMSYSERR_NOMEM;
ndhi = waveOutGetNumDevs();
if (dwFlags & WAVE_MAPPED) {
if (lpDesc->uMappedDeviceID >= ndhi) return MMSYSERR_INVALPARAM;
ndlo = lpDesc->uMappedDeviceID;
ndhi = ndlo + 1;
dwFlags &= ~WAVE_MAPPED;
} else {
ndlo = 0;
}
wom->self = wom;
wom->dwCallback = lpDesc->dwCallback;
wom->dwFlags = dwFlags;
wom->dwClientInstance = lpDesc->dwInstance;
wom->hOuterWave = lpDesc->hWave;
for (i = 0; i < nd; i++) {
for (i = ndlo; i < ndhi; i++) {
/* if no ACM stuff is involved, no need to handle callbacks at this
* level, this will be done transparently
*/
......@@ -145,7 +154,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
if (wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags) == MMSYSERR_NOERROR) goto found;
for (i = 0; i < nd; i++) {
for (i = ndlo; i < ndhi; i++) {
/* first try with same stereo/mono option as source */
wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(44100, 16);
......@@ -435,7 +444,7 @@ static void CALLBACK widCallback(HWAVE hWave, UINT uMsg, DWORD dwInstance,
TRACE("(0x%x %u %ld %lx %lx);\n", hWave, uMsg, dwInstance, dwParam1, dwParam2);
if (!WAVEMAP_IsData(wim)) {
ERR("Bad date\n");
ERR("Bad data\n");
return;
}
......@@ -502,7 +511,7 @@ static DWORD widOpenHelper(WAVEMAPDATA* wim, UINT idx,
static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
{
UINT nd = waveInGetNumDevs();
UINT ndlo, ndhi;
UINT i;
WAVEMAPDATA* wim = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
WAVEFORMATEX wfx;
......@@ -518,7 +527,17 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wim->dwClientInstance = lpDesc->dwInstance;
wim->hOuterWave = lpDesc->hWave;
for (i = 0; i < nd; i++) {
ndhi = waveOutGetNumDevs();
if (dwFlags & WAVE_MAPPED) {
if (lpDesc->uMappedDeviceID >= ndhi) return MMSYSERR_INVALPARAM;
ndlo = lpDesc->uMappedDeviceID;
ndhi = ndlo + 1;
dwFlags &= ~WAVE_MAPPED;
} else {
ndlo = 0;
}
for (i = ndlo; i < ndhi; i++) {
if (waveInOpen(&wim->hInnerWave, i, lpDesc->lpFormat, (DWORD)widCallback,
(DWORD)wim, (dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION) == MMSYSERR_NOERROR) {
wim->hAcmStream = 0;
......@@ -532,7 +551,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
if (widOpenHelper(wim, i, lpDesc, &wfx, dwFlags) == MMSYSERR_NOERROR) goto found;
for (i = 0; i < nd; i++) {
for (i = ndlo; i < ndhi; i++) {
/* first try with same stereo/mono option as source */
wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(44100, 8);
......
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