Commit c75c2668 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Fixed a bug where wrong a return value was returned when mapping is

not possible.
parent cd072ca2
...@@ -121,6 +121,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx, ...@@ -121,6 +121,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
DWORD dwFlags) DWORD dwFlags)
{ {
DWORD ret; DWORD ret;
TRACE("(%p, %04x, %p, %p, %08lx)\n", wom, idx, lpDesc, lpwfx, dwFlags);
/* destination is always PCM, so the formulas below apply */ /* destination is always PCM, so the formulas below apply */
lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8; lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8;
...@@ -138,6 +139,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx, ...@@ -138,6 +139,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
wom->hAcmStream = 0; wom->hAcmStream = 0;
} }
} }
WARN("ret = %08lx\n", ret);
return ret; return ret;
} }
...@@ -146,6 +148,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -146,6 +148,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
UINT ndlo, ndhi; UINT ndlo, ndhi;
UINT i; UINT i;
WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA)); WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
DWORD res;
TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags);
...@@ -187,7 +190,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -187,7 +190,7 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
/* try some ACM stuff */ /* try some ACM stuff */
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ #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 MMSYSERR_NOERROR: wom->avgSpeedInner = wfx.nAvgBytesPerSec; goto found; \
case WAVERR_BADFORMAT: break; \ case WAVERR_BADFORMAT: break; \
default: goto error; \ default: goto error; \
...@@ -255,6 +258,11 @@ found: ...@@ -255,6 +258,11 @@ found:
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
error: error:
HeapFree(GetProcessHeap(), 0, wom); HeapFree(GetProcessHeap(), 0, wom);
if (res==ACMERR_NOTPOSSIBLE) {
WARN("ret = WAVERR_BADFORMAT\n");
return WAVERR_BADFORMAT;
}
WARN("ret = MMSYSERR_ERROR\n");
return MMSYSERR_ERROR; return MMSYSERR_ERROR;
} }
...@@ -594,6 +602,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -594,6 +602,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
UINT ndlo, ndhi; UINT ndlo, ndhi;
UINT i; UINT i;
WAVEMAPDATA* wim = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA)); WAVEMAPDATA* wim = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
DWORD res;
TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags);
...@@ -635,7 +644,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -635,7 +644,7 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
/* try some ACM stuff */ /* try some ACM stuff */
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ #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 MMSYSERR_NOERROR: wim->avgSpeedInner = wfx.nAvgBytesPerSec; goto found; \
case WAVERR_BADFORMAT: break; \ case WAVERR_BADFORMAT: break; \
default: goto error; \ default: goto error; \
...@@ -702,6 +711,11 @@ found: ...@@ -702,6 +711,11 @@ found:
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
error: error:
HeapFree(GetProcessHeap(), 0, wim); HeapFree(GetProcessHeap(), 0, wim);
if (res==ACMERR_NOTPOSSIBLE) {
WARN("ret = WAVERR_BADFORMAT\n");
return WAVERR_BADFORMAT;
}
WARN("ret = MMSYSERR_ERROR\n");
return MMSYSERR_ERROR; return MMSYSERR_ERROR;
} }
......
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