[PATCH] dsound: Add conformance tests for 24/32 bits buffers and waveformatextensible

Maarten Lankhorst maarten at codeweavers.com
Sun Oct 14 11:23:22 CDT 2007


---
 dlls/dsound/tests/ds3d.c        |   41 ++++++++++++++++++--
 dlls/dsound/tests/ds3d8.c       |    9 ++++-
 dlls/dsound/tests/dsound.c      |   78 +++++++++++++++++++++++++++++++++++----
 dlls/dsound/tests/dsound8.c     |   78 ++++++++++++++++++++++++++++++++++----
 dlls/dsound/tests/dsound_test.h |   26 ++++++++++++-
 5 files changed, 209 insertions(+), 23 deletions(-)

diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c
index 4f8ec8f..bba6c36 100644
--- a/dlls/dsound/tests/ds3d.c
+++ b/dlls/dsound/tests/ds3d.c
@@ -30,7 +30,7 @@
 #include "wine/test.h"
 #include "dsound.h"
 #include "dxerr8.h"
-
+#include "mmreg.h"
 #include "dsound_test.h"
 
 #define PI 3.14159265358979323846
@@ -57,7 +57,7 @@ char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
             *b++=sample;
             if (wfx->nChannels==2)
                 *b++=sample;
-        } else {
+        } else if (wfx->wBitsPerSample == 16) {
             signed short sample=(signed short)((double)32767.5*y-0.5);
             b[0]=sample & 0xff;
             b[1]=sample >> 8;
@@ -67,6 +67,32 @@ char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
                 b[1]=sample >> 8;
                 b+=2;
             }
+        } else if (wfx->wBitsPerSample == 24) {
+            signed int sample=(signed int)((double)8388607.5*y-0.5);
+            b[0]=sample & 0xff;
+            b[1]=(sample >> 8)&0xff;
+            b[2]=sample >> 16;
+            b+=3;
+            if (wfx->nChannels==2) {
+                b[0]=sample & 0xff;
+                b[1]=(sample >> 8)&0xff;
+                b[2]=sample >> 16;
+                b+=3;
+            }
+        } else if (wfx->wBitsPerSample == 32) {
+            signed int sample=(signed int)((double)2147483647.5*y-0.5);
+            b[0]=sample & 0xff;
+            b[1]=(sample >> 8)&0xff;
+            b[2]=(sample >> 16)&0xff;
+            b[3]=sample >> 24;
+            b+=4;
+            if (wfx->nChannels==2) {
+                b[0]=sample & 0xff;
+                b[1]=(sample >> 8)&0xff;
+                b[2]=(sample >> 16)&0xff;
+                b[3]=sample >> 24;
+                b+=4;
+            }
         }
     }
     return buf;
@@ -330,8 +356,15 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER *dsbo,
        "returned the needed size: rc=%s size=%d\n",DXGetErrorString8(rc),size);
 
     rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
-    ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
-       DXGetErrorString8(rc));
+    if (wfx.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+    {
+        WAVEFORMATEXTENSIBLE wfxe;
+        ok(rc == DSERR_INVALIDPARAM, "IDirectSoundBuffer_GetFormat returned: %s\n", DXGetErrorString8(rc));
+        rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,sizeof(wfxe),NULL);
+        wfx = wfxe.Format;
+    }
+    ok(rc==DS_OK,
+        "IDirectSoundBuffer_GetFormat() failed: %s\n", DXGetErrorString8(rc));
     if (rc==DS_OK && winetest_debug > 1) {
         trace("    Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
               is_primary ? "Primary" : "Secondary",
diff --git a/dlls/dsound/tests/ds3d8.c b/dlls/dsound/tests/ds3d8.c
index cddcf70..359eafd 100644
--- a/dlls/dsound/tests/ds3d8.c
+++ b/dlls/dsound/tests/ds3d8.c
@@ -30,7 +30,7 @@
 #include "wine/test.h"
 #include "dsound.h"
 #include "dxerr8.h"
-
+#include "mmreg.h"
 #include "dsound_test.h"
 
 static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
@@ -218,6 +218,13 @@ void test_buffer8(LPDIRECTSOUND8 dso, LPDIRECTSOUNDBUFFER * dsbo,
        "returned the needed size: rc=%s size=%d\n",DXGetErrorString8(rc),size);
 
     rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
+    if (wfx.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+    {
+        WAVEFORMATEXTENSIBLE wfxe;
+        ok(rc == DSERR_INVALIDPARAM, "IDirectSoundBuffer_GetFormat returned: %s\n", DXGetErrorString8(rc));
+        rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,sizeof(wfxe),NULL);
+        wfx = wfxe.Format;
+    }
     ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
        DXGetErrorString8(rc));
     if (rc==DS_OK && winetest_debug > 1) {
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index fe22064..1146e5d 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -32,6 +32,11 @@
 #include "dsound.h"
 #include "dxerr8.h"
 #include "dsconf.h"
+#include "mmreg.h"
+/* MinGW doesn't have ksguid, needed for make crosstest to work. */
+#include "initguid.h"
+#include "ks.h"
+#include "ksmedia.h"
 
 #include "dsound_test.h"
 
@@ -694,6 +699,7 @@ static HRESULT test_secondary(LPGUID lpGuid)
             goto EXIT1;
 
         for (f=0;f<NB_FORMATS;f++) {
+            WAVEFORMATEXTENSIBLE wfxe;
             init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
                         formats[f][2]);
             secondary=NULL;
@@ -716,18 +722,74 @@ static HRESULT test_secondary(LPGUID lpGuid)
             bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                         wfx.nBlockAlign);
             bufdesc.lpwfxFormat=&wfx;
-            if (winetest_interactive) {
-                trace("  Testing a secondary buffer at %dx%dx%d "
-                      "with a primary buffer at %dx%dx%d\n",
-                      wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
-                      wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
-            }
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16)
+                ok(rc == DSERR_CONTROLUNAVAIL && !secondary, "IDirectSound_CreateSoundBuffer() "
+                    "should have returned DSERR_CONTROLUNAVAIL and NULL, returned: %s %p\n",
+                    DXGetErrorString8(rc), secondary);
+            else
+                ok(rc==DS_OK && secondary!=NULL,
+                    "IDirectSound_CreateSoundBuffer() failed to create a secondary "
+                    "buffer %s\n",DXGetErrorString8(rc));
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            secondary = NULL;
+
+            bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
+            wfxe.Format = wfx;
+            wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+            wfxe.Format.cbSize = 1;
+            wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
+            wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO);
+
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+
+            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;
+
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(DSERR_CONTROLUNAVAIL && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+
+            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
+            wfxe.SubFormat = GUID_NULL;
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+
+            ++wfxe.Samples.wValidBitsPerSample;
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            --wfxe.Samples.wValidBitsPerSample;
+
             rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
             ok(rc==DS_OK && secondary!=NULL,
-               "IDirectSound_CreateSoundBuffer() failed to create a secondary "
-               "buffer %s\n",DXGetErrorString8(rc));
+                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
+                "buffer %s\n",DXGetErrorString8(rc));
 
             if (rc==DS_OK && secondary!=NULL) {
+                if (winetest_interactive) {
+                    trace("  Testing a secondary buffer at %dx%dx%d "
+                        "with a primary buffer at %dx%dx%d\n",
+                        wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+                        wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
+                }
                 test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
                             winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
 
diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c
index 3a0063f..a535665 100644
--- a/dlls/dsound/tests/dsound8.c
+++ b/dlls/dsound/tests/dsound8.c
@@ -32,6 +32,9 @@
 #include "dsound.h"
 #include "dxerr8.h"
 #include "dsconf.h"
+#include "mmreg.h"
+#include "ks.h"
+#include "ksmedia.h"
 
 #include "dsound_test.h"
 
@@ -727,6 +730,7 @@ static HRESULT test_secondary8(LPGUID lpGuid)
             goto EXIT1;
 
         for (f=0;f<NB_FORMATS;f++) {
+            WAVEFORMATEXTENSIBLE wfxe;
             init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
                         formats[f][2]);
             secondary=NULL;
@@ -749,18 +753,74 @@ static HRESULT test_secondary8(LPGUID lpGuid)
             bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                         wfx.nBlockAlign);
             bufdesc.lpwfxFormat=&wfx;
-            if (winetest_interactive) {
-                trace("  Testing a secondary buffer at %dx%dx%d "
-                      "with a primary buffer at %dx%dx%d\n",
-                      wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
-                      wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
-            }
-            rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16)
+                ok(rc == DSERR_CONTROLUNAVAIL && !secondary, "IDirectSound_CreateSoundBuffer() "
+                    "should have returned DSERR_CONTROLUNAVAIL and NULL, returned: %s %p\n",
+                    DXGetErrorString8(rc), secondary);
+            else
+                ok(rc==DS_OK && secondary!=NULL,
+                    "IDirectSound_CreateSoundBuffer() failed to create a secondary "
+                    "buffer %s\n",DXGetErrorString8(rc));
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            secondary = NULL;
+
+            bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
+            wfxe.Format = wfx;
+            wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+            wfxe.Format.cbSize = 1;
+            wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
+            wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO);
+
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+
+            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;
+
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(DSERR_CONTROLUNAVAIL && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+
+            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
+            wfxe.SubFormat = GUID_NULL;
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+
+            ++wfxe.Samples.wValidBitsPerSample;
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
+            ok(rc==DSERR_INVALIDPARAM && !secondary,
+                "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
+                DXGetErrorString8(rc), secondary);
+            if (secondary)
+                IDirectSoundBuffer_Release(secondary);
+            --wfxe.Samples.wValidBitsPerSample;
+
+            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
             ok(rc==DS_OK && secondary!=NULL,
-               "IDirectSound8_CreateSoundBuffer() failed to create a secondary "
-               "buffer: %s\n",DXGetErrorString8(rc));
+                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
+                "buffer %s\n",DXGetErrorString8(rc));
 
             if (rc==DS_OK && secondary!=NULL) {
+                if (winetest_interactive) {
+                    trace("  Testing a secondary buffer at %dx%dx%d "
+                        "with a primary buffer at %dx%dx%d\n",
+                        wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+                        wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
+                }
                 test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
                              winetest_interactive,1.0,0,NULL,0,0);
 
diff --git a/dlls/dsound/tests/dsound_test.h b/dlls/dsound/tests/dsound_test.h
index 2a948ee..23ca169 100644
--- a/dlls/dsound/tests/dsound_test.h
+++ b/dlls/dsound/tests/dsound_test.h
@@ -23,26 +23,50 @@ static const unsigned int formats[][4]={
     { 8000,  8, 2, 0 },
     { 8000, 16, 1, 0 },
     { 8000, 16, 2, 0 },
+    { 8000, 24, 1, 0 },
+    { 8000, 24, 2, 0 },
+    { 8000, 32, 1, 0 },
+    { 8000, 32, 2, 0 },
     {11025,  8, 1, WAVE_FORMAT_1M08 },
     {11025,  8, 2, WAVE_FORMAT_1S08 },
     {11025, 16, 1, WAVE_FORMAT_1M16 },
     {11025, 16, 2, WAVE_FORMAT_1S16 },
+    {11025, 24, 1, 0 },
+    {11025, 24, 2, 0 },
+    {11025, 32, 1, 0 },
+    {11025, 32, 2, 0 },
     {22050,  8, 1, WAVE_FORMAT_2M08 },
     {22050,  8, 2, WAVE_FORMAT_2S08 },
     {22050, 16, 1, WAVE_FORMAT_2M16 },
     {22050, 16, 2, WAVE_FORMAT_2S16 },
+    {22050, 24, 1, 0 },
+    {22050, 24, 2, 0 },
+    {22050, 32, 1, 0 },
+    {22050, 32, 2, 0 },
     {44100,  8, 1, WAVE_FORMAT_4M08 },
     {44100,  8, 2, WAVE_FORMAT_4S08 },
     {44100, 16, 1, WAVE_FORMAT_4M16 },
     {44100, 16, 2, WAVE_FORMAT_4S16 },
+    {44100, 24, 1, 0 },
+    {44100, 24, 2, 0 },
+    {44100, 32, 1, 0 },
+    {44100, 32, 2, 0 },
     {48000,  8, 1, WAVE_FORMAT_48M08 },
     {48000,  8, 2, WAVE_FORMAT_48S08 },
     {48000, 16, 1, WAVE_FORMAT_48M16 },
     {48000, 16, 2, WAVE_FORMAT_48S16 },
+    {48000, 24, 1, 0 },
+    {48000, 24, 2, 0 },
+    {48000, 32, 1, 0 },
+    {48000, 32, 2, 0 },
     {96000,  8, 1, WAVE_FORMAT_96M08 },
     {96000,  8, 2, WAVE_FORMAT_96S08 },
     {96000, 16, 1, WAVE_FORMAT_96M16 },
-    {96000, 16, 2, WAVE_FORMAT_96S16 }
+    {96000, 16, 2, WAVE_FORMAT_96S16 },
+    {96000, 24, 1, 0 },
+    {96000, 24, 2, 0 },
+    {96000, 32, 1, 0 },
+    {96000, 32, 2, 0 }
 };
 #define NB_FORMATS (sizeof(formats)/sizeof(*formats))
 
-- 
1.5.2.5


--------------000907060502030003050404--



More information about the wine-patches mailing list