Declaration, implemention and test for BuildTrusteeWithSid.
[wine] / dlls / dsound / tests / ds3d8.c
1 /*
2  * Tests the panning and 3D functions of DirectSound
3  *
4  * Part of this test involves playing test tones. But this only makes
5  * sense if someone is going to carefully listen to it, and would only
6  * bother everyone else.
7  * So this is only done if the test is being run in interactive mode.
8  *
9  * Copyright (c) 2002-2004 Francois Gouget
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #define NONAMELESSSTRUCT
27 #define NONAMELESSUNION
28 #include <windows.h>
29
30 #include <math.h>
31 #include <stdlib.h>
32
33 #include "wine/test.h"
34 #include "windef.h"
35 #include "wingdi.h"
36 #include "dsound.h"
37 #include "dxerr8.h"
38
39 #include "dsound_test.h"
40
41 typedef struct {
42     char* wave;
43     DWORD wave_len;
44
45     LPDIRECTSOUNDBUFFER dsbo;
46     LPWAVEFORMATEX wfx;
47     DWORD buffer_size;
48     DWORD written;
49     DWORD played;
50     DWORD offset;
51 } play_state_t;
52
53 static int buffer_refill8(play_state_t* state, DWORD size)
54 {
55     LPVOID ptr1,ptr2;
56     DWORD len1,len2;
57     HRESULT rc;
58
59     if (size>state->wave_len-state->written)
60         size=state->wave_len-state->written;
61
62     rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
63                                &ptr1,&len1,&ptr2,&len2,0);
64     ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
65        DXGetErrorString8(rc));
66     if (rc!=DS_OK)
67         return -1;
68
69     memcpy(ptr1,state->wave+state->written,len1);
70     state->written+=len1;
71     if (ptr2!=NULL) {
72         memcpy(ptr2,state->wave+state->written,len2);
73         state->written+=len2;
74     }
75     state->offset=state->written % state->buffer_size;
76     rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
77     ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
78        DXGetErrorString8(rc));
79     if (rc!=DS_OK)
80         return -1;
81     return size;
82 }
83
84 static int buffer_silence8(play_state_t* state, DWORD size)
85 {
86     LPVOID ptr1,ptr2;
87     DWORD len1,len2;
88     HRESULT rc;
89     BYTE s;
90
91     rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
92                                &ptr1,&len1,&ptr2,&len2,0);
93     ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
94        DXGetErrorString8(rc));
95     if (rc!=DS_OK)
96         return -1;
97
98     s=(state->wfx->wBitsPerSample==8?0x80:0);
99     memset(ptr1,s,len1);
100     if (ptr2!=NULL) {
101         memset(ptr2,s,len2);
102     }
103     state->offset=(state->offset+size) % state->buffer_size;
104     rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
105     ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
106        DXGetErrorString8(rc));
107     if (rc!=DS_OK)
108         return -1;
109     return size;
110 }
111
112 static int buffer_service8(play_state_t* state)
113 {
114     DWORD last_play_pos,play_pos,buf_free;
115     HRESULT rc;
116
117     rc=IDirectSoundBuffer_GetCurrentPosition(state->dsbo,&play_pos,NULL);
118     ok(rc==DS_OK,"IDirectSoundBuffer_GetCurrentPosition() failed: %s\n",
119        DXGetErrorString8(rc));
120     if (rc!=DS_OK) {
121         goto STOP;
122     }
123
124     /* Update the amount played */
125     last_play_pos=state->played % state->buffer_size;
126     if (play_pos<last_play_pos)
127         state->played+=state->buffer_size-last_play_pos+play_pos;
128     else
129         state->played+=play_pos-last_play_pos;
130
131     if (winetest_debug > 1)
132         trace("buf size=%ld last_play_pos=%ld play_pos=%ld played=%ld / %ld\n",
133               state->buffer_size,last_play_pos,play_pos,state->played,
134               state->wave_len);
135
136     if (state->played>state->wave_len)
137     {
138         /* Everything has been played */
139         goto STOP;
140     }
141
142     /* Refill the buffer */
143     if (state->offset<=play_pos)
144         buf_free=play_pos-state->offset;
145     else
146         buf_free=state->buffer_size-state->offset+play_pos;
147
148     if (winetest_debug > 1)
149         trace("offset=%ld free=%ld written=%ld / %ld\n",
150               state->offset,buf_free,state->written,state->wave_len);
151     if (buf_free==0)
152         return 1;
153
154     if (state->written<state->wave_len)
155     {
156         int w=buffer_refill8(state,buf_free);
157         if (w==-1)
158             goto STOP;
159         buf_free-=w;
160         if (state->written==state->wave_len && winetest_debug > 1)
161             trace("last sound byte at %ld\n",
162                   (state->written % state->buffer_size));
163     }
164
165     if (buf_free>0) {
166         /* Fill with silence */
167         if (winetest_debug > 1)
168             trace("writing %ld bytes of silence\n",buf_free);
169         if (buffer_silence8(state,buf_free)==-1)
170             goto STOP;
171     }
172     return 1;
173
174 STOP:
175     if (winetest_debug > 1)
176         trace("stopping playback\n");
177     rc=IDirectSoundBuffer_Stop(state->dsbo);
178     ok(rc==DS_OK,"IDirectSoundBuffer_Stop() failed: %s\n",
179        DXGetErrorString8(rc));
180     return 0;
181 }
182
183 void test_buffer8(LPDIRECTSOUND8 dso, LPDIRECTSOUNDBUFFER dsbo,
184                   BOOL is_primary, BOOL set_volume, LONG volume,
185                   BOOL set_pan, LONG pan, BOOL play, double duration,
186                   BOOL buffer3d, LPDIRECTSOUND3DLISTENER listener,
187                   BOOL move_listener, BOOL move_sound)
188 {
189     HRESULT rc;
190     DSBCAPS dsbcaps;
191     WAVEFORMATEX wfx,wfx2;
192     DWORD size,status,freq;
193     int ref;
194
195     /* DSOUND: Error: Invalid caps pointer */
196     rc=IDirectSoundBuffer_GetCaps(dsbo,0);
197     ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
198
199     ZeroMemory(&dsbcaps, sizeof(dsbcaps));
200
201     /* DSOUND: Error: Invalid caps pointer */
202     rc=IDirectSoundBuffer_GetCaps(dsbo,&dsbcaps);
203     ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
204
205     dsbcaps.dwSize=sizeof(dsbcaps);
206     rc=IDirectSoundBuffer_GetCaps(dsbo,&dsbcaps);
207     ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
208     if (rc==DS_OK && winetest_interactive) {
209         trace("    Caps: flags=0x%08lx size=%ld\n",dsbcaps.dwFlags,
210               dsbcaps.dwBufferBytes);
211     }
212
213     /* Query the format size. Note that it may not match sizeof(wfx) */
214     size=0;
215     rc=IDirectSoundBuffer_GetFormat(dsbo,NULL,0,&size);
216     ok(rc==DS_OK && size!=0,
217        "GetFormat should have returned the needed size: rc=0x%lx size=%ld\n",
218        rc,size);
219
220     rc=IDirectSoundBuffer_GetFormat(dsbo,&wfx,sizeof(wfx),NULL);
221     ok(rc==DS_OK,"GetFormat failed: 0x%lx\n",rc);
222     if (rc==DS_OK && is_primary && winetest_interactive) {
223         trace("Primary buffer default format: tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
224               wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
225               wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
226     }
227
228     /* DSOUND: Error: Invalid frequency buffer */
229     rc=IDirectSoundBuffer_GetFrequency(dsbo,0);
230     ok(rc==DSERR_INVALIDPARAM,"GetFrequency should have failed: 0x%lx\n",rc);
231
232     /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
233     rc=IDirectSoundBuffer_GetFrequency(dsbo,&freq);
234     ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
235        (rc==DSERR_CONTROLUNAVAIL&&!(dsbcaps.dwFlags&DSBCAPS_CTRLFREQUENCY)),
236        "GetFrequency failed: 0x%lx\n",rc);
237     if (rc==DS_OK) {
238         ok(freq==wfx.nSamplesPerSec,
239            "The frequency returned by GetFrequency %ld does not match the format %ld\n",
240            freq,wfx.nSamplesPerSec);
241     }
242
243     /* DSOUND: Error: Invalid status pointer */
244     rc=IDirectSoundBuffer_GetStatus(dsbo,0);
245     ok(rc==DSERR_INVALIDPARAM,"GetStatus should have failed: 0x%lx\n",rc);
246
247     rc=IDirectSoundBuffer_GetStatus(dsbo,&status);
248     ok(rc==DS_OK,"GetStatus failed: 0x%lx\n",rc);
249     ok(status==0,"status=0x%lx instead of 0\n",status);
250
251     if (is_primary) {
252         /* We must call SetCooperativeLevel to be allowed to call SetFormat */
253         /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
254         rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
255         ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
256         if (rc!=DS_OK)
257             return;
258
259         /* DSOUND: Error: Invalid format pointer */
260         rc=IDirectSoundBuffer_SetFormat(dsbo,0);
261         ok(rc==DSERR_INVALIDPARAM,"SetFormat should have failed: 0x%lx\n",rc);
262
263         init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
264         rc=IDirectSoundBuffer_SetFormat(dsbo,&wfx2);
265         ok(rc==DS_OK,"SetFormat failed: 0x%lx\n",rc);
266
267         /* There is no garantee that SetFormat will actually change the
268          * format to what we asked for. It depends on what the soundcard
269          * supports. So we must re-query the format.
270          */
271         rc=IDirectSoundBuffer_GetFormat(dsbo,&wfx,sizeof(wfx),NULL);
272         ok(rc==DS_OK,"GetFormat failed: 0x%lx\n",rc);
273         if (rc==DS_OK &&
274             (wfx.wFormatTag!=wfx2.wFormatTag ||
275              wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
276              wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
277              wfx.nChannels!=wfx2.nChannels)) {
278             trace("Requested format tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
279                   wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
280                   wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
281             trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
282                   wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
283                   wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
284         }
285
286         /* Set the CooperativeLevel back to normal */
287         /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
288         rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
289         ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
290     }
291
292     if (play) {
293         play_state_t state;
294         DS3DLISTENER listener_param;
295         LPDIRECTSOUND3DBUFFER buffer=NULL;
296         DS3DBUFFER buffer_param;
297         DWORD start_time,now;
298
299         if (winetest_interactive) {
300             trace("    Playing %g second 440Hz tone at %ldx%dx%d\n", duration,
301                   wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
302         }
303
304         if (is_primary) {
305             /* We must call SetCooperativeLevel to be allowed to call Lock */
306             /* DSOUND: Setting DirectSound cooperative level to DSSCL_WRITEPRIMARY */
307             rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_WRITEPRIMARY);
308             ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
309             if (rc!=DS_OK)
310                 return;
311         }
312         if (buffer3d) {
313             LPDIRECTSOUNDBUFFER temp_buffer;
314
315             rc=IDirectSoundBuffer_QueryInterface(dsbo,&IID_IDirectSound3DBuffer,(LPVOID *)&buffer);
316             ok(rc==DS_OK,"QueryInterface failed: 0x%lx\n",rc);
317             if (rc!=DS_OK)
318                 return;
319
320             /* check the COM interface */
321             rc=IDirectSoundBuffer_QueryInterface(dsbo, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
322             ok(rc==DS_OK && temp_buffer!=NULL,"QueryInterface failed: 0x%lx\n",rc);
323             ok(temp_buffer==dsbo,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)dsbo);
324             ref=IDirectSoundBuffer_Release(temp_buffer);
325             ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref);
326
327             temp_buffer=NULL;
328             rc=IDirectSound3DBuffer_QueryInterface(dsbo, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
329             ok(rc==DS_OK && temp_buffer!=NULL,"IDirectSound3DBuffer_QueryInterface failed: 0x%lx\n",rc);
330             ok(temp_buffer==dsbo,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)dsbo);
331             ref=IDirectSoundBuffer_Release(temp_buffer);
332             ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref);
333
334 #if 0
335             /* FIXME: this works on windows */
336             ref=IDirectSoundBuffer_Release(dsbo);
337             ok(ref==0,"IDirectSoundBuffer_Release has %d references, should have 0\n",ref);
338
339             rc=IDirectSound3DBuffer_QueryInterface(buffer, &IID_IDirectSoundBuffer,(LPVOID *)&dsbo);
340             ok(rc==DS_OK && dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface failed: 0x%lx\n",rc);
341 #endif
342
343             /* DSOUND: Error: Invalid buffer */
344             rc=IDirectSound3DBuffer_GetAllParameters(buffer,0);
345             ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters failed: 0x%lx\n",rc);
346
347             ZeroMemory(&buffer_param, sizeof(buffer_param));
348
349             /* DSOUND: Error: Invalid buffer */
350             rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
351             ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters failed: 0x%lx\n",rc);
352
353             buffer_param.dwSize=sizeof(buffer_param);
354             rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
355             ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters failed: 0x%lx\n",rc);
356         }
357         if (set_volume) {
358             if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
359                 LONG val;
360                 rc=IDirectSoundBuffer_GetVolume(dsbo,&val);
361                 ok(rc==DS_OK,"GetVolume failed: 0x%lx\n",rc);
362
363                 rc=IDirectSoundBuffer_SetVolume(dsbo,volume);
364                 ok(rc==DS_OK,"SetVolume failed: 0x%lx\n",rc);
365             } else {
366                 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
367                 rc=IDirectSoundBuffer_GetVolume(dsbo,&volume);
368                 ok(rc==DSERR_CONTROLUNAVAIL,"GetVolume should have failed: 0x%lx\n",rc);
369             }
370         }
371
372         if (set_pan) {
373             if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
374                 LONG val;
375                 rc=IDirectSoundBuffer_GetPan(dsbo,&val);
376                 ok(rc==DS_OK,"GetPan failed: 0x%lx\n",rc);
377
378                 rc=IDirectSoundBuffer_SetPan(dsbo,pan);
379                 ok(rc==DS_OK,"SetPan failed: 0x%lx\n",rc);
380             } else {
381                 /* DSOUND: Error: Buffer does not have CTRLPAN */
382                 rc=IDirectSoundBuffer_GetPan(dsbo,&pan);
383                 ok(rc==DSERR_CONTROLUNAVAIL,"GetPan should have failed: 0x%lx\n",rc);
384             }
385         }
386
387         state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
388
389         state.dsbo=dsbo;
390         state.wfx=&wfx;
391         state.buffer_size=dsbcaps.dwBufferBytes;
392         state.played=state.written=state.offset=0;
393         buffer_refill8(&state,state.buffer_size);
394
395         rc=IDirectSoundBuffer_Play(dsbo,0,0,DSBPLAY_LOOPING);
396         ok(rc==DS_OK,"Play: 0x%lx\n",rc);
397
398         rc=IDirectSoundBuffer_GetStatus(dsbo,&status);
399         ok(rc==DS_OK,"GetStatus failed: 0x%lx\n",rc);
400         ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING),
401            "GetStatus: bad status: %lx\n",status);
402
403         if (listener) {
404             ZeroMemory(&listener_param,sizeof(listener_param));
405             listener_param.dwSize=sizeof(listener_param);
406             rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
407             ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters failed 0x%lx\n",rc);
408             if (move_listener)
409             {
410                 listener_param.vPosition.x = -5.0;
411                 listener_param.vVelocity.x = 10.0/duration;
412             }
413             rc=IDirectSound3DListener_SetAllParameters(listener,&listener_param,DS3D_IMMEDIATE);
414             ok(rc==DS_OK,"IDirectSound3dListener_SetPosition failed 0x%lx\n",rc);
415         }
416         if (buffer3d) {
417             if (move_sound)
418             {
419                 buffer_param.vPosition.x = 100.0;
420                 buffer_param.vVelocity.x = -200.0/duration;
421             }
422             buffer_param.flMinDistance = 10;
423             rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,DS3D_IMMEDIATE);
424             ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition failed 0x%lx\n",rc);
425         }
426
427         start_time=GetTickCount();
428         while (buffer_service8(&state)) {
429             WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
430             now=GetTickCount();
431             if (listener && move_listener) {
432                 listener_param.vPosition.x = -5.0+10.0*(now-start_time)/1000/duration;
433                 if (winetest_debug>2)
434                     trace("listener position=%g\n",listener_param.vPosition.x);
435                 rc=IDirectSound3DListener_SetPosition(listener,listener_param.vPosition.x,listener_param.vPosition.y,listener_param.vPosition.z,DS3D_IMMEDIATE);
436                 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition failed 0x%lx\n",rc);
437             }
438             if (buffer3d && move_sound) {
439                 buffer_param.vPosition.x = 100-200.0*(now-start_time)/1000/duration;
440                 if (winetest_debug>2)
441                     trace("sound position=%g\n",buffer_param.vPosition.x);
442                 rc=IDirectSound3DBuffer_SetPosition(buffer,buffer_param.vPosition.x,buffer_param.vPosition.y,buffer_param.vPosition.z,DS3D_IMMEDIATE);
443                 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition failed 0x%lx\n",rc);
444             }
445         }
446         /* Check the sound duration was within 10% of the expected value */
447         now=GetTickCount();
448         ok(fabs(1000*duration-now+start_time)<=100*duration,"The sound played for %ld ms instead of %g ms\n",now-start_time,1000*duration);
449
450         free(state.wave);
451         if (is_primary) {
452             /* Set the CooperativeLevel back to normal */
453             /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
454             rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
455             ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
456         }
457         if (buffer3d) {
458             ref=IDirectSound3DBuffer_Release(buffer);
459             ok(ref==0,"IDirectSound3DBuffer_Release has %d references, should have 0\n",ref);
460         }
461     }
462 }
463
464 static HRESULT test_secondary8(LPGUID lpGuid, int play,
465                               int has_3d, int has_3dbuffer,
466                               int has_listener, int has_duplicate,
467                               int move_listener, int move_sound)
468 {
469     HRESULT rc;
470     LPDIRECTSOUND8 dso=NULL;
471     LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
472     LPDIRECTSOUND3DLISTENER listener=NULL;
473     DSBUFFERDESC bufdesc;
474     WAVEFORMATEX wfx;
475     int ref;
476
477     /* Create the DirectSound object */
478     rc=DirectSoundCreate8(lpGuid,&dso,NULL);
479     ok(rc==DS_OK,"DirectSoundCreate8 failed: 0x%08lx\n",rc);
480     if (rc!=DS_OK)
481         return rc;
482
483     /* We must call SetCooperativeLevel before creating primary buffer */
484     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
485     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
486     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
487     if (rc!=DS_OK)
488         goto EXIT;
489
490     ZeroMemory(&bufdesc, sizeof(bufdesc));
491     bufdesc.dwSize=sizeof(bufdesc);
492     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
493     if (has_3d)
494         bufdesc.dwFlags|=DSBCAPS_CTRL3D;
495     else
496         bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
497     rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
498     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a %sprimary buffer 0x%lx\n",has_3d?"3D ":"", rc);
499
500     if (rc==DS_OK && primary!=NULL) {
501         if (has_listener) {
502             rc=IDirectSoundBuffer_QueryInterface(primary,&IID_IDirectSound3DListener,(void **)&listener);
503             ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface failed to get a 3D listener 0x%lx\n",rc);
504             ref=IDirectSoundBuffer_Release(primary);
505             ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
506             if (rc==DS_OK && listener!=NULL) {
507                 DS3DLISTENER listener_param;
508                 ZeroMemory(&listener_param,sizeof(listener_param));
509                 /* DSOUND: Error: Invalid buffer */
510                 rc=IDirectSound3DListener_GetAllParameters(listener,0);
511                 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3dListener_GetAllParameters failed 0x%lx\n",rc);
512
513                 /* DSOUND: Error: Invalid buffer */
514                 rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
515                 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3dListener_GetAllParameters failed 0x%lx\n",rc);
516
517                 listener_param.dwSize=sizeof(listener_param);
518                 rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
519                 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters failed 0x%lx\n",rc);
520             }
521             else
522                 goto EXIT;
523         }
524
525         init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
526         secondary=NULL;
527         ZeroMemory(&bufdesc, sizeof(bufdesc));
528         bufdesc.dwSize=sizeof(bufdesc);
529         bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
530         if (has_3d)
531             bufdesc.dwFlags|=DSBCAPS_CTRL3D;
532         else
533             bufdesc.dwFlags|=(DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
534         bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
535         bufdesc.lpwfxFormat=&wfx;
536         if (winetest_interactive) {
537             trace("  Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d\n",
538                   has_3dbuffer?"3D ":"",
539                   has_duplicate?"duplicated ":"",
540                   listener!=NULL||move_sound?"with ":"",
541                   move_listener?"moving ":"",
542                   listener!=NULL?"listener ":"",
543                   listener&&move_sound?"and moving sound ":move_sound?"moving sound ":"",
544                   wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
545         }
546         rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
547         ok(rc==DS_OK && secondary!=NULL,"CreateSoundBuffer failed to create a 3D secondary buffer 0x%lx\n",rc);
548         if (rc==DS_OK && secondary!=NULL) {
549             if (!has_3d)
550             {
551                 LONG refvol,refpan,vol,pan;
552
553                 /* Check the initial secondary buffer's volume and pan */
554                 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
555                 ok(rc==DS_OK,"GetVolume(secondary) failed: %s\n",DXGetErrorString8(rc));
556                 ok(vol==0,"wrong volume for a new secondary buffer: %ld\n",vol);
557                 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
558                 ok(rc==DS_OK,"GetPan(secondary) failed: %s\n",DXGetErrorString8(rc));
559                 ok(pan==0,"wrong pan for a new secondary buffer: %ld\n",pan);
560
561                 /* Check that changing the secondary buffer's volume and pan
562                  * does not impact the primary buffer's volume and pan
563                  */
564                 rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
565                 ok(rc==DS_OK,"GetVolume(primary) failed: %s\n",DXGetErrorString8(rc));
566                 rc=IDirectSoundBuffer_GetPan(primary,&refpan);
567                 ok(rc==DS_OK,"GetPan(primary) failed: %s\n",DXGetErrorString8(rc));
568
569                 rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
570                 ok(rc==DS_OK,"SetVolume(secondary) failed: %s\n",DXGetErrorString8(rc));
571                 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
572                 ok(rc==DS_OK,"SetVolume(secondary) failed: %s\n",DXGetErrorString8(rc));
573                 ok(vol==-1000,"secondary: wrong volume %ld instead of -1000\n",vol);
574                 rc=IDirectSoundBuffer_SetPan(secondary,-1000);
575                 ok(rc==DS_OK,"SetPan(secondary) failed: %s\n",DXGetErrorString8(rc));
576                 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
577                 ok(rc==DS_OK,"SetPan(secondary) failed: %s\n",DXGetErrorString8(rc));
578                 ok(vol==-1000,"secondary: wrong pan %ld instead of -1000\n",pan);
579
580                 rc=IDirectSoundBuffer_GetVolume(primary,&vol);
581                 ok(rc==DS_OK,"GetVolume(primary) failed: %s\n",DXGetErrorString8(rc));
582                 ok(vol==refvol,"The primary volume changed from %ld to %ld\n",refvol,vol);
583                 rc=IDirectSoundBuffer_GetPan(primary,&pan);
584                 ok(rc==DS_OK,"GetPan(primary) failed: %s\n",DXGetErrorString8(rc));
585                 ok(pan==refpan,"The primary pan changed from %ld to %ld\n",refpan,pan);
586
587                 rc=IDirectSoundBuffer_SetVolume(secondary,0);
588                 ok(rc==DS_OK,"SetVolume(secondary) failed: %s\n",DXGetErrorString8(rc));
589                 rc=IDirectSoundBuffer_SetPan(secondary,0);
590                 ok(rc==DS_OK,"SetPan(secondary) failed: %s\n",DXGetErrorString8(rc));
591             }
592             if (has_duplicate) {
593                 LPDIRECTSOUNDBUFFER duplicated=NULL;
594
595                 /* DSOUND: Error: Invalid source buffer */
596                 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,0);
597                 ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_DuplicateSoundBuffer should have failed 0x%lx\n",rc);
598
599                 /* DSOUND: Error: Invalid dest buffer */
600                 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,0);
601                 ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_DuplicateSoundBuffer should have failed 0x%lx\n",rc);
602
603                 /* DSOUND: Error: Invalid source buffer */
604                 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,&duplicated);
605                 ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_DuplicateSoundBuffer should have failed 0x%lx\n",rc);
606
607                 duplicated=NULL;
608                 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,&duplicated);
609                 ok(rc==DS_OK && duplicated!=NULL,"IDirectSound8_DuplicateSoundBuffer failed to duplicate a secondary buffer 0x%lx\n",rc);
610
611                 if (rc==DS_OK && duplicated!=NULL) {
612                     ref=IDirectSoundBuffer_Release(secondary);
613                     ok(ref==0,"IDirectSoundBuffer_Release secondary has %d references, should have 0\n",ref);
614                     secondary=duplicated;
615                 }
616             }
617
618             if (rc==DS_OK && secondary!=NULL) {
619                 double duration;
620                 duration=(move_listener || move_sound?4.0:1.0);
621                 test_buffer8(dso,secondary,0,FALSE,0,FALSE,0,winetest_interactive,duration,has_3dbuffer,listener,move_listener,move_sound);
622                 ref=IDirectSoundBuffer_Release(secondary);
623                 ok(ref==0,"IDirectSoundBuffer_Release %s has %d references, should have 0\n",has_duplicate?"duplicated":"secondary",ref);
624             }
625         }
626     }
627     if (has_listener) {
628         ref=IDirectSound3DListener_Release(listener);
629         ok(ref==0,"IDirectSound3dListener_Release listener has %d references, should have 0\n",ref);
630     } else {
631         ref=IDirectSoundBuffer_Release(primary);
632         ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
633     }
634
635     /* Set the CooperativeLevel back to normal */
636     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
637     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
638     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%0lx\n",rc);
639
640 EXIT:
641     ref=IDirectSound8_Release(dso);
642     ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
643     if (ref!=0)
644         return DSERR_GENERIC;
645
646     return rc;
647 }
648
649 static HRESULT test_primary8(LPGUID lpGuid)
650 {
651     HRESULT rc;
652     LPDIRECTSOUND8 dso=NULL;
653     LPDIRECTSOUNDBUFFER primary=NULL;
654     DSBUFFERDESC bufdesc;
655     DSCAPS dscaps;
656     int ref, i;
657
658     /* Create the DirectSound object */
659     rc=DirectSoundCreate8(lpGuid,&dso,NULL);
660     ok(rc==DS_OK,"DirectSoundCreate8 failed: 0x%lx\n",rc);
661     if (rc!=DS_OK)
662         return rc;
663
664     /* Get the device capabilities */
665     ZeroMemory(&dscaps, sizeof(dscaps));
666     dscaps.dwSize=sizeof(dscaps);
667     rc=IDirectSound8_GetCaps(dso,&dscaps);
668     ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
669     if (rc!=DS_OK)
670         goto EXIT;
671
672     /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
673     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
674     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
675     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\n",rc);
676     if (rc!=DS_OK)
677         goto EXIT;
678
679     /* Testing the primary buffer */
680     primary=NULL;
681     ZeroMemory(&bufdesc, sizeof(bufdesc));
682     bufdesc.dwSize=sizeof(bufdesc);
683     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN;
684     rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
685     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc);
686     if (rc==DS_OK && primary!=NULL) {
687         test_buffer8(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
688         if (winetest_interactive) {
689             LONG volume,pan;
690
691             volume = DSBVOLUME_MAX;
692             for (i = 0; i < 6; i++) {
693                 test_buffer8(dso,primary,1,TRUE,volume,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
694                 volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
695             }
696
697             pan = DSBPAN_LEFT;
698             for (i = 0; i < 7; i++) {
699                 test_buffer8(dso,primary,1,TRUE,0,TRUE,pan,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
700                 pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
701             }
702         }
703         ref=IDirectSoundBuffer_Release(primary);
704         ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
705     }
706
707     /* Set the CooperativeLevel back to normal */
708     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
709     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
710     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\n",rc);
711
712 EXIT:
713     ref=IDirectSound8_Release(dso);
714     ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
715     if (ref!=0)
716         return DSERR_GENERIC;
717
718     return rc;
719 }
720
721 static HRESULT test_primary_3d8(LPGUID lpGuid)
722 {
723     HRESULT rc;
724     LPDIRECTSOUND8 dso=NULL;
725     LPDIRECTSOUNDBUFFER primary=NULL;
726     DSBUFFERDESC bufdesc;
727     DSCAPS dscaps;
728     int ref;
729
730     /* Create the DirectSound object */
731     rc=DirectSoundCreate8(lpGuid,&dso,NULL);
732     ok(rc==DS_OK,"DirectSoundCreate8 failed: 0x%lx\n",rc);
733     if (rc!=DS_OK)
734         return rc;
735
736     /* Get the device capabilities */
737     ZeroMemory(&dscaps, sizeof(dscaps));
738     dscaps.dwSize=sizeof(dscaps);
739     rc=IDirectSound8_GetCaps(dso,&dscaps);
740     ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
741     if (rc!=DS_OK)
742         goto EXIT;
743
744     /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
745     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
746     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
747     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\n",rc);
748     if (rc!=DS_OK)
749         goto EXIT;
750
751     primary=NULL;
752     ZeroMemory(&bufdesc, sizeof(bufdesc));
753     bufdesc.dwSize=sizeof(bufdesc);
754     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
755     rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
756     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc);
757     if (rc==DS_OK && primary!=NULL) {
758         ref=IDirectSoundBuffer_Release(primary);
759         ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
760         primary=NULL;
761         ZeroMemory(&bufdesc, sizeof(bufdesc));
762         bufdesc.dwSize=sizeof(bufdesc);
763         bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
764         rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
765         ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a 3D primary buffer: 0x%lx\n",rc);
766         if (rc==DS_OK && primary!=NULL) {
767             test_buffer8(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
768             ref=IDirectSoundBuffer_Release(primary);
769             ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
770         }
771     }
772     /* Set the CooperativeLevel back to normal */
773     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
774     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
775     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\n",rc);
776
777 EXIT:
778     ref=IDirectSound8_Release(dso);
779     ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
780     if (ref!=0)
781         return DSERR_GENERIC;
782
783     return rc;
784 }
785
786 static HRESULT test_primary_3d_with_listener8(LPGUID lpGuid)
787 {
788     HRESULT rc;
789     LPDIRECTSOUND8 dso=NULL;
790     LPDIRECTSOUNDBUFFER primary=NULL;
791     DSBUFFERDESC bufdesc;
792     DSCAPS dscaps;
793     int ref;
794
795     /* Create the DirectSound object */
796     rc=DirectSoundCreate8(lpGuid,&dso,NULL);
797     ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc);
798     if (rc!=DS_OK)
799         return rc;
800
801     /* Get the device capabilities */
802     ZeroMemory(&dscaps, sizeof(dscaps));
803     dscaps.dwSize=sizeof(dscaps);
804     rc=IDirectSound8_GetCaps(dso,&dscaps);
805     ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
806     if (rc!=DS_OK)
807         goto EXIT;
808
809     /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
810     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
811     rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
812     ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\n",rc);
813     if (rc!=DS_OK)
814         goto EXIT;
815     primary=NULL;
816     ZeroMemory(&bufdesc, sizeof(bufdesc));
817     bufdesc.dwSize=sizeof(bufdesc);
818     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
819     rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
820     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a 3D primary buffer 0x%lx\n",rc);
821     if (rc==DS_OK && primary!=NULL) {
822         LPDIRECTSOUND3DLISTENER listener=NULL;
823         rc=IDirectSoundBuffer_QueryInterface(primary,&IID_IDirectSound3DListener,(void **)&listener);
824         ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface failed to get a 3D listener 0x%lx\n",rc);
825         if (rc==DS_OK && listener!=NULL) {
826             LPDIRECTSOUNDBUFFER temp_buffer=NULL;
827
828             /* Checking the COM interface */
829             rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
830             ok(rc==DS_OK && temp_buffer!=NULL,"IDirectSoundBuffer_QueryInterface failed: 0x%lx\n",rc);
831             ok(temp_buffer==primary,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)primary);
832             if (rc==DS_OK && temp_buffer!=NULL) {
833                 ref=IDirectSoundBuffer_Release(temp_buffer);
834                 ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref);
835
836                 temp_buffer=NULL;
837                 rc=IDirectSound3DListener_QueryInterface(listener, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
838                 ok(rc==DS_OK && temp_buffer!=NULL,"IDirectSoundBuffer_QueryInterface failed: 0x%lx\n",rc);
839                 ok(temp_buffer==primary,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)primary);
840                 ref=IDirectSoundBuffer_Release(temp_buffer);
841                 ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref);
842
843                 /* Testing the buffer */
844                 test_buffer8(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,listener,0,0);
845             }
846
847             /* Testing the reference counting */
848             ref=IDirectSound3DListener_Release(listener);
849             ok(ref==0,"IDirectSound3DListener_Release listener has %d references, should have 0\n",ref);
850         }
851
852         /* Testing the reference counting */
853         ref=IDirectSoundBuffer_Release(primary);
854         ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
855     }
856
857 EXIT:
858     ref=IDirectSound8_Release(dso);
859     ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
860     if (ref!=0)
861 return DSERR_GENERIC;
862
863     return rc;
864 }
865
866 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
867                                    LPCSTR lpcstrModule, LPVOID lpContext)
868 {
869     trace("*** Testing %s - %s\n",lpcstrDescription,lpcstrModule);
870
871     trace("  Testing the primary buffer\n");
872     test_primary8(lpGuid);
873
874     trace("  Testing 3D primary buffer\n");
875     test_primary_3d8(lpGuid);
876
877     trace("  Testing 3D primary buffer with listener\n");
878     test_primary_3d_with_listener8(lpGuid);
879
880     /* Testing secondary buffers */
881     test_secondary8(lpGuid,winetest_interactive,0,0,0,0,0,0);
882     test_secondary8(lpGuid,winetest_interactive,0,0,0,1,0,0);
883
884     /* Testing 3D secondary buffers */
885     test_secondary8(lpGuid,winetest_interactive,1,0,0,0,0,0);
886     test_secondary8(lpGuid,winetest_interactive,1,1,0,0,0,0);
887     test_secondary8(lpGuid,winetest_interactive,1,1,0,1,0,0);
888     test_secondary8(lpGuid,winetest_interactive,1,0,1,0,0,0);
889     test_secondary8(lpGuid,winetest_interactive,1,0,1,1,0,0);
890     test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,0);
891     test_secondary8(lpGuid,winetest_interactive,1,1,1,1,0,0);
892     test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,0);
893     test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,1);
894     test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,1);
895
896     return 1;
897 }
898
899 static void ds3d8_tests()
900 {
901     HRESULT rc;
902     rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
903     ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
904 }
905
906 START_TEST(ds3d8)
907 {
908     HMODULE hDsound;
909     FARPROC pFunc;
910
911     CoInitialize(NULL);
912
913     hDsound = LoadLibraryA("dsound.dll");
914     if (!hDsound) {
915         trace("dsound.dll not found\n");
916         return;
917     }
918
919     pFunc = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
920     if (!pFunc) {
921         trace("ds3d8 test skipped\n");
922         return;
923     }
924
925     ds3d8_tests();
926 }