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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
34 #include "dsound_test.h"
36 static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
37 static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
43 LPDIRECTSOUNDBUFFER dsbo;
51 static int buffer_refill8(play_state_t* state, DWORD size)
57 if (size>state->wave_len-state->written)
58 size=state->wave_len-state->written;
60 rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
61 &ptr1,&len1,&ptr2,&len2,0);
62 ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
63 DXGetErrorString8(rc));
67 memcpy(ptr1,state->wave+state->written,len1);
70 memcpy(ptr2,state->wave+state->written,len2);
73 state->offset=state->written % state->buffer_size;
74 rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
75 ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
76 DXGetErrorString8(rc));
82 static int buffer_silence8(play_state_t* state, DWORD size)
89 rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
90 &ptr1,&len1,&ptr2,&len2,0);
91 ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %s\n",
92 DXGetErrorString8(rc));
96 s=(state->wfx->wBitsPerSample==8?0x80:0);
101 state->offset=(state->offset+size) % state->buffer_size;
102 rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
103 ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %s\n",
104 DXGetErrorString8(rc));
110 static int buffer_service8(play_state_t* state)
112 DWORD last_play_pos,play_pos,buf_free;
115 rc=IDirectSoundBuffer_GetCurrentPosition(state->dsbo,&play_pos,NULL);
116 ok(rc==DS_OK,"IDirectSoundBuffer_GetCurrentPosition() failed: %s\n",
117 DXGetErrorString8(rc));
122 /* Update the amount played */
123 last_play_pos=state->played % state->buffer_size;
124 if (play_pos<last_play_pos)
125 state->played+=state->buffer_size-last_play_pos+play_pos;
127 state->played+=play_pos-last_play_pos;
129 if (winetest_debug > 1)
130 trace("buf size=%d last_play_pos=%d play_pos=%d played=%d / %d\n",
131 state->buffer_size,last_play_pos,play_pos,state->played,
134 if (state->played>state->wave_len)
136 /* Everything has been played */
140 /* Refill the buffer */
141 if (state->offset<=play_pos)
142 buf_free=play_pos-state->offset;
144 buf_free=state->buffer_size-state->offset+play_pos;
146 if (winetest_debug > 1)
147 trace("offset=%d free=%d written=%d / %d\n",
148 state->offset,buf_free,state->written,state->wave_len);
152 if (state->written<state->wave_len)
154 int w=buffer_refill8(state,buf_free);
158 if (state->written==state->wave_len && winetest_debug > 1)
159 trace("last sound byte at %d\n",
160 (state->written % state->buffer_size));
164 /* Fill with silence */
165 if (winetest_debug > 1)
166 trace("writing %d bytes of silence\n",buf_free);
167 if (buffer_silence8(state,buf_free)==-1)
173 if (winetest_debug > 1)
174 trace("stopping playback\n");
175 rc=IDirectSoundBuffer_Stop(state->dsbo);
176 ok(rc==DS_OK,"IDirectSoundBuffer_Stop() failed: %s\n",
177 DXGetErrorString8(rc));
181 void test_buffer8(LPDIRECTSOUND8 dso, LPDIRECTSOUNDBUFFER * dsbo,
182 BOOL is_primary, BOOL set_volume, LONG volume,
183 BOOL set_pan, LONG pan, BOOL play, double duration,
184 BOOL buffer3d, LPDIRECTSOUND3DLISTENER listener,
185 BOOL move_listener, BOOL move_sound)
189 WAVEFORMATEX wfx,wfx2;
190 DWORD size,status,freq;
193 /* DSOUND: Error: Invalid caps pointer */
194 rc=IDirectSoundBuffer_GetCaps(*dsbo,0);
195 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
196 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
198 ZeroMemory(&dsbcaps, sizeof(dsbcaps));
200 /* DSOUND: Error: Invalid caps pointer */
201 rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
202 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
203 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
205 dsbcaps.dwSize=sizeof(dsbcaps);
206 rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
207 ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %s\n",
208 DXGetErrorString8(rc));
209 if (rc==DS_OK && winetest_debug > 1) {
210 trace(" Caps: flags=0x%08x size=%d\n",dsbcaps.dwFlags,
211 dsbcaps.dwBufferBytes);
214 /* Query the format size. Note that it may not match sizeof(wfx) */
216 rc=IDirectSoundBuffer_GetFormat(*dsbo,NULL,0,&size);
217 ok(rc==DS_OK && size!=0,"IDirectSoundBuffer_GetFormat() should have "
218 "returned the needed size: rc=%s size=%d\n",DXGetErrorString8(rc),size);
220 rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
221 ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
222 DXGetErrorString8(rc));
223 if (rc==DS_OK && winetest_debug > 1) {
224 trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
225 is_primary ? "Primary" : "Secondary",
226 wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
227 wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
230 /* DSOUND: Error: Invalid frequency buffer */
231 rc=IDirectSoundBuffer_GetFrequency(*dsbo,0);
232 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetFrequency() should have "
233 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
235 /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
236 rc=IDirectSoundBuffer_GetFrequency(*dsbo,&freq);
237 ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
238 (rc==DSERR_CONTROLUNAVAIL&&!(dsbcaps.dwFlags&DSBCAPS_CTRLFREQUENCY)),
239 "IDirectSoundBuffer_GetFrequency() failed: %s\n",DXGetErrorString8(rc));
241 ok(freq==wfx.nSamplesPerSec,"The frequency returned by GetFrequency "
242 "%d does not match the format %d\n",freq,wfx.nSamplesPerSec);
245 /* DSOUND: Error: Invalid status pointer */
246 rc=IDirectSoundBuffer_GetStatus(*dsbo,0);
247 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetStatus() should have "
248 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
250 rc=IDirectSoundBuffer_GetStatus(*dsbo,&status);
251 ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n",
252 DXGetErrorString8(rc));
253 ok(status==0,"status=0x%x instead of 0\n",status);
257 /* We must call SetCooperativeLevel to be allowed to call SetFormat */
258 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
259 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
260 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) "
261 "failed: %s\n",DXGetErrorString8(rc));
265 /* DSOUND: Error: Invalid format pointer */
266 rc=IDirectSoundBuffer_SetFormat(*dsbo,0);
267 ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_SetFormat() should have "
268 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
270 init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
271 rc=IDirectSoundBuffer_SetFormat(*dsbo,&wfx2);
272 ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %s\n",
273 format_string(&wfx2), DXGetErrorString8(rc));
275 /* There is no guarantee that SetFormat will actually change the
276 * format to what we asked for. It depends on what the soundcard
277 * supports. So we must re-query the format.
279 rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
280 ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
281 DXGetErrorString8(rc));
283 (wfx.wFormatTag!=wfx2.wFormatTag ||
284 wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
285 wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
286 wfx.nChannels!=wfx2.nChannels)) {
287 trace("Requested format tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
288 wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
289 wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
290 trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
291 wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
292 wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
295 ZeroMemory(&new_dsbcaps, sizeof(new_dsbcaps));
296 new_dsbcaps.dwSize = sizeof(new_dsbcaps);
297 rc=IDirectSoundBuffer_GetCaps(*dsbo,&new_dsbcaps);
298 ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %s\n",
299 DXGetErrorString8(rc));
300 if (rc==DS_OK && winetest_debug > 1) {
301 trace(" new Caps: flags=0x%08x size=%d\n",new_dsbcaps.dwFlags,
302 new_dsbcaps.dwBufferBytes);
305 /* Check for primary buffer size change */
306 ok(new_dsbcaps.dwBufferBytes == dsbcaps.dwBufferBytes,
307 " buffer size changed after SetFormat() - "
308 "previous size was %u, current size is %u\n",
309 dsbcaps.dwBufferBytes, new_dsbcaps.dwBufferBytes);
311 /* Check for primary buffer flags change */
312 ok(new_dsbcaps.dwFlags == dsbcaps.dwFlags,
313 " flags changed after SetFormat() - "
314 "previous flags were %08x, current flags are %08x\n",
315 dsbcaps.dwFlags, new_dsbcaps.dwFlags);
317 /* Set the CooperativeLevel back to normal */
318 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
319 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
320 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
321 "failed: %s\n",DXGetErrorString8(rc));
326 DS3DLISTENER listener_param;
327 LPDIRECTSOUND3DBUFFER buffer=NULL;
328 DS3DBUFFER buffer_param;
329 DWORD start_time,now;
333 if (winetest_interactive) {
334 trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration,
335 wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
339 /* We must call SetCooperativeLevel to be allowed to call Lock */
340 /* DSOUND: Setting DirectSound cooperative level to
341 * DSSCL_WRITEPRIMARY */
342 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),
345 "IDirectSound8_SetCooperativeLevel(DSSCL_WRITEPRIMARY) failed: "
346 "%s\n",DXGetErrorString8(rc));
351 LPDIRECTSOUNDBUFFER temp_buffer;
353 rc=IDirectSoundBuffer_QueryInterface(*dsbo,&IID_IDirectSound3DBuffer,
355 ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %s\n",
356 DXGetErrorString8(rc));
360 /* check the COM interface */
361 rc=IDirectSoundBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
362 (LPVOID *)&temp_buffer);
363 ok(rc==DS_OK && temp_buffer!=NULL,
364 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
365 DXGetErrorString8(rc));
366 ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
368 ref=IDirectSoundBuffer_Release(temp_buffer);
369 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
370 "should have 1\n",ref);
373 rc=IDirectSound3DBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
374 (LPVOID *)&temp_buffer);
375 ok(rc==DS_OK && temp_buffer!=NULL,
376 "IDirectSound3DBuffer_QueryInterface() failed: %s\n",
377 DXGetErrorString8(rc));
378 ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
380 ref=IDirectSoundBuffer_Release(temp_buffer);
381 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
382 "should have 1\n",ref);
384 ref=IDirectSoundBuffer_Release(*dsbo);
385 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
386 "should have 0\n",ref);
388 rc=IDirectSound3DBuffer_QueryInterface(buffer,
389 &IID_IDirectSoundBuffer,
391 ok(rc==DS_OK && *dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
392 "failed: %s\n",DXGetErrorString8(rc));
394 /* DSOUND: Error: Invalid buffer */
395 rc=IDirectSound3DBuffer_GetAllParameters(buffer,0);
396 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
397 "failed: %s\n",DXGetErrorString8(rc));
399 ZeroMemory(&buffer_param, sizeof(buffer_param));
401 /* DSOUND: Error: Invalid buffer */
402 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
403 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
404 "failed: %s\n",DXGetErrorString8(rc));
406 buffer_param.dwSize=sizeof(buffer_param);
407 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
408 ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %s\n",
409 DXGetErrorString8(rc));
412 if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
414 rc=IDirectSoundBuffer_GetVolume(*dsbo,&val);
415 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
416 DXGetErrorString8(rc));
418 rc=IDirectSoundBuffer_SetVolume(*dsbo,volume);
419 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %s\n",
420 DXGetErrorString8(rc));
422 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
423 rc=IDirectSoundBuffer_GetVolume(*dsbo,&volume);
424 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
425 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
426 DXGetErrorString8(rc));
431 if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
433 rc=IDirectSoundBuffer_GetPan(*dsbo,&val);
434 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %s\n",
435 DXGetErrorString8(rc));
437 rc=IDirectSoundBuffer_SetPan(*dsbo,pan);
438 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %s\n",
439 DXGetErrorString8(rc));
441 /* DSOUND: Error: Buffer does not have CTRLPAN */
442 rc=IDirectSoundBuffer_GetPan(*dsbo,&pan);
443 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
444 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
445 DXGetErrorString8(rc));
449 /* try an offset past the end of the buffer */
450 rc = IDirectSoundBuffer_Lock(*dsbo, dsbcaps.dwBufferBytes, 0, &buffer1,
451 &length1, NULL, NULL,
452 DSBLOCK_ENTIREBUFFER);
453 ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
454 "returned DSERR_INVALIDPARAM, returned %s\n", DXGetErrorString8(rc));
456 /* try a size larger than the buffer */
457 rc = IDirectSoundBuffer_Lock(*dsbo, 0, dsbcaps.dwBufferBytes + 1,
458 &buffer1, &length1, NULL, NULL,
459 DSBLOCK_FROMWRITECURSOR);
460 ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
461 "returned DSERR_INVALIDPARAM, returned %s\n", DXGetErrorString8(rc));
463 state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
467 state.buffer_size=dsbcaps.dwBufferBytes;
468 state.played=state.written=state.offset=0;
469 buffer_refill8(&state,state.buffer_size);
471 rc=IDirectSoundBuffer_Play(*dsbo,0,0,DSBPLAY_LOOPING);
472 ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %s\n",
473 DXGetErrorString8(rc));
475 rc=IDirectSoundBuffer_GetStatus(*dsbo,&status);
476 ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n",
477 DXGetErrorString8(rc));
478 ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING),
479 "GetStatus: bad status: %x\n",status);
482 ZeroMemory(&listener_param,sizeof(listener_param));
483 listener_param.dwSize=sizeof(listener_param);
484 rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
485 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
486 "failed: %s\n",DXGetErrorString8(rc));
488 listener_param.vPosition.x = -5.0;
489 listener_param.vVelocity.x = 10.0/duration;
491 rc=IDirectSound3DListener_SetAllParameters(listener,
494 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %s\n",
495 DXGetErrorString8(rc));
499 buffer_param.vPosition.x = 100.0;
500 buffer_param.vVelocity.x = -200.0/duration;
502 buffer_param.flMinDistance = 10;
503 rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,
505 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
506 DXGetErrorString8(rc));
509 start_time=GetTickCount();
510 while (buffer_service8(&state)) {
511 WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
513 if (listener && move_listener) {
514 listener_param.vPosition.x = -5.0+10.0*(now-start_time)/
516 if (winetest_debug>2)
517 trace("listener position=%g\n",listener_param.vPosition.x);
518 rc=IDirectSound3DListener_SetPosition(listener,
519 listener_param.vPosition.x,listener_param.vPosition.y,
520 listener_param.vPosition.z,DS3D_IMMEDIATE);
521 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: "
522 "%s\n",DXGetErrorString8(rc));
524 if (buffer3d && move_sound) {
525 buffer_param.vPosition.x = 100-200.0*(now-start_time)/
527 if (winetest_debug>2)
528 trace("sound position=%g\n",buffer_param.vPosition.x);
529 rc=IDirectSound3DBuffer_SetPosition(buffer,
530 buffer_param.vPosition.x,buffer_param.vPosition.y,
531 buffer_param.vPosition.z,DS3D_IMMEDIATE);
532 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
533 DXGetErrorString8(rc));
536 /* Check the sound duration was within 10% of the expected value */
538 ok(fabs(1000*duration-now+start_time)<=100*duration,
539 "The sound played for %d ms instead of %g ms\n",
540 now-start_time,1000*duration);
544 /* Set the CooperativeLevel back to normal */
545 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
546 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
547 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
548 "failed: %s\n",DXGetErrorString8(rc));
551 ref=IDirectSound3DBuffer_Release(buffer);
552 ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
553 "should have 0\n",ref);
558 static HRESULT test_secondary8(LPGUID lpGuid, int play,
559 int has_3d, int has_3dbuffer,
560 int has_listener, int has_duplicate,
561 int move_listener, int move_sound)
564 LPDIRECTSOUND8 dso=NULL;
565 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
566 LPDIRECTSOUND3DLISTENER listener=NULL;
567 DSBUFFERDESC bufdesc;
568 WAVEFORMATEX wfx, wfx1;
571 /* Create the DirectSound object */
572 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
573 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
574 DXGetErrorString8(rc));
578 /* We must call SetCooperativeLevel before creating primary buffer */
579 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
580 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
581 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
582 "%s\n",DXGetErrorString8(rc));
586 ZeroMemory(&bufdesc, sizeof(bufdesc));
587 bufdesc.dwSize=sizeof(bufdesc);
588 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
590 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
592 bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
593 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
594 ok((rc==DS_OK && primary!=NULL) || (rc == DSERR_CONTROLUNAVAIL),
595 "IDirectSound8_CreateSoundBuffer() failed to create a %sprimary buffer: "
596 "%s\n",has_3d?"3D ":"", DXGetErrorString8(rc));
597 if (rc == DSERR_CONTROLUNAVAIL)
598 trace(" No Primary\n");
599 else if (rc==DS_OK && primary!=NULL) {
600 rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
601 ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
602 DXGetErrorString8(rc));
607 rc=IDirectSoundBuffer_QueryInterface(primary,
608 &IID_IDirectSound3DListener,
610 ok(rc==DS_OK && listener!=NULL,
611 "IDirectSoundBuffer_QueryInterface() failed to get a 3D "
612 "listener %s\n",DXGetErrorString8(rc));
613 ref=IDirectSoundBuffer_Release(primary);
614 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
615 "should have 0\n",ref);
616 if (rc==DS_OK && listener!=NULL) {
617 DS3DLISTENER listener_param;
618 ZeroMemory(&listener_param,sizeof(listener_param));
619 /* DSOUND: Error: Invalid buffer */
620 rc=IDirectSound3DListener_GetAllParameters(listener,0);
621 ok(rc==DSERR_INVALIDPARAM,
622 "IDirectSound3dListener_GetAllParameters() should have "
623 "returned DSERR_INVALIDPARAM, returned: %s\n",
624 DXGetErrorString8(rc));
626 /* DSOUND: Error: Invalid buffer */
627 rc=IDirectSound3DListener_GetAllParameters(listener,
629 ok(rc==DSERR_INVALIDPARAM,
630 "IDirectSound3dListener_GetAllParameters() should have "
631 "returned DSERR_INVALIDPARAM, returned: %s\n",
632 DXGetErrorString8(rc));
634 listener_param.dwSize=sizeof(listener_param);
635 rc=IDirectSound3DListener_GetAllParameters(listener,
637 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
638 "failed: %s\n",DXGetErrorString8(rc));
640 ok(listener==NULL, "IDirectSoundBuffer_QueryInterface() "
641 "failed but returned a listener anyway\n");
642 ok(rc!=DS_OK, "IDirectSoundBuffer_QueryInterface() succeeded "
643 "but returned a NULL listener\n");
645 ref=IDirectSound3DListener_Release(listener);
646 ok(ref==0,"IDirectSound3dListener_Release() listener has "
647 "%d references, should have 0\n",ref);
653 init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
655 ZeroMemory(&bufdesc, sizeof(bufdesc));
656 bufdesc.dwSize=sizeof(bufdesc);
657 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
659 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
662 (DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
663 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
665 bufdesc.lpwfxFormat=&wfx;
667 /* a stereo 3D buffer should fail */
668 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
669 ok(rc==DSERR_INVALIDPARAM,
670 "IDirectSound8_CreateSoundBuffer(secondary) should have "
671 "returned DSERR_INVALIDPARAM, returned %s\n",
672 DXGetErrorString8(rc));
674 ref=IDirectSoundBuffer_Release(secondary);
675 init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
678 if (winetest_interactive) {
679 trace(" Testing a %s%ssecondary buffer %s%s%s%sat %dx%dx%d "
680 "with a primary buffer at %dx%dx%d\n",
681 has_3dbuffer?"3D ":"",
682 has_duplicate?"duplicated ":"",
683 listener!=NULL||move_sound?"with ":"",
684 move_listener?"moving ":"",
685 listener!=NULL?"listener ":"",
686 listener&&move_sound?"and moving sound ":move_sound?
688 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
689 wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
691 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
692 ok(rc==DS_OK && secondary!=NULL,"IDirectSound8_CreateSoundBuffer() "
693 "failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %s\n",
694 has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
695 listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
696 listener!=NULL?"listener ":"",
697 listener&&move_sound?"and moving sound ":move_sound?
699 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
700 getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
701 if (rc==DS_OK && secondary!=NULL) {
703 LONG refvol,vol,refpan,pan;
705 /* Check the initial secondary buffer's volume and pan */
706 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
707 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: "
708 "%s\n",DXGetErrorString8(rc));
709 ok(vol==0,"wrong volume for a new secondary buffer: %d\n",vol);
710 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
711 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: "
712 "%s\n",DXGetErrorString8(rc));
713 ok(pan==0,"wrong pan for a new secondary buffer: %d\n",pan);
715 /* Check that changing the secondary buffer's volume and pan
716 * does not impact the primary buffer's volume and pan
718 rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
719 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "
720 "%s\n",DXGetErrorString8(rc));
721 rc=IDirectSoundBuffer_GetPan(primary,&refpan);
722 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
723 "%s\n",DXGetErrorString8(rc));
725 rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
726 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
727 "%s\n",DXGetErrorString8(rc));
728 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
729 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
730 "%s\n",DXGetErrorString8(rc));
731 ok(vol==-1000,"secondary: wrong volume %d instead of -1000\n",
733 rc=IDirectSoundBuffer_SetPan(secondary,-1000);
734 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
735 "%s\n",DXGetErrorString8(rc));
736 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
737 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
738 "%s\n",DXGetErrorString8(rc));
739 ok(pan==-1000,"secondary: wrong pan %d instead of -1000\n",
742 rc=IDirectSoundBuffer_GetVolume(primary,&vol);
743 ok(rc==DS_OK,"IDirectSoundBuffer_`GetVolume(primary) failed: i"
744 "%s\n",DXGetErrorString8(rc));
745 ok(vol==refvol,"The primary volume changed from %d to %d\n",
747 rc=IDirectSoundBuffer_GetPan(primary,&pan);
748 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
749 "%s\n",DXGetErrorString8(rc));
750 ok(pan==refpan,"The primary pan changed from %d to %d\n",
753 rc=IDirectSoundBuffer_SetVolume(secondary,0);
754 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
755 "%s\n",DXGetErrorString8(rc));
756 rc=IDirectSoundBuffer_SetPan(secondary,0);
757 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
758 "%s\n",DXGetErrorString8(rc));
761 LPDIRECTSOUNDBUFFER duplicated=NULL;
763 /* DSOUND: Error: Invalid source buffer */
764 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,0);
765 ok(rc==DSERR_INVALIDPARAM,
766 "IDirectSound8_DuplicateSoundBuffer() should have returned "
767 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
769 /* DSOUND: Error: Invalid dest buffer */
770 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,0);
771 ok(rc==DSERR_INVALIDPARAM,
772 "IDirectSound8_DuplicateSoundBuffer() should have returned "
773 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
775 /* DSOUND: Error: Invalid source buffer */
776 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,&duplicated);
777 ok(rc==DSERR_INVALIDPARAM,
778 "IDirectSound8_DuplicateSoundBuffer() should have returned "
779 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
782 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,
784 ok(rc==DS_OK && duplicated!=NULL,
785 "IDirectSound8_DuplicateSoundBuffer() failed to duplicate "
786 "a secondary buffer: %s\n",DXGetErrorString8(rc));
788 if (rc==DS_OK && duplicated!=NULL) {
789 ref=IDirectSoundBuffer_Release(secondary);
790 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
791 "references, should have 0\n",ref);
792 secondary=duplicated;
796 if (rc==DS_OK && secondary!=NULL) {
798 duration=(move_listener || move_sound?4.0:1.0);
799 test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
800 winetest_interactive,duration,has_3dbuffer,
801 listener,move_listener,move_sound);
802 ref=IDirectSoundBuffer_Release(secondary);
803 ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
804 "should have 0\n",has_duplicate?"duplicated":"secondary",
810 ref=IDirectSound3DListener_Release(listener);
811 ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
812 "references, should have 0\n",ref);
814 ref=IDirectSoundBuffer_Release(primary);
815 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
816 "should have 0\n",ref);
819 ok(primary==NULL,"IDirectSound8_CreateSoundBuffer(primary) failed "
820 "but primary created anyway\n");
821 ok(rc!=DS_OK,"IDirectSound8_CreateSoundBuffer(primary) succeeded "
822 "but primary not created\n");
824 ref=IDirectSoundBuffer_Release(primary);
825 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
826 "should have 0\n",ref);
830 /* Set the CooperativeLevel back to normal */
831 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
832 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
833 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
834 "%s\n",DXGetErrorString8(rc));
837 ref=IDirectSound8_Release(dso);
838 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
840 return DSERR_GENERIC;
845 static HRESULT test_for_driver8(LPGUID lpGuid)
848 LPDIRECTSOUND8 dso=NULL;
851 /* Create the DirectSound object */
852 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
853 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
854 "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
858 ref=IDirectSound8_Release(dso);
859 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
861 return DSERR_GENERIC;
866 static HRESULT test_primary8(LPGUID lpGuid)
869 LPDIRECTSOUND8 dso=NULL;
870 LPDIRECTSOUNDBUFFER primary=NULL;
871 DSBUFFERDESC bufdesc;
875 /* Create the DirectSound object */
876 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
877 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
878 DXGetErrorString8(rc));
882 /* Get the device capabilities */
883 ZeroMemory(&dscaps, sizeof(dscaps));
884 dscaps.dwSize=sizeof(dscaps);
885 rc=IDirectSound8_GetCaps(dso,&dscaps);
886 ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
890 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
891 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
892 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
893 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
894 "%s\n",DXGetErrorString8(rc));
898 /* Testing the primary buffer */
900 ZeroMemory(&bufdesc, sizeof(bufdesc));
901 bufdesc.dwSize=sizeof(bufdesc);
902 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN;
903 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
904 ok((rc==DS_OK && primary!=NULL) || (rc == DSERR_CONTROLUNAVAIL),
905 "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
906 "%s\n",DXGetErrorString8(rc));
907 if (rc == DSERR_CONTROLUNAVAIL)
908 trace(" No Primary\n");
909 else if (rc==DS_OK && primary!=NULL) {
910 test_buffer8(dso,&primary,1,TRUE,0,TRUE,0,winetest_interactive &&
911 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
912 if (winetest_interactive) {
915 volume = DSBVOLUME_MAX;
916 for (i = 0; i < 6; i++) {
917 test_buffer8(dso,&primary,1,TRUE,volume,TRUE,0,
918 winetest_interactive &&
919 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
921 volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
925 for (i = 0; i < 7; i++) {
926 test_buffer8(dso,&primary,1,TRUE,0,TRUE,pan,
927 winetest_interactive &&
928 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
929 pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
932 ref=IDirectSoundBuffer_Release(primary);
933 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
934 "should have 0\n",ref);
937 /* Set the CooperativeLevel back to normal */
938 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
939 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
940 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
941 "%s\n",DXGetErrorString8(rc));
944 ref=IDirectSound8_Release(dso);
945 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
947 return DSERR_GENERIC;
952 static HRESULT test_primary_3d8(LPGUID lpGuid)
955 LPDIRECTSOUND8 dso=NULL;
956 LPDIRECTSOUNDBUFFER primary=NULL;
957 DSBUFFERDESC bufdesc;
961 /* Create the DirectSound object */
962 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
963 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
964 DXGetErrorString8(rc));
968 /* Get the device capabilities */
969 ZeroMemory(&dscaps, sizeof(dscaps));
970 dscaps.dwSize=sizeof(dscaps);
971 rc=IDirectSound8_GetCaps(dso,&dscaps);
972 ok(rc==DS_OK,"IDirectSound8_GetCaps failed: %s\n",DXGetErrorString8(rc));
976 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
977 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
978 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
979 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
980 "%s\n",DXGetErrorString8(rc));
985 ZeroMemory(&bufdesc, sizeof(bufdesc));
986 bufdesc.dwSize=sizeof(bufdesc);
987 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
988 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
989 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() failed "
990 "to create a primary buffer: %s\n",DXGetErrorString8(rc));
991 if (rc==DS_OK && primary!=NULL) {
992 ref=IDirectSoundBuffer_Release(primary);
993 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
994 "should have 0\n",ref);
996 ZeroMemory(&bufdesc, sizeof(bufdesc));
997 bufdesc.dwSize=sizeof(bufdesc);
998 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
999 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1000 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() "
1001 "failed to create a 3D primary buffer: %s\n",DXGetErrorString8(rc));
1002 if (rc==DS_OK && primary!=NULL) {
1003 test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,
1004 winetest_interactive &&
1005 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
1006 ref=IDirectSoundBuffer_Release(primary);
1007 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1008 "should have 0\n",ref);
1011 /* Set the CooperativeLevel back to normal */
1012 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
1013 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
1014 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
1015 "%s\n",DXGetErrorString8(rc));
1018 ref=IDirectSound8_Release(dso);
1019 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
1021 return DSERR_GENERIC;
1026 static HRESULT test_primary_3d_with_listener8(LPGUID lpGuid)
1029 LPDIRECTSOUND8 dso=NULL;
1030 LPDIRECTSOUNDBUFFER primary=NULL;
1031 DSBUFFERDESC bufdesc;
1035 /* Create the DirectSound object */
1036 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
1037 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
1038 DXGetErrorString8(rc));
1042 /* Get the device capabilities */
1043 ZeroMemory(&dscaps, sizeof(dscaps));
1044 dscaps.dwSize=sizeof(dscaps);
1045 rc=IDirectSound8_GetCaps(dso,&dscaps);
1046 ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
1050 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
1051 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
1052 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
1053 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
1054 "%s\n",DXGetErrorString8(rc));
1058 ZeroMemory(&bufdesc, sizeof(bufdesc));
1059 bufdesc.dwSize=sizeof(bufdesc);
1060 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
1061 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1062 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() failed "
1063 "to create a 3D primary buffer %s\n",DXGetErrorString8(rc));
1064 if (rc==DS_OK && primary!=NULL) {
1065 LPDIRECTSOUND3DLISTENER listener=NULL;
1066 rc=IDirectSoundBuffer_QueryInterface(primary,
1067 &IID_IDirectSound3DListener,
1068 (void **)&listener);
1069 ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface() "
1070 "failed to get a 3D listener: %s\n",DXGetErrorString8(rc));
1071 if (rc==DS_OK && listener!=NULL) {
1072 LPDIRECTSOUNDBUFFER temp_buffer=NULL;
1074 /* Checking the COM interface */
1075 rc=IDirectSoundBuffer_QueryInterface(primary,
1076 &IID_IDirectSoundBuffer,
1077 (LPVOID *)&temp_buffer);
1078 ok(rc==DS_OK && temp_buffer!=NULL,
1079 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1080 DXGetErrorString8(rc));
1081 ok(temp_buffer==primary,"COM interface broken: %p != %p\n",temp_buffer,primary);
1082 if (rc==DS_OK && temp_buffer!=NULL) {
1083 ref=IDirectSoundBuffer_Release(temp_buffer);
1084 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1085 "should have 1\n",ref);
1088 rc=IDirectSound3DListener_QueryInterface(listener,
1089 &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
1090 ok(rc==DS_OK && temp_buffer!=NULL,
1091 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1092 DXGetErrorString8(rc));
1093 ok(temp_buffer==primary,"COM interface broken: %p != %p\n",temp_buffer,primary);
1094 ref=IDirectSoundBuffer_Release(temp_buffer);
1095 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1096 "should have 1\n",ref);
1098 /* Testing the buffer */
1099 test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,
1100 winetest_interactive &&
1101 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
1102 1.0,0,listener,0,0);
1105 /* Testing the reference counting */
1106 ref=IDirectSound3DListener_Release(listener);
1107 ok(ref==0,"IDirectSound3DListener_Release() listener has %d "
1108 "references, should have 0\n",ref);
1111 /* Testing the reference counting */
1112 ref=IDirectSoundBuffer_Release(primary);
1113 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1114 "should have 0\n",ref);
1118 ref=IDirectSound8_Release(dso);
1119 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
1121 return DSERR_GENERIC;
1126 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
1127 LPCSTR lpcstrModule, LPVOID lpContext)
1130 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
1132 rc = test_for_driver8(lpGuid);
1133 if (rc == DSERR_NODRIVER) {
1134 trace(" No Driver\n");
1136 } else if (rc == DSERR_ALLOCATED) {
1137 trace(" Already In Use\n");
1139 } else if (rc == E_FAIL) {
1140 trace(" No Device\n");
1144 trace(" Testing the primary buffer\n");
1145 test_primary8(lpGuid);
1147 trace(" Testing 3D primary buffer\n");
1148 test_primary_3d8(lpGuid);
1150 trace(" Testing 3D primary buffer with listener\n");
1151 test_primary_3d_with_listener8(lpGuid);
1153 /* Testing secondary buffers */
1154 test_secondary8(lpGuid,winetest_interactive,0,0,0,0,0,0);
1155 test_secondary8(lpGuid,winetest_interactive,0,0,0,1,0,0);
1157 /* Testing 3D secondary buffers */
1158 test_secondary8(lpGuid,winetest_interactive,1,0,0,0,0,0);
1159 test_secondary8(lpGuid,winetest_interactive,1,1,0,0,0,0);
1160 test_secondary8(lpGuid,winetest_interactive,1,1,0,1,0,0);
1161 test_secondary8(lpGuid,winetest_interactive,1,0,1,0,0,0);
1162 test_secondary8(lpGuid,winetest_interactive,1,0,1,1,0,0);
1163 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,0);
1164 test_secondary8(lpGuid,winetest_interactive,1,1,1,1,0,0);
1165 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,0);
1166 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,1);
1167 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,1);
1172 static void ds3d8_tests(void)
1175 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
1176 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
1185 hDsound = LoadLibrary("dsound.dll");
1188 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
1190 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
1191 "DirectSoundEnumerateA");
1192 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
1193 "DirectSoundCreate8");
1194 if (pDirectSoundCreate8)
1197 skip("ds3d8 test skipped\n");
1199 FreeLibrary(hDsound);
1202 skip("dsound.dll not found!\n");