From a41cfac6b98f9e2f25eafe4332b6791c07e98e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 16 Jun 2004 18:40:05 +0000 Subject: [PATCH] Sync to Wine-20040615: Robert Reif - Added tracing to all functions. - Added error explanations. - Changed debug channel from msacm to wavemap so not confused with msacm. - Handle case where partial structure update requested. - Minor white space cleanup. - Returns proper error code when trying to get caps when no devices present. - Fixed a bug where wrong a return value was returned when mapping is not possible. svn path=/trunk/; revision=9685 --- reactos/lib/winmm/wavemap/wavemap.c | 206 ++++++++++++++++++++++------ 1 file changed, 166 insertions(+), 40 deletions(-) diff --git a/reactos/lib/winmm/wavemap/wavemap.c b/reactos/lib/winmm/wavemap/wavemap.c index 6d53e498c53..c91bbf44f57 100644 --- a/reactos/lib/winmm/wavemap/wavemap.c +++ b/reactos/lib/winmm/wavemap/wavemap.c @@ -39,7 +39,7 @@ #include "msacm.h" #include "wine/debug.h" -WINE_DEFAULT_DEBUG_CHANNEL(msacm); +WINE_DEFAULT_DEBUG_CHANNEL(wavemap); typedef struct tagWAVEMAPDATA { struct tagWAVEMAPDATA* self; @@ -122,6 +122,8 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx, { DWORD ret; + TRACE("(%p %04x %p %p %08lx)\n", wom, idx, lpDesc, lpwfx, dwFlags); + /* destination is always PCM, so the formulas below apply */ lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8; lpwfx->nAvgBytesPerSec = lpwfx->nSamplesPerSec * lpwfx->nBlockAlign; @@ -138,6 +140,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx, wom->hAcmStream = 0; } } + TRACE("ret = %08lx\n", ret); return ret; } @@ -146,15 +149,21 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) UINT ndlo, ndhi; UINT i; WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA)); + DWORD res; TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); - if (!wom) + if (!wom) { + WARN("no memory\n"); return MMSYSERR_NOMEM; + } ndhi = waveOutGetNumDevs(); if (dwFlags & WAVE_MAPPED) { - if (lpDesc->uMappedDeviceID >= ndhi) return MMSYSERR_INVALPARAM; + if (lpDesc->uMappedDeviceID >= ndhi) { + WARN("invalid parameter: dwFlags WAVE_MAPPED\n"); + return MMSYSERR_INVALPARAM; + } ndlo = lpDesc->uMappedDeviceID; ndhi = ndlo + 1; dwFlags &= ~WAVE_MAPPED; @@ -187,7 +196,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) /* try some ACM stuff */ #define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ - switch (wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \ + switch (res=wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \ case MMSYSERR_NOERROR: wom->avgSpeedInner = wfx.nAvgBytesPerSec; goto found; \ case WAVERR_BADFORMAT: break; \ default: goto error; \ @@ -243,6 +252,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) } HeapFree(GetProcessHeap(), 0, wom); + WARN("ret = WAVERR_BADFORMAT\n"); return WAVERR_BADFORMAT; found: @@ -255,13 +265,21 @@ found: return MMSYSERR_NOERROR; error: HeapFree(GetProcessHeap(), 0, wom); + if (res==ACMERR_NOTPOSSIBLE) { + WARN("ret = WAVERR_BADFORMAT\n"); + return WAVERR_BADFORMAT; + } + WARN("ret = MMSYSERR_ERROR\n"); return MMSYSERR_ERROR; } static DWORD wodClose(WAVEMAPDATA* wom) { - DWORD ret = waveOutClose(wom->u.out.hInnerWave); + DWORD ret; + TRACE("(%p)\n", wom); + + ret = waveOutClose(wom->u.out.hInnerWave); if (ret == MMSYSERR_NOERROR) { if (wom->hAcmStream) { ret = acmStreamClose(wom->hAcmStream, 0); @@ -278,6 +296,8 @@ static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2) PACMSTREAMHEADER ash; LPWAVEHDR lpWaveHdrDst; + TRACE("(%p %p %08lx)\n", wom, lpWaveHdrSrc, dwParam2); + if (!wom->hAcmStream) { return waveOutWrite(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2); } @@ -286,8 +306,10 @@ static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2) ash = (PACMSTREAMHEADER)lpWaveHdrSrc->reserved; /* acmStreamConvert will actually check that the new size is less than initial size */ ash->cbSrcLength = lpWaveHdrSrc->dwBufferLength; - if (acmStreamConvert(wom->hAcmStream, ash, 0L) != MMSYSERR_NOERROR) + if (acmStreamConvert(wom->hAcmStream, ash, 0L) != MMSYSERR_NOERROR) { + WARN("acmStreamConvert failed\n"); return MMSYSERR_ERROR; + } lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER)); if (ash->cbSrcLength > ash->cbSrcLengthUsed) @@ -295,8 +317,7 @@ static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2) else if (ash->cbSrcLength < ash->cbSrcLengthUsed) ERR("CoDec has read more data than it is allowed to\n"); - if (ash->cbDstLengthUsed == 0) - { + if (ash->cbDstLengthUsed == 0) { /* something went wrong in decoding */ FIXME("Got 0 length\n"); return MMSYSERR_ERROR; @@ -312,15 +333,21 @@ static DWORD wodPrepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2 DWORD dwRet; LPWAVEHDR lpWaveHdrDst; - if (!wom->hAcmStream) { + TRACE("(%p %p %08lx)\n", wom, lpWaveHdrSrc, dwParam2); + + if (!wom->hAcmStream) return waveOutPrepareHeader(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2); - } - if (acmStreamSize(wom->hAcmStream, lpWaveHdrSrc->dwBufferLength, &size, ACM_STREAMSIZEF_SOURCE) != MMSYSERR_NOERROR) + + if (acmStreamSize(wom->hAcmStream, lpWaveHdrSrc->dwBufferLength, &size, ACM_STREAMSIZEF_SOURCE) != MMSYSERR_NOERROR) { + WARN("acmStreamSize failed\n"); return MMSYSERR_ERROR; + } ash = HeapAlloc(GetProcessHeap(), 0, sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR) + size); - if (ash == NULL) + if (ash == NULL) { + WARN("no memory\n"); return MMSYSERR_NOMEM; + } ash->cbStruct = sizeof(*ash); ash->fdwStatus = 0L; @@ -334,8 +361,10 @@ static DWORD wodPrepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2 /* ash->cbDstLengthUsed */ ash->dwDstUser = 0; /* FIXME ? */ dwRet = acmStreamPrepareHeader(wom->hAcmStream, ash, 0L); - if (dwRet != MMSYSERR_NOERROR) + if (dwRet != MMSYSERR_NOERROR) { + WARN("acmStreamPrepareHeader failed\n"); goto errCleanUp; + } lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER)); lpWaveHdrDst->lpData = ash->pbDst; @@ -343,8 +372,10 @@ static DWORD wodPrepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2 lpWaveHdrDst->dwFlags = 0; lpWaveHdrDst->dwLoops = 0; dwRet = waveOutPrepareHeader(wom->u.out.hInnerWave, lpWaveHdrDst, sizeof(*lpWaveHdrDst)); - if (dwRet != MMSYSERR_NOERROR) + if (dwRet != MMSYSERR_NOERROR) { + WARN("waveOutPrepareHeader failed\n"); goto errCleanUp; + } lpWaveHdrSrc->reserved = (DWORD)ash; lpWaveHdrSrc->dwFlags = WHDR_PREPARED; @@ -362,6 +393,8 @@ static DWORD wodUnprepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwPara LPWAVEHDR lpWaveHdrDst; DWORD dwRet1, dwRet2; + TRACE("(%p %p %08lx)\n", wom, lpWaveHdrSrc, dwParam2); + if (!wom->hAcmStream) { return waveOutUnprepareHeader(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2); } @@ -379,7 +412,10 @@ static DWORD wodUnprepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwPara static DWORD wodGetPosition(WAVEMAPDATA* wom, LPMMTIME lpTime, DWORD dwParam2) { - DWORD val = waveOutGetPosition(wom->u.out.hInnerWave, lpTime, dwParam2); + DWORD val; + TRACE("(%p %p %08lx)\n", wom, lpTime, dwParam2); + + val = waveOutGetPosition(wom->u.out.hInnerWave, lpTime, dwParam2); if (lpTime->wType == TIME_BYTES) lpTime->u.cb = MulDiv(lpTime->u.cb, wom->avgSpeedOuter, wom->avgSpeedInner); /* other time types don't require conversion */ @@ -388,21 +424,32 @@ static DWORD wodGetPosition(WAVEMAPDATA* wom, LPMMTIME lpTime, DWORD dwParam2) static DWORD wodGetDevCaps(UINT wDevID, WAVEMAPDATA* wom, LPWAVEOUTCAPSA lpWaveCaps, DWORD dwParam2) { + TRACE("(%04x %p %p %08lx)\n",wDevID, wom, lpWaveCaps, dwParam2); + /* if opened low driver, forward message */ if (WAVEMAP_IsData(wom)) return waveOutGetDevCapsA((UINT)wom->u.out.hInnerWave, lpWaveCaps, dwParam2); + /* else if no drivers, nothing to map so return bad device */ + if (waveOutGetNumDevs() == 0) { + WARN("bad device id\n"); + return MMSYSERR_BADDEVICEID; + } /* otherwise, return caps of mapper itself */ if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) { - lpWaveCaps->wMid = 0x00FF; - lpWaveCaps->wPid = 0x0001; - lpWaveCaps->vDriverVersion = 0x0100; - strcpy(lpWaveCaps->szPname, "Wine wave out mapper"); - lpWaveCaps->dwFormats = + WAVEOUTCAPSA woc; + woc.wMid = 0x00FF; + woc.wPid = 0x0001; + woc.vDriverVersion = 0x0100; + strcpy(woc.szPname, "Wine wave out mapper"); + woc.dwFormats = + WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16 | + WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 | WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 | WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 | WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16; - lpWaveCaps->wChannels = 2; - lpWaveCaps->dwSupport = WAVECAPS_VOLUME | WAVECAPS_LRVOLUME; + woc.wChannels = 2; + woc.dwSupport = WAVECAPS_VOLUME | WAVECAPS_LRVOLUME; + memcpy(lpWaveCaps, &woc, min(dwParam2, sizeof(woc))); return MMSYSERR_NOERROR; } @@ -412,6 +459,8 @@ static DWORD wodGetDevCaps(UINT wDevID, WAVEMAPDATA* wom, LPWAVEOUTCAPSA lpWaveC static DWORD wodGetVolume(UINT wDevID, WAVEMAPDATA* wom, LPDWORD lpVol) { + TRACE("(%04x %p %p)\n",wDevID, wom, lpVol); + if (WAVEMAP_IsData(wom)) return waveOutGetVolume(wom->u.out.hInnerWave, lpVol); return MMSYSERR_NOERROR; @@ -419,6 +468,8 @@ static DWORD wodGetVolume(UINT wDevID, WAVEMAPDATA* wom, LPDWORD lpVol) static DWORD wodSetVolume(UINT wDevID, WAVEMAPDATA* wom, DWORD vol) { + TRACE("(%04x %p %08lx)\n",wDevID, wom, vol); + if (WAVEMAP_IsData(wom)) return waveOutSetVolume(wom->u.out.hInnerWave, vol); return MMSYSERR_NOERROR; @@ -426,21 +477,29 @@ static DWORD wodSetVolume(UINT wDevID, WAVEMAPDATA* wom, DWORD vol) static DWORD wodPause(WAVEMAPDATA* wom) { + TRACE("(%p)\n",wom); + return waveOutPause(wom->u.out.hInnerWave); } static DWORD wodRestart(WAVEMAPDATA* wom) { + TRACE("(%p)\n",wom); + return waveOutRestart(wom->u.out.hInnerWave); } static DWORD wodReset(WAVEMAPDATA* wom) { + TRACE("(%p)\n",wom); + return waveOutReset(wom->u.out.hInnerWave); } static DWORD wodBreakLoop(WAVEMAPDATA* wom) { + TRACE("(%p)\n",wom); + return waveOutBreakLoop(wom->u.out.hInnerWave); } @@ -449,6 +508,8 @@ static DWORD wodMapperStatus(WAVEMAPDATA* wom, DWORD flags, LPVOID ptr) UINT id; DWORD ret = MMSYSERR_NOTSUPPORTED; + TRACE("(%p %08lx %p)\n",wom, flags, ptr); + switch (flags) { case WAVEOUT_MAPPER_STATUS_DEVICE: ret = waveOutGetID(wom->u.out.hInnerWave, &id); @@ -506,6 +567,10 @@ DWORD WINAPI WAVEMAP_wodMessage(UINT wDevID, UINT wMsg, DWORD dwUser, case WODM_RESTART: return wodRestart ((WAVEMAPDATA*)dwUser); case WODM_RESET: return wodReset ((WAVEMAPDATA*)dwUser); case WODM_MAPPER_STATUS: return wodMapperStatus ((WAVEMAPDATA*)dwUser, dwParam1, (LPVOID)dwParam2); + /* known but not supported */ + case DRV_QUERYDEVICEINTERFACESIZE: + case DRV_QUERYDEVICEINTERFACE: + return MMSYSERR_NOTSUPPORTED; default: FIXME("unknown message %d!\n", wMsg); } @@ -570,6 +635,8 @@ static DWORD widOpenHelper(WAVEMAPDATA* wim, UINT idx, { DWORD ret; + TRACE("(%p %04x %p %p %08lx)\n", wim, idx, lpDesc, lpwfx, dwFlags); + /* source is always PCM, so the formulas below apply */ lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8; lpwfx->nAvgBytesPerSec = lpwfx->nSamplesPerSec * lpwfx->nBlockAlign; @@ -586,6 +653,7 @@ static DWORD widOpenHelper(WAVEMAPDATA* wim, UINT idx, wim->hAcmStream = 0; } } + TRACE("ret = %08lx\n", ret); return ret; } @@ -594,11 +662,14 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) UINT ndlo, ndhi; UINT i; WAVEMAPDATA* wim = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA)); + DWORD res; TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); - if (!wim) + if (!wim) { + WARN("no memory\n"); return MMSYSERR_NOMEM; + } wim->self = wim; wim->dwCallback = lpDesc->dwCallback; @@ -633,14 +704,14 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */ /* try some ACM stuff */ - + #define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ - switch (widOpenHelper(wim, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \ + switch (res=widOpenHelper(wim, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \ case MMSYSERR_NOERROR: wim->avgSpeedInner = wfx.nAvgBytesPerSec; goto found; \ case WAVERR_BADFORMAT: break; \ default: goto error; \ } - + for (i = ndlo; i < ndhi; i++) { wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec; /* first try with same stereo/mono option as source */ @@ -661,7 +732,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) TRY(44100, 16); TRY(22050, 16); TRY(11025, 16); - + /* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */ wfx.nChannels ^= 3; TRY(96000, 16); @@ -677,7 +748,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) TRY(44100, 8); TRY(22050, 8); TRY(11025, 8); - + /* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */ wfx.nChannels ^= 3; TRY(96000, 8); @@ -690,6 +761,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) } HeapFree(GetProcessHeap(), 0, wim); + WARN("ret = WAVERR_BADFORMAT\n"); return WAVERR_BADFORMAT; found: if (dwFlags & WAVE_FORMAT_QUERY) { @@ -702,13 +774,21 @@ found: return MMSYSERR_NOERROR; error: HeapFree(GetProcessHeap(), 0, wim); + if (res==ACMERR_NOTPOSSIBLE) { + WARN("ret = WAVERR_BADFORMAT\n"); + return WAVERR_BADFORMAT; + } + WARN("ret = MMSYSERR_ERROR\n"); return MMSYSERR_ERROR; } static DWORD widClose(WAVEMAPDATA* wim) { - DWORD ret = waveInClose(wim->u.in.hInnerWave); + DWORD ret; + TRACE("(%p)\n", wim); + + ret = waveInClose(wim->u.in.hInnerWave); if (ret == MMSYSERR_NOERROR) { if (wim->hAcmStream) { ret = acmStreamClose(wim->hAcmStream, 0); @@ -725,6 +805,8 @@ static DWORD widAddBuffer(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwPara PACMSTREAMHEADER ash; LPWAVEHDR lpWaveHdrSrc; + TRACE("(%p %p %08lx)\n", wim, lpWaveHdrDst, dwParam2); + if (!wim->hAcmStream) { return waveInAddBuffer(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2); } @@ -743,16 +825,22 @@ static DWORD widPrepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2 DWORD dwRet; LPWAVEHDR lpWaveHdrSrc; + TRACE("(%p %p %08lx)\n", wim, lpWaveHdrDst, dwParam2); + if (!wim->hAcmStream) { return waveInPrepareHeader(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2); } if (acmStreamSize(wim->hAcmStream, lpWaveHdrDst->dwBufferLength, &size, - ACM_STREAMSIZEF_DESTINATION) != MMSYSERR_NOERROR) + ACM_STREAMSIZEF_DESTINATION) != MMSYSERR_NOERROR) { + WARN("acmStreamSize failed\n"); return MMSYSERR_ERROR; + } ash = HeapAlloc(GetProcessHeap(), 0, sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR) + size); - if (ash == NULL) + if (ash == NULL) { + WARN("no memory\n"); return MMSYSERR_NOMEM; + } ash->cbStruct = sizeof(*ash); ash->fdwStatus = 0L; @@ -766,8 +854,10 @@ static DWORD widPrepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2 /* ash->cbDstLengthUsed */ ash->dwDstUser = lpWaveHdrDst->dwUser; /* FIXME ? */ dwRet = acmStreamPrepareHeader(wim->hAcmStream, ash, 0L); - if (dwRet != MMSYSERR_NOERROR) + if (dwRet != MMSYSERR_NOERROR) { + WARN("acmStreamPrepareHeader failed\n"); goto errCleanUp; + } lpWaveHdrSrc = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER)); lpWaveHdrSrc->lpData = ash->pbSrc; @@ -775,8 +865,10 @@ static DWORD widPrepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2 lpWaveHdrSrc->dwFlags = 0; lpWaveHdrSrc->dwLoops = 0; dwRet = waveInPrepareHeader(wim->u.in.hInnerWave, lpWaveHdrSrc, sizeof(*lpWaveHdrSrc)); - if (dwRet != MMSYSERR_NOERROR) + if (dwRet != MMSYSERR_NOERROR) { + WARN("waveInPrepareHeader failed\n"); goto errCleanUp; + } lpWaveHdrDst->reserved = (DWORD)ash; lpWaveHdrDst->dwFlags = WHDR_PREPARED; @@ -794,6 +886,8 @@ static DWORD widUnprepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwPara LPWAVEHDR lpWaveHdrSrc; DWORD dwRet1, dwRet2; + TRACE("(%p %p %08lx)\n", wim, lpWaveHdrDst, dwParam2); + if (!wim->hAcmStream) { return waveInUnprepareHeader(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2); } @@ -811,7 +905,11 @@ static DWORD widUnprepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwPara static DWORD widGetPosition(WAVEMAPDATA* wim, LPMMTIME lpTime, DWORD dwParam2) { - DWORD val = waveInGetPosition(wim->u.in.hInnerWave, lpTime, dwParam2); + DWORD val; + + TRACE("(%p %p %08lx)\n", wim, lpTime, dwParam2); + + val = waveInGetPosition(wim->u.in.hInnerWave, lpTime, dwParam2); if (lpTime->wType == TIME_BYTES) lpTime->u.cb = MulDiv(lpTime->u.cb, wim->avgSpeedOuter, wim->avgSpeedInner); /* other time types don't require conversion */ @@ -820,20 +918,32 @@ static DWORD widGetPosition(WAVEMAPDATA* wim, LPMMTIME lpTime, DWORD dwParam2) static DWORD widGetDevCaps(UINT wDevID, WAVEMAPDATA* wim, LPWAVEINCAPSA lpWaveCaps, DWORD dwParam2) { + TRACE("(%04x, %p %p %08lx)\n", wDevID, wim, lpWaveCaps, dwParam2); + /* if opened low driver, forward message */ if (WAVEMAP_IsData(wim)) return waveInGetDevCapsA((UINT)wim->u.in.hInnerWave, lpWaveCaps, dwParam2); + /* else if no drivers, nothing to map so return bad device */ + if (waveInGetNumDevs() == 0) { + WARN("bad device id\n"); + return MMSYSERR_BADDEVICEID; + } /* otherwise, return caps of mapper itself */ if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) { - lpWaveCaps->wMid = 0x00FF; - lpWaveCaps->wPid = 0x0001; - lpWaveCaps->vDriverVersion = 0x0001; - strcpy(lpWaveCaps->szPname, "Wine wave in mapper"); - lpWaveCaps->dwFormats = + WAVEINCAPSA wic; + wic.wMid = 0x00FF; + wic.wPid = 0x0001; + wic.vDriverVersion = 0x0001; + strcpy(wic.szPname, "Wine wave in mapper"); + wic.dwFormats = + WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16 | + WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 | WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 | WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 | WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16; - lpWaveCaps->wChannels = 2; + wic.wChannels = 2; + memcpy(lpWaveCaps, &wic, min(dwParam2, sizeof(wic))); + return MMSYSERR_NOERROR; } ERR("This shouldn't happen\n"); @@ -842,16 +952,22 @@ static DWORD widGetDevCaps(UINT wDevID, WAVEMAPDATA* wim, LPWAVEINCAPSA lpWaveCa static DWORD widStop(WAVEMAPDATA* wim) { + TRACE("(%p)\n", wim); + return waveInStop(wim->u.in.hInnerWave); } static DWORD widStart(WAVEMAPDATA* wim) { + TRACE("(%p)\n", wim); + return waveInStart(wim->u.in.hInnerWave); } static DWORD widReset(WAVEMAPDATA* wim) { + TRACE("(%p)\n", wim); + return waveInReset(wim->u.in.hInnerWave); } @@ -860,6 +976,8 @@ static DWORD widMapperStatus(WAVEMAPDATA* wim, DWORD flags, LPVOID ptr) UINT id; DWORD ret = MMSYSERR_NOTSUPPORTED; + TRACE("(%p %08lx %p)\n", wim, flags, ptr); + switch (flags) { case WAVEIN_MAPPER_STATUS_DEVICE: ret = waveInGetID(wim->u.in.hInnerWave, &id); @@ -912,6 +1030,10 @@ DWORD WINAPI WAVEMAP_widMessage(WORD wDevID, WORD wMsg, DWORD dwUser, case WIDM_START: return widStart ((WAVEMAPDATA*)dwUser); case WIDM_STOP: return widStop ((WAVEMAPDATA*)dwUser); case WIDM_MAPPER_STATUS: return widMapperStatus ((WAVEMAPDATA*)dwUser, dwParam1, (LPVOID)dwParam2); + /* known but not supported */ + case DRV_QUERYDEVICEINTERFACESIZE: + case DRV_QUERYDEVICEINTERFACE: + return MMSYSERR_NOTSUPPORTED; default: FIXME("unknown message %u!\n", wMsg); } @@ -929,6 +1051,8 @@ static struct WINE_WAVEMAP* oss = NULL; */ static DWORD WAVEMAP_drvOpen(LPSTR str) { + TRACE("(%p)\n", str); + if (oss) return 0; @@ -942,6 +1066,8 @@ static DWORD WAVEMAP_drvOpen(LPSTR str) */ static DWORD WAVEMAP_drvClose(DWORD dwDevID) { + TRACE("(%08lx)\n", dwDevID); + if (oss) { oss = NULL; return 1;