Always open the device in the default 22050x8x2 format, and let it

report the actual device format to us.
This commit is contained in:
Francois Gouget 2003-01-07 19:43:18 +00:00 committed by Alexandre Julliard
parent 772cabeba9
commit 112cf22a12
1 changed files with 10 additions and 21 deletions

View File

@ -571,7 +571,6 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
{ {
IDirectSoundImpl** ippDS=(IDirectSoundImpl**)ppDS; IDirectSoundImpl** ippDS=(IDirectSoundImpl**)ppDS;
PIDSDRIVER drv = NULL; PIDSDRIVER drv = NULL;
WAVEOUTCAPSA wcaps;
unsigned wod, wodn; unsigned wod, wodn;
HRESULT err = DS_OK; HRESULT err = DS_OK;
@ -599,8 +598,6 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
/* FIXME: How do we find the GUID of an audio device? */ /* FIXME: How do we find the GUID of an audio device? */
wod = 0; /* start at the first audio device */ wod = 0; /* start at the first audio device */
/* Get output device caps */
waveOutGetDevCapsA(wod, &wcaps, sizeof(wcaps));
/* DRV_QUERYDSOUNDIFACE is a "Wine extension" to get the DSound interface */ /* DRV_QUERYDSOUNDIFACE is a "Wine extension" to get the DSound interface */
waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0); waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0);
@ -638,23 +635,15 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
/* Set default wave format (may need it for waveOutOpen) */ /* Set default wave format (may need it for waveOutOpen) */
(*ippDS)->wfx.wFormatTag = WAVE_FORMAT_PCM; (*ippDS)->wfx.wFormatTag = WAVE_FORMAT_PCM;
/* default to stereo, if the sound card can do it */ /* We rely on the sound driver to return the actual sound format of
if (wcaps.wChannels > 1) * the device if it does not support 22050x8x2 and is given the
(*ippDS)->wfx.nChannels = 2; * WAVE_DIRECTSOUND flag.
else */
(*ippDS)->wfx.nChannels = 1; (*ippDS)->wfx.nSamplesPerSec = 22050;
/* default to 8, if the sound card can do it */ (*ippDS)->wfx.wBitsPerSample = 8;
if (wcaps.dwFormats & (WAVE_FORMAT_4M08 | WAVE_FORMAT_2M08 | WAVE_FORMAT_1M08 | (*ippDS)->wfx.nChannels = 2;
WAVE_FORMAT_4S08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_1S08)) { (*ippDS)->wfx.nBlockAlign = (*ippDS)->wfx.wBitsPerSample * (*ippDS)->wfx.nChannels / 8;
(*ippDS)->wfx.wBitsPerSample = 8; (*ippDS)->wfx.nAvgBytesPerSec = (*ippDS)->wfx.nSamplesPerSec * (*ippDS)->wfx.nBlockAlign;
(*ippDS)->wfx.nBlockAlign = 1 * (*ippDS)->wfx.nChannels;
} else {
/* it's probably a 16-bit-only card */
(*ippDS)->wfx.wBitsPerSample = 16;
(*ippDS)->wfx.nBlockAlign = 2 * (*ippDS)->wfx.nChannels;
}
(*ippDS)->wfx.nSamplesPerSec = 22050;
(*ippDS)->wfx.nAvgBytesPerSec = 22050 * (*ippDS)->wfx.nBlockAlign;
/* If the driver requests being opened through MMSYSTEM /* If the driver requests being opened through MMSYSTEM
* (which is recommended by the DDK), it is supposed to happen * (which is recommended by the DDK), it is supposed to happen
@ -695,7 +684,7 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
} else { } else {
unsigned c; unsigned c;
/* FIXME: look at wcaps */ /* FIXME: We should check the device capabilities */
(*ippDS)->drvcaps.dwFlags = (*ippDS)->drvcaps.dwFlags =
DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO; DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO;
if (ds_emuldriver) if (ds_emuldriver)