2 * Tests the panning and 3D functions of DirectSound
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.
9 * Copyright (c) 2002-2004 Francois Gouget
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.
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.
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
26 #define NONAMELESSSTRUCT
27 #define NONAMELESSUNION
32 #include "wine/test.h"
36 #include "dsound_test.h"
38 #define PI 3.14159265358979323846
39 char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
46 nb_samples=(int)(duration*wfx->nSamplesPerSec);
47 *size=nb_samples*wfx->nBlockAlign;
49 for (i=0;i<nb_samples;i++) {
50 double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
51 if (wfx->wBitsPerSample==8) {
52 unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
54 if (wfx->nChannels==2)
57 signed short sample=(signed short)((double)32767.5*y-0.5);
61 if (wfx->nChannels==2) {
71 const char * getDSBCAPS(DWORD xmask) {
76 #define FE(x) { x, #x },
77 FE(DSBCAPS_PRIMARYBUFFER)
79 FE(DSBCAPS_LOCHARDWARE)
80 FE(DSBCAPS_LOCSOFTWARE)
82 FE(DSBCAPS_CTRLFREQUENCY)
84 FE(DSBCAPS_CTRLVOLUME)
85 FE(DSBCAPS_CTRLPOSITIONNOTIFY)
86 FE(DSBCAPS_STICKYFOCUS)
87 FE(DSBCAPS_GLOBALFOCUS)
88 FE(DSBCAPS_GETCURRENTPOSITION2)
89 FE(DSBCAPS_MUTE3DATMAXDISTANCE)
92 static char buffer[512];
98 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++) {
99 if ((flags[i].mask & xmask) == flags[i].mask) {
104 strcat(buffer, flags[i].name);
113 HWND hwnd=GetForegroundWindow();
115 hwnd=GetDesktopWindow();
119 void init_format(WAVEFORMATEX* wfx, int format, int rate, int depth,
122 wfx->wFormatTag=format;
123 wfx->nChannels=channels;
124 wfx->wBitsPerSample=depth;
125 wfx->nSamplesPerSec=rate;
126 wfx->nBlockAlign=wfx->nChannels*wfx->wBitsPerSample/8;
127 /* FIXME: Shouldn't this test be if (format!=WAVE_FORMAT_PCM) */
128 if (wfx->nBlockAlign==0)
130 /* align compressed formats to byte boundary */
133 wfx->nAvgBytesPerSec=wfx->nSamplesPerSec*wfx->nBlockAlign;
141 LPDIRECTSOUNDBUFFER dsbo;
149 static int buffer_refill(play_state_t* state, DWORD size)
155 if (size>state->wave_len-state->written)
156 size=state->wave_len-state->written;
158 rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
159 &ptr1,&len1,&ptr2,&len2,0);
160 ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
161 DXGetErrorString8(rc));
165 memcpy(ptr1,state->wave+state->written,len1);
166 state->written+=len1;
168 memcpy(ptr2,state->wave+state->written,len2);
169 state->written+=len2;
171 state->offset=state->written % state->buffer_size;
172 rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
173 ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
174 DXGetErrorString8(rc));
180 static int buffer_silence(play_state_t* state, DWORD size)
187 rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
188 &ptr1,&len1,&ptr2,&len2,0);
189 ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
190 DXGetErrorString8(rc));
194 s=(state->wfx->wBitsPerSample==8?0x80:0);
199 state->offset=(state->offset+size) % state->buffer_size;
200 rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
201 ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
202 DXGetErrorString8(rc));
208 static int buffer_service(play_state_t* state)
210 DWORD last_play_pos,play_pos,buf_free;
213 rc=IDirectSoundBuffer_GetCurrentPosition(state->dsbo,&play_pos,NULL);
214 ok(rc==DS_OK,"IDirectSoundBuffer_GetCurrentPosition() failed: %s\n",
215 DXGetErrorString8(rc));
220 /* Update the amount played */
221 last_play_pos=state->played % state->buffer_size;
222 if (play_pos<last_play_pos)
223 state->played+=state->buffer_size-last_play_pos+play_pos;
225 state->played+=play_pos-last_play_pos;
227 if (winetest_debug > 1)
228 trace("buf size=%ld last_play_pos=%ld play_pos=%ld played=%ld / %ld\n",
229 state->buffer_size,last_play_pos,play_pos,state->played,
232 if (state->played>state->wave_len)
234 /* Everything has been played */
238 /* Refill the buffer */
239 if (state->offset<=play_pos)
240 buf_free=play_pos-state->offset;
242 buf_free=state->buffer_size-state->offset+play_pos;
244 if (winetest_debug > 1)
245 trace("offset=%ld free=%ld written=%ld / %ld\n",
246 state->offset,buf_free,state->written,state->wave_len);
250 if (state->written<state->wave_len)
252 int w=buffer_refill(state,buf_free);
256 if (state->written==state->wave_len && winetest_debug > 1)
257 trace("last sound byte at %ld\n",
258 (state->written % state->buffer_size));
262 /* Fill with silence */
263 if (winetest_debug > 1)
264 trace("writing %ld bytes of silence\n",buf_free);
265 if (buffer_silence(state,buf_free)==-1)
271 if (winetest_debug > 1)
272 trace("stopping playback\n");
273 rc=IDirectSoundBuffer_Stop(state->dsbo);
274 ok(rc==DS_OK,"IDirectSoundBuffer_Stop() failed: %s\n",
275 DXGetErrorString8(rc));
279 void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
280 BOOL is_primary, BOOL set_volume, LONG volume,
281 BOOL set_pan, LONG pan, BOOL play, double duration,
282 BOOL buffer3d, LPDIRECTSOUND3DLISTENER listener,
283 BOOL move_listener, BOOL move_sound)
287 WAVEFORMATEX wfx,wfx2;
288 DWORD size,status,freq;
291 /* DSOUND: Error: Invalid caps pointer */
292 rc=IDirectSoundBuffer_GetCaps(dsbo,0);
293 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
294 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
296 ZeroMemory(&dsbcaps, sizeof(dsbcaps));
298 /* DSOUND: Error: Invalid caps pointer */
299 rc=IDirectSoundBuffer_GetCaps(dsbo,&dsbcaps);
300 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
301 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
303 dsbcaps.dwSize=sizeof(dsbcaps);
304 rc=IDirectSoundBuffer_GetCaps(dsbo,&dsbcaps);
305 ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %s\n",
306 DXGetErrorString8(rc));
307 if (rc==DS_OK && winetest_debug > 1) {
308 trace(" Caps: flags=0x%08lx size=%ld\n",dsbcaps.dwFlags,
309 dsbcaps.dwBufferBytes);
312 /* Query the format size. Note that it may not match sizeof(wfx) */
314 rc=IDirectSoundBuffer_GetFormat(dsbo,NULL,0,&size);
315 ok(rc==DS_OK && size!=0,"IDirectSoundBuffer_GetFormat() should have "
316 "returned the needed size: rc=%s size=%ld\n",DXGetErrorString8(rc),size);
318 rc=IDirectSoundBuffer_GetFormat(dsbo,&wfx,sizeof(wfx),NULL);
319 ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
320 DXGetErrorString8(rc));
321 if (rc==DS_OK && winetest_debug > 1) {
322 trace(" Format: %s tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
323 is_primary ? "Primary" : "Secondary",
324 wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
325 wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
328 /* DSOUND: Error: Invalid frequency buffer */
329 rc=IDirectSoundBuffer_GetFrequency(dsbo,0);
330 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetFrequency() should have "
331 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
333 /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
334 rc=IDirectSoundBuffer_GetFrequency(dsbo,&freq);
335 ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
336 (rc==DSERR_CONTROLUNAVAIL&&!(dsbcaps.dwFlags&DSBCAPS_CTRLFREQUENCY)),
337 "IDirectSoundBuffer_GetFrequency() failed: %s\n",DXGetErrorString8(rc));
339 ok(freq==wfx.nSamplesPerSec,"The frequency returned by GetFrequency "
340 "%ld does not match the format %ld\n",freq,wfx.nSamplesPerSec);
343 /* DSOUND: Error: Invalid status pointer */
344 rc=IDirectSoundBuffer_GetStatus(dsbo,0);
345 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetStatus() should have "
346 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
348 rc=IDirectSoundBuffer_GetStatus(dsbo,&status);
349 ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n",
350 DXGetErrorString8(rc));
351 ok(status==0,"status=0x%lx instead of 0\n",status);
354 /* We must call SetCooperativeLevel to be allowed to call SetFormat */
355 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
356 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
357 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
358 "%s\n",DXGetErrorString8(rc));
362 /* DSOUND: Error: Invalid format pointer */
363 rc=IDirectSoundBuffer_SetFormat(dsbo,0);
364 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_SetFormat() should have "
365 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
367 init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
368 rc=IDirectSoundBuffer_SetFormat(dsbo,&wfx2);
369 ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat() failed: %s\n",
370 DXGetErrorString8(rc));
372 /* There is no garantee that SetFormat will actually change the
373 * format to what we asked for. It depends on what the soundcard
374 * supports. So we must re-query the format.
376 rc=IDirectSoundBuffer_GetFormat(dsbo,&wfx,sizeof(wfx),NULL);
377 ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
378 DXGetErrorString8(rc));
380 (wfx.wFormatTag!=wfx2.wFormatTag ||
381 wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
382 wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
383 wfx.nChannels!=wfx2.nChannels)) {
384 trace("Requested format tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
385 wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
386 wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
387 trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
388 wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
389 wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
392 /* Set the CooperativeLevel back to normal */
393 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
394 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
395 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: "
396 "%s\n",DXGetErrorString8(rc));
401 DS3DLISTENER listener_param;
402 LPDIRECTSOUND3DBUFFER buffer=NULL;
403 DS3DBUFFER buffer_param;
404 DWORD start_time,now;
406 if (winetest_interactive) {
407 trace(" Playing %g second 440Hz tone at %ldx%dx%d\n", duration,
408 wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
412 /* We must call SetCooperativeLevel to be allowed to call Lock */
413 /* DSOUND: Setting DirectSound cooperative level to
414 * DSSCL_WRITEPRIMARY */
415 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),
417 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_WRITEPRIMARY) "
418 "failed: %s\n",DXGetErrorString8(rc));
423 LPDIRECTSOUNDBUFFER temp_buffer;
425 rc=IDirectSoundBuffer_QueryInterface(dsbo,&IID_IDirectSound3DBuffer,
427 ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %s\n",
428 DXGetErrorString8(rc));
432 /* check the COM interface */
433 rc=IDirectSoundBuffer_QueryInterface(dsbo, &IID_IDirectSoundBuffer,
434 (LPVOID *)&temp_buffer);
435 ok(rc==DS_OK && temp_buffer!=NULL,
436 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
437 DXGetErrorString8(rc));
438 ok(temp_buffer==dsbo,"COM interface broken: 0x%08lx != 0x%08lx\n",
439 (DWORD)temp_buffer,(DWORD)dsbo);
440 ref=IDirectSoundBuffer_Release(temp_buffer);
441 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
442 "should have 1\n",ref);
445 rc=IDirectSound3DBuffer_QueryInterface(dsbo,
446 &IID_IDirectSoundBuffer,
447 (LPVOID *)&temp_buffer);
448 ok(rc==DS_OK && temp_buffer!=NULL,
449 "IDirectSound3DBuffer_QueryInterface() failed: %s\n",
450 DXGetErrorString8(rc));
451 ok(temp_buffer==dsbo,"COM interface broken: 0x%08lx != 0x%08lx\n",
452 (DWORD)temp_buffer,(DWORD)dsbo);
453 ref=IDirectSoundBuffer_Release(temp_buffer);
454 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
455 "should have 1\n",ref);
458 /* FIXME: this works on windows */
459 ref=IDirectSoundBuffer_Release(dsbo);
460 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
461 "should have 0\n",ref);
463 rc=IDirectSound3DBuffer_QueryInterface(buffer,
464 &IID_IDirectSoundBuffer,
466 ok(rc==DS_OK && dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
467 "failed: %s\n",DXGetErrorString8(rc));
470 /* DSOUND: Error: Invalid buffer */
471 rc=IDirectSound3DBuffer_GetAllParameters(buffer,0);
472 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
473 "failed: %s\n",DXGetErrorString8(rc));
475 ZeroMemory(&buffer_param, sizeof(buffer_param));
477 /* DSOUND: Error: Invalid buffer */
478 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
479 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
480 "failed: %s\n",DXGetErrorString8(rc));
482 buffer_param.dwSize=sizeof(buffer_param);
483 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
484 ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %s\n",
485 DXGetErrorString8(rc));
488 if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
490 rc=IDirectSoundBuffer_GetVolume(dsbo,&val);
491 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
492 DXGetErrorString8(rc));
494 rc=IDirectSoundBuffer_SetVolume(dsbo,volume);
495 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %s\n",
496 DXGetErrorString8(rc));
498 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
499 rc=IDirectSoundBuffer_GetVolume(dsbo,&volume);
500 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
501 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
502 DXGetErrorString8(rc));
507 if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
509 rc=IDirectSoundBuffer_GetPan(dsbo,&val);
510 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %s\n",
511 DXGetErrorString8(rc));
513 rc=IDirectSoundBuffer_SetPan(dsbo,pan);
514 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %s\n",
515 DXGetErrorString8(rc));
517 /* DSOUND: Error: Buffer does not have CTRLPAN */
518 rc=IDirectSoundBuffer_GetPan(dsbo,&pan);
519 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
520 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
521 DXGetErrorString8(rc));
525 state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
529 state.buffer_size=dsbcaps.dwBufferBytes;
530 state.played=state.written=state.offset=0;
531 buffer_refill(&state,state.buffer_size);
533 rc=IDirectSoundBuffer_Play(dsbo,0,0,DSBPLAY_LOOPING);
534 ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %s\n",
535 DXGetErrorString8(rc));
537 rc=IDirectSoundBuffer_GetStatus(dsbo,&status);
538 ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n",
539 DXGetErrorString8(rc));
540 ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING),
541 "GetStatus: bad status: %lx\n",status);
544 ZeroMemory(&listener_param,sizeof(listener_param));
545 listener_param.dwSize=sizeof(listener_param);
546 rc=IDirectSound3DListener_GetAllParameters(listener,
548 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
549 "failed: %s\n",DXGetErrorString8(rc));
551 listener_param.vPosition.x = -5.0;
552 listener_param.vVelocity.x = 10.0/duration;
554 rc=IDirectSound3DListener_SetAllParameters(listener,
557 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %s\n",
558 DXGetErrorString8(rc));
562 buffer_param.vPosition.x = 100.0;
563 buffer_param.vVelocity.x = -200.0/duration;
565 buffer_param.flMinDistance = 10;
566 rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,
568 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
569 DXGetErrorString8(rc));
572 start_time=GetTickCount();
573 while (buffer_service(&state)) {
574 WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
576 if (listener && move_listener) {
577 listener_param.vPosition.x = -5.0+10.0*(now-start_time)/
579 if (winetest_debug>2)
580 trace("listener position=%g\n",listener_param.vPosition.x);
581 rc=IDirectSound3DListener_SetPosition(listener,
582 listener_param.vPosition.x,listener_param.vPosition.y,
583 listener_param.vPosition.z,DS3D_IMMEDIATE);
584 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: "
585 "%s\n",DXGetErrorString8(rc));
587 if (buffer3d && move_sound) {
588 buffer_param.vPosition.x = 100-200.0*(now-start_time)/
590 if (winetest_debug>2)
591 trace("sound position=%g\n",buffer_param.vPosition.x);
592 rc=IDirectSound3DBuffer_SetPosition(buffer,
593 buffer_param.vPosition.x,buffer_param.vPosition.y,
594 buffer_param.vPosition.z,DS3D_IMMEDIATE);
595 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
596 DXGetErrorString8(rc));
599 /* Check the sound duration was within 10% of the expected value */
601 ok(fabs(1000*duration-now+start_time)<=100*duration,
602 "The sound played for %ld ms instead of %g ms\n",
603 now-start_time,1000*duration);
607 /* Set the CooperativeLevel back to normal */
608 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
609 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
610 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) "
611 "failed: %s\n",DXGetErrorString8(rc));
614 ref=IDirectSound3DBuffer_Release(buffer);
615 ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
616 "should have 0\n",ref);
621 static HRESULT test_secondary(LPGUID lpGuid, int play,
622 int has_3d, int has_3dbuffer,
623 int has_listener, int has_duplicate,
624 int move_listener, int move_sound)
627 LPDIRECTSOUND dso=NULL;
628 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
629 LPDIRECTSOUND3DLISTENER listener=NULL;
630 DSBUFFERDESC bufdesc;
631 WAVEFORMATEX wfx, wfx1;
634 /* Create the DirectSound object */
635 rc=DirectSoundCreate(lpGuid,&dso,NULL);
636 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
637 DXGetErrorString8(rc));
641 /* We must call SetCooperativeLevel before creating primary buffer */
642 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
643 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
644 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
645 "%s\n",DXGetErrorString8(rc));
649 ZeroMemory(&bufdesc, sizeof(bufdesc));
650 bufdesc.dwSize=sizeof(bufdesc);
651 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
653 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
655 bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
656 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
657 ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() "
658 "failed to create a %sprimary buffer: %s\n",has_3d?"3D ":"",
659 DXGetErrorString8(rc));
661 if (rc==DS_OK && primary!=NULL) {
662 rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
663 ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
664 DXGetErrorString8(rc));
669 rc=IDirectSoundBuffer_QueryInterface(primary,
670 &IID_IDirectSound3DListener,
672 ok(rc==DS_OK && listener!=NULL,
673 "IDirectSoundBuffer_QueryInterface() failed to get a 3D "
674 "listener: %s\n",DXGetErrorString8(rc));
675 ref=IDirectSoundBuffer_Release(primary);
676 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
677 "should have 0\n",ref);
678 if (rc==DS_OK && listener!=NULL) {
679 DS3DLISTENER listener_param;
680 ZeroMemory(&listener_param,sizeof(listener_param));
681 /* DSOUND: Error: Invalid buffer */
682 rc=IDirectSound3DListener_GetAllParameters(listener,0);
683 ok(rc==DSERR_INVALIDPARAM,
684 "IDirectSound3dListener_GetAllParameters() should have "
685 "returned DSERR_INVALIDPARAM, returned: %s\n",
686 DXGetErrorString8(rc));
688 /* DSOUND: Error: Invalid buffer */
689 rc=IDirectSound3DListener_GetAllParameters(listener,
691 ok(rc==DSERR_INVALIDPARAM,
692 "IDirectSound3dListener_GetAllParameters() should have "
693 "returned DSERR_INVALIDPARAM, returned: %s\n",
694 DXGetErrorString8(rc));
696 listener_param.dwSize=sizeof(listener_param);
697 rc=IDirectSound3DListener_GetAllParameters(listener,
699 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
700 "failed: %s\n",DXGetErrorString8(rc));
706 init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
708 ZeroMemory(&bufdesc, sizeof(bufdesc));
709 bufdesc.dwSize=sizeof(bufdesc);
710 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
712 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
715 (DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
716 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
718 bufdesc.lpwfxFormat=&wfx;
719 if (winetest_interactive) {
720 trace(" Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d "
721 "with a primary buffer at %ldx%dx%d\n",
722 has_3dbuffer?"3D ":"",
723 has_duplicate?"duplicated ":"",
724 listener!=NULL||move_sound?"with ":"",
725 move_listener?"moving ":"",
726 listener!=NULL?"listener ":"",
727 listener&&move_sound?"and moving sound ":move_sound?
729 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
730 wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
732 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
733 ok(rc==DS_OK && secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
734 "failed to create a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d (%s): %s\n",
735 has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
736 listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
737 listener!=NULL?"listener ":"",
738 listener&&move_sound?"and moving sound ":move_sound?
740 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
741 getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
742 if (rc==DS_OK && secondary!=NULL) {
747 /* Check the initial secondary buffer's volume and pan */
748 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
749 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: "
750 "%s\n",DXGetErrorString8(rc));
751 ok(vol==0,"wrong volume for a new secondary buffer: %ld\n",vol);
752 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
753 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: "
754 "%s\n",DXGetErrorString8(rc));
755 ok(pan==0,"wrong pan for a new secondary buffer: %ld\n",pan);
757 /* Check that changing the secondary buffer's volume and pan
758 * does not impact the primary buffer's volume and pan
760 rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
761 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "
762 "%s\n",DXGetErrorString8(rc));
763 rc=IDirectSoundBuffer_GetPan(primary,&refpan);
764 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %s\n",
765 DXGetErrorString8(rc));
767 rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
768 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
769 "%s\n",DXGetErrorString8(rc));
770 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
771 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
772 "%s\n",DXGetErrorString8(rc));
773 ok(vol==-1000,"secondary: wrong volume %ld instead of -1000\n",
775 rc=IDirectSoundBuffer_SetPan(secondary,-1000);
776 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
777 "%s\n",DXGetErrorString8(rc));
778 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
779 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
780 "%s\n",DXGetErrorString8(rc));
781 ok(pan==-1000,"secondary: wrong pan %ld instead of -1000\n",
784 rc=IDirectSoundBuffer_GetVolume(primary,&vol);
785 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "
786 "%s\n",DXGetErrorString8(rc));
787 ok(vol==refvol,"The primary volume changed from %ld to %ld\n",
789 rc=IDirectSoundBuffer_GetPan(primary,&pan);
790 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %s\n",
791 DXGetErrorString8(rc));
792 ok(pan==refpan,"The primary pan changed from %ld to %ld\n",
795 rc=IDirectSoundBuffer_SetVolume(secondary,0);
796 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
797 "%s\n",DXGetErrorString8(rc));
798 rc=IDirectSoundBuffer_SetPan(secondary,0);
799 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
800 "%s\n",DXGetErrorString8(rc));
803 LPDIRECTSOUNDBUFFER duplicated=NULL;
805 /* DSOUND: Error: Invalid source buffer */
806 rc=IDirectSound_DuplicateSoundBuffer(dso,0,0);
807 ok(rc==DSERR_INVALIDPARAM,
808 "IDirectSound_DuplicateSoundBuffer() should have returned "
809 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
811 /* DSOUND: Error: Invalid dest buffer */
812 rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,0);
813 ok(rc==DSERR_INVALIDPARAM,
814 "IDirectSound_DuplicateSoundBuffer() should have returned "
815 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
817 /* DSOUND: Error: Invalid source buffer */
818 rc=IDirectSound_DuplicateSoundBuffer(dso,0,&duplicated);
819 ok(rc==DSERR_INVALIDPARAM,
820 "IDirectSound_DuplicateSoundBuffer() should have returned "
821 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
824 rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,
826 ok(rc==DS_OK && duplicated!=NULL,
827 "IDirectSound_DuplicateSoundBuffer() failed to duplicate "
828 "a secondary buffer: %s\n",DXGetErrorString8(rc));
830 if (rc==DS_OK && duplicated!=NULL) {
831 ref=IDirectSoundBuffer_Release(secondary);
832 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
833 "references, should have 0\n",ref);
834 secondary=duplicated;
838 if (rc==DS_OK && secondary!=NULL) {
840 duration=(move_listener || move_sound?4.0:1.0);
841 test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
842 winetest_interactive,duration,has_3dbuffer,
843 listener,move_listener,move_sound);
844 ref=IDirectSoundBuffer_Release(secondary);
845 ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
846 "should have 0\n",has_duplicate?"duplicated":"secondary",
853 ref=IDirectSound3DListener_Release(listener);
854 ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
855 "references, should have 0\n",ref);
857 ref=IDirectSoundBuffer_Release(primary);
858 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
859 "should have 0\n",ref);
862 /* Set the CooperativeLevel back to normal */
863 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
864 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
865 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %s\n",
866 DXGetErrorString8(rc));
869 ref=IDirectSound_Release(dso);
870 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
872 return DSERR_GENERIC;
877 static HRESULT test_for_driver(LPGUID lpGuid)
880 LPDIRECTSOUND dso=NULL;
883 /* Create the DirectSound object */
884 rc=DirectSoundCreate(lpGuid,&dso,NULL);
885 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
886 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
890 ref=IDirectSound_Release(dso);
891 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
893 return DSERR_GENERIC;
898 static HRESULT test_primary(LPGUID lpGuid)
901 LPDIRECTSOUND dso=NULL;
902 LPDIRECTSOUNDBUFFER primary=NULL;
903 DSBUFFERDESC bufdesc;
907 /* Create the DirectSound object */
908 rc=DirectSoundCreate(lpGuid,&dso,NULL);
909 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
910 DXGetErrorString8(rc));
914 /* Get the device capabilities */
915 ZeroMemory(&dscaps, sizeof(dscaps));
916 dscaps.dwSize=sizeof(dscaps);
917 rc=IDirectSound_GetCaps(dso,&dscaps);
918 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
922 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
923 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
924 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
925 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
926 "%s\n",DXGetErrorString8(rc));
930 /* Testing the primary buffer */
932 ZeroMemory(&bufdesc, sizeof(bufdesc));
933 bufdesc.dwSize=sizeof(bufdesc);
934 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN;
935 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
936 ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
937 "to create a primary buffer: %s\n",DXGetErrorString8(rc));
938 if (rc==DS_OK && primary!=NULL) {
939 test_buffer(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive &&
940 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
941 if (winetest_interactive) {
944 volume = DSBVOLUME_MAX;
945 for (i = 0; i < 6; i++) {
946 test_buffer(dso,primary,1,TRUE,volume,TRUE,0,
947 winetest_interactive &&
948 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
950 volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
954 for (i = 0; i < 7; i++) {
955 test_buffer(dso,primary,1,TRUE,0,TRUE,pan,
956 winetest_interactive &&
957 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
958 pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
961 ref=IDirectSoundBuffer_Release(primary);
962 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
963 "should have 0\n",ref);
966 /* Set the CooperativeLevel back to normal */
967 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
968 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
969 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %s\n",
970 DXGetErrorString8(rc));
973 ref=IDirectSound_Release(dso);
974 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
976 return DSERR_GENERIC;
981 static HRESULT test_primary_3d(LPGUID lpGuid)
984 LPDIRECTSOUND dso=NULL;
985 LPDIRECTSOUNDBUFFER primary=NULL;
986 DSBUFFERDESC bufdesc;
990 /* Create the DirectSound object */
991 rc=DirectSoundCreate(lpGuid,&dso,NULL);
992 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
993 DXGetErrorString8(rc));
997 /* Get the device capabilities */
998 ZeroMemory(&dscaps, sizeof(dscaps));
999 dscaps.dwSize=sizeof(dscaps);
1000 rc=IDirectSound_GetCaps(dso,&dscaps);
1001 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
1005 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
1006 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
1007 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
1008 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
1009 "%s\n",DXGetErrorString8(rc));
1014 ZeroMemory(&bufdesc, sizeof(bufdesc));
1015 bufdesc.dwSize=sizeof(bufdesc);
1016 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
1017 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1018 ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
1019 "to create a primary buffer: %s\n",DXGetErrorString8(rc));
1020 if (rc==DS_OK && primary!=NULL) {
1021 ref=IDirectSoundBuffer_Release(primary);
1022 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1023 "should have 0\n",ref);
1025 ZeroMemory(&bufdesc, sizeof(bufdesc));
1026 bufdesc.dwSize=sizeof(bufdesc);
1027 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
1028 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1029 ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() "
1030 "failed to create a 3D primary buffer: %s\n",DXGetErrorString8(rc));
1031 if (rc==DS_OK && primary!=NULL) {
1032 test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
1033 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
1034 ref=IDirectSoundBuffer_Release(primary);
1035 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1036 "should have 0\n",ref);
1039 /* Set the CooperativeLevel back to normal */
1040 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
1041 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
1042 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %s\n",
1043 DXGetErrorString8(rc));
1046 ref=IDirectSound_Release(dso);
1047 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
1049 return DSERR_GENERIC;
1054 static HRESULT test_primary_3d_with_listener(LPGUID lpGuid)
1057 LPDIRECTSOUND dso=NULL;
1058 LPDIRECTSOUNDBUFFER primary=NULL;
1059 DSBUFFERDESC bufdesc;
1063 /* Create the DirectSound object */
1064 rc=DirectSoundCreate(lpGuid,&dso,NULL);
1065 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
1066 DXGetErrorString8(rc));
1070 /* Get the device capabilities */
1071 ZeroMemory(&dscaps, sizeof(dscaps));
1072 dscaps.dwSize=sizeof(dscaps);
1073 rc=IDirectSound_GetCaps(dso,&dscaps);
1074 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
1078 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
1079 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
1080 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
1081 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
1082 "%s\n",DXGetErrorString8(rc));
1086 ZeroMemory(&bufdesc, sizeof(bufdesc));
1087 bufdesc.dwSize=sizeof(bufdesc);
1088 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
1089 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1090 ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
1091 "to create a 3D primary buffer: %s\n",DXGetErrorString8(rc));
1092 if (rc==DS_OK && primary!=NULL) {
1093 LPDIRECTSOUND3DLISTENER listener=NULL;
1094 rc=IDirectSoundBuffer_QueryInterface(primary,
1095 &IID_IDirectSound3DListener,(void **)&listener);
1096 ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface() "
1097 "failed to get a 3D listener: %s\n",DXGetErrorString8(rc));
1098 if (rc==DS_OK && listener!=NULL) {
1099 LPDIRECTSOUNDBUFFER temp_buffer=NULL;
1101 /* Checking the COM interface */
1102 rc=IDirectSoundBuffer_QueryInterface(primary,
1103 &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
1104 ok(rc==DS_OK && temp_buffer!=NULL,
1105 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1106 DXGetErrorString8(rc));
1107 ok(temp_buffer==primary,
1108 "COM interface broken: 0x%08lx != 0x%08lx\n",
1109 (DWORD)temp_buffer,(DWORD)primary);
1110 if (rc==DS_OK && temp_buffer!=NULL) {
1111 ref=IDirectSoundBuffer_Release(temp_buffer);
1112 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1113 "should have 1\n",ref);
1116 rc=IDirectSound3DListener_QueryInterface(listener,
1117 &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
1118 ok(rc==DS_OK && temp_buffer!=NULL,
1119 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1120 DXGetErrorString8(rc));
1121 ok(temp_buffer==primary,
1122 "COM interface broken: 0x%08lx != 0x%08lx\n",
1123 (DWORD)temp_buffer,(DWORD)primary);
1124 ref=IDirectSoundBuffer_Release(temp_buffer);
1125 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1126 "should have 1\n",ref);
1128 /* Testing the buffer */
1129 test_buffer(dso,primary,1,FALSE,0,FALSE,0,
1130 winetest_interactive &&
1131 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,
1135 /* Testing the reference counting */
1136 ref=IDirectSound3DListener_Release(listener);
1137 ok(ref==0,"IDirectSound3DListener_Release() listener has %d "
1138 "references, should have 0\n",ref);
1141 /* Testing the reference counting */
1142 ref=IDirectSoundBuffer_Release(primary);
1143 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1144 "should have 0\n",ref);
1148 ref=IDirectSound_Release(dso);
1149 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
1151 return DSERR_GENERIC;
1156 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
1157 LPCSTR lpcstrModule, LPVOID lpContext)
1160 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
1162 rc = test_for_driver(lpGuid);
1163 if (rc == DSERR_NODRIVER) {
1164 trace(" No Driver\n");
1166 } else if (rc == DSERR_ALLOCATED) {
1167 trace(" Already In Use\n");
1169 } else if (rc == E_FAIL) {
1170 trace(" No Device\n");
1174 trace(" Testing the primary buffer\n");
1175 test_primary(lpGuid);
1177 trace(" Testing 3D primary buffer\n");
1178 test_primary_3d(lpGuid);
1180 trace(" Testing 3D primary buffer with listener\n");
1181 test_primary_3d_with_listener(lpGuid);
1183 /* Testing secondary buffers */
1184 test_secondary(lpGuid,winetest_interactive,0,0,0,0,0,0);
1185 test_secondary(lpGuid,winetest_interactive,0,0,0,1,0,0);
1187 /* Testing 3D secondary buffers */
1188 test_secondary(lpGuid,winetest_interactive,1,0,0,0,0,0);
1189 test_secondary(lpGuid,winetest_interactive,1,1,0,0,0,0);
1190 test_secondary(lpGuid,winetest_interactive,1,1,0,1,0,0);
1191 test_secondary(lpGuid,winetest_interactive,1,0,1,0,0,0);
1192 test_secondary(lpGuid,winetest_interactive,1,0,1,1,0,0);
1193 test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,0);
1194 test_secondary(lpGuid,winetest_interactive,1,1,1,1,0,0);
1195 test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,0);
1196 test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,1);
1197 test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,1);
1202 static void ds3d_tests()
1205 rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
1206 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));