Added tracing to all functions.

Added error explanations.
Changed debug channel from msacm to wavemap so not confused with
msacm.
This commit is contained in:
Robert Reif 2004-06-14 17:55:03 +00:00 committed by Alexandre Julliard
parent 3aab82079e
commit a9d5f0829a
1 changed files with 122 additions and 25 deletions

View File

@ -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;
@ -121,7 +121,8 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
DWORD dwFlags)
{
DWORD ret;
TRACE("(%p, %04x, %p, %p, %08lx)\n", wom, idx, lpDesc, lpwfx, dwFlags);
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;
@ -139,7 +140,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
wom->hAcmStream = 0;
}
}
WARN("ret = %08lx\n", ret);
TRACE("ret = %08lx\n", ret);
return ret;
}
@ -152,12 +153,17 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
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;
@ -246,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:
@ -268,8 +275,11 @@ 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);
@ -286,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);
}
@ -294,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)
@ -303,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;
@ -320,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;
@ -342,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;
@ -351,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;
@ -370,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);
}
@ -387,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 */
@ -396,12 +424,16 @@ 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)
if (waveOutGetNumDevs() == 0) {
WARN("bad device id\n");
return MMSYSERR_BADDEVICEID;
}
/* otherwise, return caps of mapper itself */
if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) {
WAVEOUTCAPSA woc;
@ -427,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;
@ -434,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;
@ -441,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);
}
@ -464,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);
@ -521,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);
}
@ -585,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;
@ -601,6 +653,7 @@ static DWORD widOpenHelper(WAVEMAPDATA* wim, UINT idx,
wim->hAcmStream = 0;
}
}
TRACE("ret = %08lx\n", ret);
return ret;
}
@ -613,8 +666,10 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
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;
@ -706,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) {
@ -728,8 +784,11 @@ 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);
@ -746,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);
}
@ -764,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;
@ -787,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;
@ -796,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;
@ -815,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);
}
@ -832,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 */
@ -841,12 +918,16 @@ 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)
if (waveInGetNumDevs() == 0) {
WARN("bad device id\n");
return MMSYSERR_BADDEVICEID;
}
/* otherwise, return caps of mapper itself */
if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) {
WAVEINCAPSA wic;
@ -871,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);
}
@ -889,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);
@ -941,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);
}
@ -958,6 +1051,8 @@ static struct WINE_WAVEMAP* oss = NULL;
*/
static DWORD WAVEMAP_drvOpen(LPSTR str)
{
TRACE("(%p)\n", str);
if (oss)
return 0;
@ -971,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;