From b7f6c1e1031e34fefbf1ece44ac8a2f007acb31c Mon Sep 17 00:00:00 2001 From: Jesse Allen Date: Mon, 20 Apr 2009 21:41:21 -0700 Subject: [PATCH] dsound: Allow a special cbSize case in CreateSoundBuffer. --- dlls/dsound/dsound.c | 6 +++++- dlls/dsound/tests/dsound8.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index 70327740681..77a5928bd90 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -1586,13 +1586,17 @@ HRESULT DirectSoundDevice_CreateSoundBuffer( } if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) { + /* check if cbSize is at least 22 bytes */ if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))) { WARN("Too small a cbSize %u\n", pwfxe->Format.cbSize); return DSERR_INVALIDPARAM; } - if (pwfxe->Format.cbSize > (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))) + /* cbSize should be 22 bytes, with one possible exception */ + if (pwfxe->Format.cbSize > (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)) && + !(IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM) && + pwfxe->Format.cbSize == sizeof(WAVEFORMATEXTENSIBLE))) { WARN("Too big a cbSize %u\n", pwfxe->Format.cbSize); return DSERR_CONTROLUNAVAIL; diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c index c79a7ac0d94..88fc66648c6 100644 --- a/dlls/dsound/tests/dsound8.c +++ b/dlls/dsound/tests/dsound8.c @@ -780,8 +780,42 @@ static HRESULT test_secondary8(LPGUID lpGuid) IDirectSoundBuffer_Release(secondary); secondary=NULL; } - wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + wfxe.Format.cbSize = sizeof(wfxe); + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); + ok((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL) && !secondary, + "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", + rc, secondary); + if (secondary) + { + IDirectSoundBuffer_Release(secondary); + secondary=NULL; + } + + wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); + ok(rc==DS_OK && secondary, + "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", + rc, secondary); + if (secondary) + { + IDirectSoundBuffer_Release(secondary); + secondary=NULL; + } + + wfxe.Format.cbSize = sizeof(wfxe) + 1; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); + ok(((rc==DSERR_CONTROLUNAVAIL || DSERR_INVALIDCALL /* 2003 */) && !secondary) + || rc==DS_OK /* driver dependent? */, + "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", + rc, secondary); + if (secondary) + { + IDirectSoundBuffer_Release(secondary); + secondary=NULL; + } + + wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx); ++wfxe.Samples.wValidBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM && !secondary,