Commit 60f21c3d authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Got rid of recursion in sub device opening.

parent b4ba9fa7
...@@ -128,7 +128,6 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -128,7 +128,6 @@ 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));
WAVEFORMATEX wfx;
TRACE("(%p %p %08lx\n", lpdwUser, lpDesc, dwFlags); TRACE("(%p %p %08lx\n", lpdwUser, lpDesc, dwFlags);
...@@ -155,45 +154,49 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -155,45 +154,49 @@ static DWORD wodOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
* level, this will be done transparently * level, this will be done transparently
*/ */
if (waveOutOpen(&wom->hInnerWave, i, lpDesc->lpFormat, (DWORD)wodCallback, if (waveOutOpen(&wom->hInnerWave, i, lpDesc->lpFormat, (DWORD)wodCallback,
(DWORD)wom, (dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION) == MMSYSERR_NOERROR) { (DWORD)wom, (dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) {
wom->hAcmStream = 0; wom->hAcmStream = 0;
goto found; goto found;
} }
} }
wfx.wFormatTag = WAVE_FORMAT_PCM; if ((dwFlags & WAVE_FORMAT_DIRECT) == 0) {
wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */ WAVEFORMATEX wfx;
/* try some ACM stuff */
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ wfx.wFormatTag = WAVE_FORMAT_PCM;
if (wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags) == MMSYSERR_NOERROR) goto found; wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */
/* try some ACM stuff */
for (i = ndlo; i < ndhi; i++) { #define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
/* first try with same stereo/mono option as source */ if (wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) goto found;
wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(44100, 16); for (i = ndlo; i < ndhi; i++) {
TRY(22050, 16); /* first try with same stereo/mono option as source */
TRY(11025, 16); wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(44100, 16);
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */ TRY(22050, 16);
wfx.nChannels ^= 3; TRY(11025, 16);
TRY(44100, 16);
TRY(22050, 16); /* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
TRY(11025, 16); wfx.nChannels ^= 3;
TRY(44100, 16);
/* first try with same stereo/mono option as source */ TRY(22050, 16);
wfx.nChannels = lpDesc->lpFormat->nChannels; TRY(11025, 16);
TRY(44100, 8);
TRY(22050, 8); /* first try with same stereo/mono option as source */
TRY(11025, 8); wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(44100, 8);
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */ TRY(22050, 8);
wfx.nChannels ^= 3; TRY(11025, 8);
TRY(44100, 8);
TRY(22050, 8); /* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
TRY(11025, 8); wfx.nChannels ^= 3;
} TRY(44100, 8);
TRY(22050, 8);
TRY(11025, 8);
}
#undef TRY #undef TRY
}
HeapFree(GetProcessHeap(), 0, wom); HeapFree(GetProcessHeap(), 0, wom);
return MMSYSERR_ALLOCATED; return MMSYSERR_ALLOCATED;
...@@ -239,6 +242,11 @@ static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2) ...@@ -239,6 +242,11 @@ static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2)
return MMSYSERR_ERROR; return MMSYSERR_ERROR;
lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER)); lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
if (ash->cbSrcLength > ash->cbSrcLengthUsed)
FIXME("Not all src buffer has been written, expect bogus sound\n");
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 */ /* something went wrong in decoding */
...@@ -536,7 +544,6 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -536,7 +544,6 @@ 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));
WAVEFORMATEX wfx;
TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags);
...@@ -561,32 +568,38 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -561,32 +568,38 @@ static DWORD widOpen(LPDWORD lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
for (i = ndlo; i < ndhi; i++) { for (i = ndlo; i < ndhi; i++) {
if (waveInOpen(&wim->hInnerWave, i, lpDesc->lpFormat, (DWORD)widCallback, if (waveInOpen(&wim->hInnerWave, i, lpDesc->lpFormat, (DWORD)widCallback,
(DWORD)wim, (dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION) == MMSYSERR_NOERROR) { (DWORD)wim, (dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) {
wim->hAcmStream = 0; wim->hAcmStream = 0;
goto found; goto found;
} }
} }
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); \ if ((dwFlags & WAVE_FORMAT_DIRECT) == 0)
if (widOpenHelper(wim, i, lpDesc, &wfx, dwFlags) == MMSYSERR_NOERROR) goto found; {
WAVEFORMATEX wfx;
for (i = ndlo; i < ndhi; i++) { wfx.wFormatTag = WAVE_FORMAT_PCM;
/* first try with same stereo/mono option as source */ wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */
wfx.nChannels = lpDesc->lpFormat->nChannels; /* try some ACM stuff */
TRY(44100, 8);
TRY(22050, 8); #define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
TRY(11025, 8); if (widOpenHelper(wim, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) goto found;
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */ for (i = ndlo; i < ndhi; i++) {
wfx.nChannels ^= 3; /* first try with same stereo/mono option as source */
TRY(44100, 8); wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(22050, 8); TRY(44100, 8);
TRY(11025, 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(44100, 8);
TRY(22050, 8);
TRY(11025, 8);
}
#undef TRY #undef TRY
}
HeapFree(GetProcessHeap(), 0, wim); HeapFree(GetProcessHeap(), 0, wim);
return MMSYSERR_ALLOCATED; return MMSYSERR_ALLOCATED;
......
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