From 112cf22a12ef3a3564551f8557e777264ccc1242 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Tue, 7 Jan 2003 19:43:18 +0000 Subject: [PATCH] Always open the device in the default 22050x8x2 format, and let it report the actual device format to us. --- dlls/dsound/dsound_main.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 5c7b11f6b52..8628d5254ed 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -571,7 +571,6 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown * { IDirectSoundImpl** ippDS=(IDirectSoundImpl**)ppDS; PIDSDRIVER drv = NULL; - WAVEOUTCAPSA wcaps; unsigned wod, wodn; 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? */ 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 */ 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) */ (*ippDS)->wfx.wFormatTag = WAVE_FORMAT_PCM; - /* default to stereo, if the sound card can do it */ - if (wcaps.wChannels > 1) - (*ippDS)->wfx.nChannels = 2; - else - (*ippDS)->wfx.nChannels = 1; - /* default to 8, if the sound card can do it */ - if (wcaps.dwFormats & (WAVE_FORMAT_4M08 | WAVE_FORMAT_2M08 | WAVE_FORMAT_1M08 | - WAVE_FORMAT_4S08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_1S08)) { - (*ippDS)->wfx.wBitsPerSample = 8; - (*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; + /* We rely on the sound driver to return the actual sound format of + * the device if it does not support 22050x8x2 and is given the + * WAVE_DIRECTSOUND flag. + */ + (*ippDS)->wfx.nSamplesPerSec = 22050; + (*ippDS)->wfx.wBitsPerSample = 8; + (*ippDS)->wfx.nChannels = 2; + (*ippDS)->wfx.nBlockAlign = (*ippDS)->wfx.wBitsPerSample * (*ippDS)->wfx.nChannels / 8; + (*ippDS)->wfx.nAvgBytesPerSec = (*ippDS)->wfx.nSamplesPerSec * (*ippDS)->wfx.nBlockAlign; /* If the driver requests being opened through MMSYSTEM * (which is recommended by the DDK), it is supposed to happen @@ -695,7 +684,7 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown * } else { unsigned c; - /* FIXME: look at wcaps */ + /* FIXME: We should check the device capabilities */ (*ippDS)->drvcaps.dwFlags = DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO; if (ds_emuldriver)