Commit a9a80b56 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

dsound: Stricter validation for formats in secondary buffers.

parent 80428310
...@@ -470,17 +470,32 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer( ...@@ -470,17 +470,32 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer(
} }
} else { } else {
IDirectSoundBufferImpl * dsb; IDirectSoundBufferImpl * dsb;
WAVEFORMATEXTENSIBLE *pwfxe;
if (dsbd->lpwfxFormat == NULL) { if (dsbd->lpwfxFormat == NULL) {
WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for " WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
"secondary buffer\n"); "secondary buffer\n");
return DSERR_INVALIDPARAM; return DSERR_INVALIDPARAM;
} }
pwfxe = (WAVEFORMATEXTENSIBLE*)dsbd->lpwfxFormat;
if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) if(dsbd->lpwfxFormat->wFormatTag != WAVE_FORMAT_PCM &&
dsbd->lpwfxFormat->wFormatTag != WAVE_FORMAT_IEEE_FLOAT &&
dsbd->lpwfxFormat->wFormatTag != WAVE_FORMAT_EXTENSIBLE) {
WARN("We can't mix this format: 0x%x\n", dsbd->lpwfxFormat->wFormatTag);
return E_NOTIMPL;
}
if(dsbd->lpwfxFormat->wBitsPerSample < 8 || dsbd->lpwfxFormat->wBitsPerSample % 8 != 0 ||
dsbd->lpwfxFormat->nChannels == 0 || dsbd->lpwfxFormat->nSamplesPerSec == 0 ||
dsbd->lpwfxFormat->nAvgBytesPerSec == 0 ||
dsbd->lpwfxFormat->nBlockAlign != dsbd->lpwfxFormat->nChannels * dsbd->lpwfxFormat->wBitsPerSample / 8) {
WARN("Format inconsistency\n");
return DSERR_INVALIDPARAM;
}
if (dsbd->lpwfxFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{ {
WAVEFORMATEXTENSIBLE *pwfxe = (WAVEFORMATEXTENSIBLE*)dsbd->lpwfxFormat;
/* check if cbSize is at least 22 bytes */ /* check if cbSize is at least 22 bytes */
if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))) if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
{ {
...@@ -510,8 +525,7 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer( ...@@ -510,8 +525,7 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer(
} }
if (pwfxe->Samples.wValidBitsPerSample && pwfxe->Samples.wValidBitsPerSample < dsbd->lpwfxFormat->wBitsPerSample) if (pwfxe->Samples.wValidBitsPerSample && pwfxe->Samples.wValidBitsPerSample < dsbd->lpwfxFormat->wBitsPerSample)
{ {
FIXME("Non-packed formats not supported right now: %d/%d\n", pwfxe->Samples.wValidBitsPerSample, dsbd->lpwfxFormat->wBitsPerSample); WARN("Non-packed formats may not function : %d/%d\n", pwfxe->Samples.wValidBitsPerSample, dsbd->lpwfxFormat->wBitsPerSample);
return DSERR_CONTROLUNAVAIL;
} }
} }
......
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