dsound: Allow a special cbSize case in CreateSoundBuffer.

This commit is contained in:
Jesse Allen 2009-04-20 21:41:21 -07:00 committed by Alexandre Julliard
parent 410c00fae4
commit b7f6c1e103
2 changed files with 40 additions and 2 deletions

View File

@ -1586,13 +1586,17 @@ HRESULT DirectSoundDevice_CreateSoundBuffer(
} }
if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{ {
/* check if cbSize is at least 22 bytes */
if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))) if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
{ {
WARN("Too small a cbSize %u\n", pwfxe->Format.cbSize); WARN("Too small a cbSize %u\n", pwfxe->Format.cbSize);
return DSERR_INVALIDPARAM; 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); WARN("Too big a cbSize %u\n", pwfxe->Format.cbSize);
return DSERR_CONTROLUNAVAIL; return DSERR_CONTROLUNAVAIL;

View File

@ -780,8 +780,42 @@ static HRESULT test_secondary8(LPGUID lpGuid)
IDirectSoundBuffer_Release(secondary); IDirectSoundBuffer_Release(secondary);
secondary=NULL; 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; ++wfxe.Samples.wValidBitsPerSample;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM && !secondary, ok(rc==DSERR_INVALIDPARAM && !secondary,