From 7c89759e887d7be73b7e92220fbb656685d9df93 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Wed, 8 Sep 2004 19:08:14 +0000 Subject: [PATCH] Make the dsound tests run with DirectX < 8. --- dlls/dsound/tests/capture.c | 23 ++++++++++++++++++++--- dlls/dsound/tests/ds3d8.c | 15 ++++++++------- dlls/dsound/tests/dsound8.c | 33 +++++++++++++++++---------------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/dlls/dsound/tests/capture.c b/dlls/dsound/tests/capture.c index b8609c08c3d..3fba339724a 100644 --- a/dlls/dsound/tests/capture.c +++ b/dlls/dsound/tests/capture.c @@ -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 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, /* 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 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, "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 @@ EXIT: 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(); } diff --git a/dlls/dsound/tests/ds3d8.c b/dlls/dsound/tests/ds3d8.c index f6bf16b02e2..7977a782d9e 100644 --- a/dlls/dsound/tests/ds3d8.c +++ b/dlls/dsound/tests/ds3d8.c @@ -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 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play, 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 @@ static HRESULT test_primary8(LPGUID lpGuid) 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 @@ static HRESULT test_primary_3d8(LPGUID lpGuid) 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 @@ static HRESULT test_primary_3d_with_listener8(LPGUID lpGuid) 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 @@ static void ds3d8_tests() START_TEST(ds3d8) { HMODULE hDsound; - FARPROC pFunc; CoInitialize(NULL); @@ -1087,8 +1088,8 @@ START_TEST(ds3d8) return; } - pFunc = (void*)GetProcAddress(hDsound, "DirectSoundCreate8"); - if (!pFunc) { + pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8"); + if (!pDirectSoundCreate8) { trace("ds3d8 test skipped\n"); return; } diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c index 542872df1e1..d0b5c5e76b3 100644 --- a/dlls/dsound/tests/dsound8.c +++ b/dlls/dsound/tests/dsound8.c @@ -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 @@ static void IDirectSound8_tests() "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 @@ static HRESULT test_dsound8(LPGUID lpGuid) 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 @@ static HRESULT test_dsound8(LPGUID lpGuid) 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 @@ static HRESULT test_dsound8(LPGUID lpGuid) 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 @@ static HRESULT test_primary8(LPGUID lpGuid) 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 @@ static HRESULT test_primary_secondary8(LPGUID lpGuid) 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 @@ static HRESULT test_secondary8(LPGUID lpGuid) 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 @@ static void dsound8_tests() START_TEST(dsound8) { HMODULE hDsound; - FARPROC pFunc; CoInitialize(NULL); @@ -761,8 +762,8 @@ START_TEST(dsound8) return; } - pFunc = (void*)GetProcAddress(hDsound, "DirectSoundCreate8"); - if (!pFunc) { + pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8"); + if (!pDirectSoundCreate8) { trace("dsound8 test skipped\n"); return; } -- 2.11.4.GIT