Maarten Lankhorst : dsound: Add support for WAVEFORMATEXTENSIBLE format.

Alexandre Julliard julliard at winehq.org
Wed Nov 7 06:45:52 CST 2007


Module: wine
Branch: master
Commit: 2a117a20176815b3b8e52c0e4b56a40c4e41e74d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2a117a20176815b3b8e52c0e4b56a40c4e41e74d

Author: Maarten Lankhorst <maarten at codeweavers.com>
Date:   Mon Nov  5 23:23:11 2007 +0100

dsound: Add support for WAVEFORMATEXTENSIBLE format.

---

 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 ed6c221..457ced1 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"
@@ -1522,6 +1526,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);
@@ -1558,12 +1563,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 && pwfxe->Samples.wValidBitsPerSample < dsbd->lpwfxFormat->wBitsPerSample)
+            {
+                FIXME("Non-packed formats not supported right now: %d/%d\n", pwfxe->Samples.wValidBitsPerSample, dsbd->lpwfxFormat->wBitsPerSample);
+                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 791b33c..53f27a7 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);




More information about the wine-cvs mailing list