From: Giovanni Mascellani gmascellani@codeweavers.com
Initializing the audio client without AUTOCONVERTPCM is expected to fail when the requested sampling rate or channel count does not match the mixing format. Such behavior is not currently modeled on Wine, but it should be introduced, and since here we expect automatic format conversion to work we add the flag. Consequently we also remove the supported format detection logic. --- dlls/dsound/capture.c | 55 +++++++++++++------------------------------ 1 file changed, 17 insertions(+), 38 deletions(-)
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index e9012600cfa..c3f6902c15b 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -744,7 +744,8 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( }
err = IAudioClient_Initialize(device->client, - AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK, + AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST + | AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM, 200 * 100000, 0, device->pwfx, NULL); if(FAILED(err)){ WARN("Initialize failed: %08lx\n", err); @@ -965,43 +966,24 @@ static DWORD WINAPI DSOUND_capture_thread(void *user) return 0; }
-static struct _TestFormat { - DWORD flag; - DWORD rate; - DWORD depth; - WORD channels; -} formats_to_test[] = { - { WAVE_FORMAT_1M08, 11025, 8, 1 }, - { WAVE_FORMAT_1M16, 11025, 16, 1 }, - { WAVE_FORMAT_1S08, 11025, 8, 2 }, - { WAVE_FORMAT_1S16, 11025, 16, 2 }, - { WAVE_FORMAT_2M08, 22050, 8, 1 }, - { WAVE_FORMAT_2M16, 22050, 16, 1 }, - { WAVE_FORMAT_2S08, 22050, 8, 2 }, - { WAVE_FORMAT_2S16, 22050, 16, 2 }, - { WAVE_FORMAT_4M08, 44100, 8, 1 }, - { WAVE_FORMAT_4M16, 44100, 16, 1 }, - { WAVE_FORMAT_4S08, 44100, 8, 2 }, - { WAVE_FORMAT_4S16, 44100, 16, 2 }, - { WAVE_FORMAT_48M08, 48000, 8, 1 }, - { WAVE_FORMAT_48M16, 48000, 16, 1 }, - { WAVE_FORMAT_48S08, 48000, 8, 2 }, - { WAVE_FORMAT_48S16, 48000, 16, 2 }, - { WAVE_FORMAT_96M08, 96000, 8, 1 }, - { WAVE_FORMAT_96M16, 96000, 16, 1 }, - { WAVE_FORMAT_96S08, 96000, 8, 2 }, - { WAVE_FORMAT_96S16, 96000, 16, 2 }, - {0} -}; - static HRESULT DirectSoundCaptureDevice_Initialize( DirectSoundCaptureDevice ** ppDevice, LPCGUID lpcGUID) { + static const DWORD all_formats = + WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | + WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16 | + WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | + WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 | + WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | + WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 | + WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | + WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 | + WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | + WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16; HRESULT hr; GUID devGUID; IMMDevice *mmdevice; - struct _TestFormat *fmt; DirectSoundCaptureDevice *device; IAudioClient *client;
@@ -1047,13 +1029,10 @@ static HRESULT DirectSoundCaptureDevice_Initialize( return DSERR_NODRIVER; }
- for(fmt = formats_to_test; fmt->flag; ++fmt){ - if(DSOUND_check_supported(client, fmt->rate, fmt->depth, fmt->channels)){ - device->drvcaps.dwFormats |= fmt->flag; - if(fmt->channels > device->drvcaps.dwChannels) - device->drvcaps.dwChannels = fmt->channels; - } - } + /* We use AUTOCONVERTPCM, so all formats are supported. */ + device->drvcaps.dwFormats = all_formats; + device->drvcaps.dwChannels = 2; + IAudioClient_Release(client);
*ppDevice = device;