Commit b7f6c1e1 authored by Jesse Allen's avatar Jesse Allen Committed by Alexandre Julliard

dsound: Allow a special cbSize case in CreateSoundBuffer.

parent 410c00fa
......@@ -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;
......
......@@ -780,8 +780,42 @@ static HRESULT test_secondary8(LPGUID lpGuid)
IDirectSoundBuffer_Release(secondary);
secondary=NULL;
}
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,
......
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