Make the dsound tests run with DirectX < 8

Francois Gouget fgouget at codeweavers.com
Wed Sep 8 06:44:19 CDT 2004


Using GetProcAddress("DirectSoundCreate8") while still making direct 
calls to it is not very useful. Now we use proper function pointers.
Also, the dsound dll on my machine does not have any of the capture 
APIs. So I used function pointers there too.

Now the DirectSound tests start ok with DirectSound < 8... but then fail 
badly. But that may be partly caused by VMWare. Finally, note that 
DirectX >= 8 is still needed to compile it (but that's not a problem).


Changelog:
  * dlls/dsound/tests/capture.c
    dlls/dsound/tests/ds3d8.c
    dlls/dsound/tests/dsound8.c

    Francois Gouget <fgouget at codeweavers.com>
    Make the dsound tests run with DirectX < 8.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/dsound/tests/capture.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/capture.c,v
retrieving revision 1.9
diff -u -r1.9 capture.c
--- dlls/dsound/tests/capture.c	23 Aug 2004 17:50:31 -0000	1.9
+++ dlls/dsound/tests/capture.c	8 Sep 2004 10:49:08 -0000
@@ -38,6 +38,8 @@
 
 #define NOTIFICATIONS    5
 
+static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
+static HRESULT (WINAPI *pDirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
 
 static const char * get_format_str(WORD format)
 {
@@ -307,7 +309,7 @@
 
     /* Private dsound.dll: Error: Invalid interface buffer */
     trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
-    rc=DirectSoundCaptureCreate(lpGuid,NULL,NULL);
+    rc=pDirectSoundCaptureCreate(lpGuid,NULL,NULL);
     ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate() should have "
        "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
     if (rc==DS_OK) {
@@ -316,7 +318,7 @@
            "have 0\n",ref);
     }
 
-    rc=DirectSoundCaptureCreate(lpGuid,&dsco,NULL);
+    rc=pDirectSoundCaptureCreate(lpGuid,&dsco,NULL);
     ok((rc==DS_OK)||(rc==DSERR_NODRIVER),"DirectSoundCaptureCreate() failed: "
        "%s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
@@ -492,12 +494,27 @@
 static void capture_tests()
 {
     HRESULT rc;
-    rc=DirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
+    rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
     ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %s\n",
        DXGetErrorString8(rc));
 }
 
 START_TEST(capture)
 {
+    HMODULE hDsound;
+
+    hDsound = LoadLibraryA("dsound.dll");
+    if (!hDsound) {
+        trace("dsound.dll not found\n");
+        return;
+    }
+    pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
+    pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,"DirectSoundCaptureEnumerateA");
+    if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA)
+    {
+        trace("capture test skipped\n");
+        return;
+    }
+
     capture_tests();
 }
Index: dlls/dsound/tests/ds3d8.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/ds3d8.c,v
retrieving revision 1.6
diff -u -r1.6 ds3d8.c
--- dlls/dsound/tests/ds3d8.c	25 Aug 2004 02:09:00 -0000	1.6
+++ dlls/dsound/tests/ds3d8.c	8 Sep 2004 10:49:08 -0000
@@ -38,6 +38,8 @@
 
 #include "dsound_test.h"
 
+static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
+
 typedef struct {
     char* wave;
     DWORD wave_len;
@@ -535,7 +537,7 @@
     int ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -788,7 +790,7 @@
     int ref, i;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -870,7 +872,7 @@
     int ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -943,7 +945,7 @@
     int ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -1077,7 +1079,6 @@
 START_TEST(ds3d8)
 {
     HMODULE hDsound;
-    FARPROC pFunc;
 
     CoInitialize(NULL);
 
@@ -1087,8 +1088,8 @@
         return;
     }
 
-    pFunc = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
-    if (!pFunc) {
+    pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
+    if (!pDirectSoundCreate8) {
         trace("ds3d8 test skipped\n");
         return;
     }
Index: dlls/dsound/tests/dsound8.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/dsound8.c,v
retrieving revision 1.6
diff -u -r1.6 dsound8.c
--- dlls/dsound/tests/dsound8.c	25 Aug 2004 02:09:00 -0000	1.6
+++ dlls/dsound/tests/dsound8.c	8 Sep 2004 10:49:08 -0000
@@ -41,6 +41,8 @@
 
 #include "dsound_test.h"
 
+static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
+
 static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized,
                                LPCGUID lpGuid)
 {
@@ -217,25 +219,25 @@
        "should have failed: %s\n",DXGetErrorString8(rc));
 
     /* try with no device specified */
-    rc=DirectSoundCreate8(NULL,&dso,NULL);
+    rc=pDirectSoundCreate8(NULL,&dso,NULL);
     ok(rc==S_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (dso)
         IDirectSound8_test(dso, TRUE, NULL);
 
     /* try with default playback device specified */
-    rc=DirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
     ok(rc==S_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (dso)
         IDirectSound8_test(dso, TRUE, NULL);
 
     /* try with default voice playback device specified */
-    rc=DirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
     ok(rc==S_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (dso)
         IDirectSound8_test(dso, TRUE, NULL);
 
     /* try with a bad device specified */
-    rc=DirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
     ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
        "should have failed: %s\n",DXGetErrorString8(rc));
 }
@@ -247,12 +249,12 @@
     int ref;
 
     /* DSOUND: Error: Invalid interface buffer */
-    rc=DirectSoundCreate8(lpGuid,0,NULL);
+    rc=pDirectSoundCreate8(lpGuid,0,NULL);
     ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8() should have returned "
        "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
 
     /* Create the DirectSound8 object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -269,13 +271,13 @@
         IDirectSound8_test(dso, FALSE, lpGuid);
 
     /* Create a DirectSound8 object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
-    ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
+    ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc==DS_OK) {
         LPDIRECTSOUND8 dso1=NULL;
 
         /* Create a second DirectSound8 object */
-        rc=DirectSoundCreate8(lpGuid,&dso1,NULL);
+        rc=pDirectSoundCreate8(lpGuid,&dso1,NULL);
         ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
         if (rc==DS_OK) {
             /* Release the second DirectSound8 object */
@@ -296,7 +298,7 @@
         return rc;
 
     /* Create a DirectSound8 object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc==DS_OK) {
         LPDIRECTSOUNDBUFFER secondary;
@@ -362,7 +364,7 @@
     int ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -503,7 +505,7 @@
     int f,ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -639,7 +641,7 @@
     int ref;
 
     /* Create the DirectSound object */
-    rc=DirectSoundCreate8(lpGuid,&dso,NULL);
+    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
     ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
     if (rc!=DS_OK)
         return rc;
@@ -751,7 +753,6 @@
 START_TEST(dsound8)
 {
     HMODULE hDsound;
-    FARPROC pFunc;
 
     CoInitialize(NULL);
 
@@ -761,8 +762,8 @@
         return;
     }
 
-    pFunc = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
-    if (!pFunc) {
+    pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
+    if (!pDirectSoundCreate8) {
         trace("dsound8 test skipped\n");
         return;
     }


More information about the wine-patches mailing list