[PATCH] dsound: Add support for WAVEFORMATEXTENSIBLE format, which is needed for 24/32 bits buffers
Maarten Lankhorst
maarten at codeweavers.com
Sun Oct 14 11:22:36 CDT 2007
---
dlls/dsound/buffer.c | 3 ++-
dlls/dsound/dsound.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
dlls/dsound/dsound_main.c | 3 +++
3 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 5d95078..02b763e 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -495,8 +495,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetFormat(
*wfwritten = size;
} else {
WARN("invalid parameter: wfsize too small\n");
+ CopyMemory(lpwf,This->pwfx,wfsize);
if (wfwritten)
- *wfwritten = 0;
+ *wfwritten = wfsize;
return DSERR_INVALIDPARAM;
}
} else {
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index 8368457..094f8f1 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -31,6 +31,10 @@
#include "mmsystem.h"
#include "winternl.h"
#include "mmddk.h"
+#include "wingdi.h"
+#include "mmreg.h"
+#include "ks.h"
+#include "ksmedia.h"
#include "wine/debug.h"
#include "dsound.h"
#include "dsdriver.h"
@@ -1523,6 +1527,7 @@ HRESULT DirectSoundDevice_CreateSoundBuffer(
WARN("invalid parameter: ppdsb == NULL\n");
return DSERR_INVALIDPARAM;
}
+ *ppdsb = NULL;
if (TRACE_ON(dsound)) {
TRACE("(structsize=%d)\n",dsbd->dwSize);
@@ -1559,12 +1564,51 @@ HRESULT DirectSoundDevice_CreateSoundBuffer(
}
} else {
IDirectSoundBufferImpl * dsb;
+ WAVEFORMATEXTENSIBLE *pwfxe;
if (dsbd->lpwfxFormat == NULL) {
WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
"secondary buffer\n");
return DSERR_INVALIDPARAM;
}
+ pwfxe = (WAVEFORMATEXTENSIBLE*)dsbd->lpwfxFormat;
+
+ if (pwfxe->Format.wBitsPerSample != 16 && pwfxe->Format.wBitsPerSample != 8 && pwfxe->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE)
+ {
+ WARN("wBitsPerSample=%d needs a WAVEFORMATEXTENSIBLE\n", dsbd->lpwfxFormat->wBitsPerSample);
+ return DSERR_CONTROLUNAVAIL;
+ }
+ if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+ {
+ if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
+ {
+ WARN("Too small a cbSize (%d/%d)\n", pwfxe->Format.cbSize, (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)));
+ return DSERR_INVALIDPARAM;
+ }
+
+ if (pwfxe->Format.cbSize > (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
+ {
+ WARN("Too big a cbSize (%d/%d)\n", pwfxe->Format.cbSize, (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)));
+ return DSERR_CONTROLUNAVAIL;
+ }
+
+ if (!IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))
+ {
+ if (!IsEqualGUID(&pwfxe->SubFormat, &GUID_NULL))
+ FIXME("SubFormat %s not supported right now.\n", debugstr_guid(&pwfxe->SubFormat));
+ return DSERR_INVALIDPARAM;
+ }
+ if (pwfxe->Samples.wValidBitsPerSample > dsbd->lpwfxFormat->wBitsPerSample)
+ {
+ WARN("Samples.wValidBitsPerSample(%d) > Format.wBitsPerSample (%d)\n", pwfxe->Samples.wValidBitsPerSample, pwfxe->Format.wBitsPerSample);
+ return DSERR_INVALIDPARAM;
+ }
+ if (pwfxe->Samples.wValidBitsPerSample < dsbd->lpwfxFormat->wBitsPerSample)
+ {
+ FIXME("Non-packed formats not supported right now.\n");
+ return DSERR_CONTROLUNAVAIL;
+ }
+ }
TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
"bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 67ab2ef..1e0837b 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -48,8 +48,11 @@
#include "wine/debug.h"
#include "dsound.h"
#include "dsconf.h"
+#include "ks.h"
#include "initguid.h"
+#include "ksmedia.h"
#include "dsdriver.h"
+
#include "dsound_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
--
1.5.2.5
--------------030502080509080306090308--
More information about the wine-patches
mailing list