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);
310 dsbcaps.dwBufferBytes = new_dsbcaps.dwBufferBytes;
312 /* Check for primary buffer flags change */
313 ok(new_dsbcaps.dwFlags == dsbcaps.dwFlags,
314 " flags changed after SetFormat() - "
315 "previous flags were %08x, current flags are %08x\n",
316 dsbcaps.dwFlags, new_dsbcaps.dwFlags);
318 /* Set the CooperativeLevel back to normal */
319 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
320 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
321 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
322 "failed: %s\n",DXGetErrorString8(rc));
327 DS3DLISTENER listener_param;
328 LPDIRECTSOUND3DBUFFER buffer=NULL;
329 DS3DBUFFER buffer_param;
330 DWORD start_time,now;
334 if (winetest_interactive) {
335 trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration,
336 wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
340 /* We must call SetCooperativeLevel to be allowed to call Lock */
341 /* DSOUND: Setting DirectSound cooperative level to
342 * DSSCL_WRITEPRIMARY */
343 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),
346 "IDirectSound8_SetCooperativeLevel(DSSCL_WRITEPRIMARY) failed: "
347 "%s\n",DXGetErrorString8(rc));
352 LPDIRECTSOUNDBUFFER temp_buffer;
354 rc=IDirectSoundBuffer_QueryInterface(*dsbo,&IID_IDirectSound3DBuffer,
356 ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %s\n",
357 DXGetErrorString8(rc));
361 /* check the COM interface */
362 rc=IDirectSoundBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
363 (LPVOID *)&temp_buffer);
364 ok(rc==DS_OK && temp_buffer!=NULL,
365 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
366 DXGetErrorString8(rc));
367 ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
369 ref=IDirectSoundBuffer_Release(temp_buffer);
370 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
371 "should have 1\n",ref);
374 rc=IDirectSound3DBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
375 (LPVOID *)&temp_buffer);
376 ok(rc==DS_OK && temp_buffer!=NULL,
377 "IDirectSound3DBuffer_QueryInterface() failed: %s\n",
378 DXGetErrorString8(rc));
379 ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
381 ref=IDirectSoundBuffer_Release(temp_buffer);
382 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
383 "should have 1\n",ref);
385 ref=IDirectSoundBuffer_Release(*dsbo);
386 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
387 "should have 0\n",ref);
389 rc=IDirectSound3DBuffer_QueryInterface(buffer,
390 &IID_IDirectSoundBuffer,
392 ok(rc==DS_OK && *dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
393 "failed: %s\n",DXGetErrorString8(rc));
395 /* DSOUND: Error: Invalid buffer */
396 rc=IDirectSound3DBuffer_GetAllParameters(buffer,0);
397 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
398 "failed: %s\n",DXGetErrorString8(rc));
400 ZeroMemory(&buffer_param, sizeof(buffer_param));
402 /* DSOUND: Error: Invalid buffer */
403 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
404 ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
405 "failed: %s\n",DXGetErrorString8(rc));
407 buffer_param.dwSize=sizeof(buffer_param);
408 rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
409 ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %s\n",
410 DXGetErrorString8(rc));
413 if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
415 rc=IDirectSoundBuffer_GetVolume(*dsbo,&val);
416 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
417 DXGetErrorString8(rc));
419 rc=IDirectSoundBuffer_SetVolume(*dsbo,volume);
420 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %s\n",
421 DXGetErrorString8(rc));
423 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
424 rc=IDirectSoundBuffer_GetVolume(*dsbo,&volume);
425 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
426 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
427 DXGetErrorString8(rc));
432 if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
434 rc=IDirectSoundBuffer_GetPan(*dsbo,&val);
435 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %s\n",
436 DXGetErrorString8(rc));
438 rc=IDirectSoundBuffer_SetPan(*dsbo,pan);
439 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %s\n",
440 DXGetErrorString8(rc));
442 /* DSOUND: Error: Buffer does not have CTRLPAN */
443 rc=IDirectSoundBuffer_GetPan(*dsbo,&pan);
444 ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
445 "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n",
446 DXGetErrorString8(rc));
450 /* try an offset past the end of the buffer */
451 rc = IDirectSoundBuffer_Lock(*dsbo, dsbcaps.dwBufferBytes, 0, &buffer1,
452 &length1, NULL, NULL,
453 DSBLOCK_ENTIREBUFFER);
454 ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
455 "returned DSERR_INVALIDPARAM, returned %s\n", DXGetErrorString8(rc));
457 /* try a size larger than the buffer */
458 rc = IDirectSoundBuffer_Lock(*dsbo, 0, dsbcaps.dwBufferBytes + 1,
459 &buffer1, &length1, NULL, NULL,
460 DSBLOCK_FROMWRITECURSOR);
461 ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
462 "returned DSERR_INVALIDPARAM, returned %s\n", DXGetErrorString8(rc));
464 state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
468 state.buffer_size=dsbcaps.dwBufferBytes;
469 state.played=state.written=state.offset=0;
470 buffer_refill8(&state,state.buffer_size);
472 rc=IDirectSoundBuffer_Play(*dsbo,0,0,DSBPLAY_LOOPING);
473 ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %s\n",
474 DXGetErrorString8(rc));
476 rc=IDirectSoundBuffer_GetStatus(*dsbo,&status);
477 ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n",
478 DXGetErrorString8(rc));
479 ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING),
480 "GetStatus: bad status: %x\n",status);
483 ZeroMemory(&listener_param,sizeof(listener_param));
484 listener_param.dwSize=sizeof(listener_param);
485 rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
486 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
487 "failed: %s\n",DXGetErrorString8(rc));
489 listener_param.vPosition.x = -5.0f;
490 listener_param.vVelocity.x = (float)(10.0/duration);
492 rc=IDirectSound3DListener_SetAllParameters(listener,
495 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %s\n",
496 DXGetErrorString8(rc));
500 buffer_param.vPosition.x = 100.0f;
501 buffer_param.vVelocity.x = (float)(-200.0/duration);
503 buffer_param.flMinDistance = 10;
504 rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,
506 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
507 DXGetErrorString8(rc));
510 start_time=GetTickCount();
511 while (buffer_service8(&state)) {
512 WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
514 if (listener && move_listener) {
515 listener_param.vPosition.x = (float)(-5.0+10.0*(now-start_time)/1000/duration);
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 = (float)(100-200.0*(now-start_time)/1000/duration);
526 if (winetest_debug>2)
527 trace("sound position=%g\n",buffer_param.vPosition.x);
528 rc=IDirectSound3DBuffer_SetPosition(buffer,
529 buffer_param.vPosition.x,buffer_param.vPosition.y,
530 buffer_param.vPosition.z,DS3D_IMMEDIATE);
531 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n",
532 DXGetErrorString8(rc));
535 /* Check the sound duration was within 10% of the expected value */
537 ok(fabs(1000*duration-now+start_time)<=100*duration,
538 "The sound played for %d ms instead of %g ms\n",
539 now-start_time,1000*duration);
543 /* Set the CooperativeLevel back to normal */
544 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
545 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
546 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
547 "failed: %s\n",DXGetErrorString8(rc));
550 ref=IDirectSound3DBuffer_Release(buffer);
551 ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
552 "should have 0\n",ref);
557 static HRESULT test_secondary8(LPGUID lpGuid, int play,
558 int has_3d, int has_3dbuffer,
559 int has_listener, int has_duplicate,
560 int move_listener, int move_sound)
563 LPDIRECTSOUND8 dso=NULL;
564 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
565 LPDIRECTSOUND3DLISTENER listener=NULL;
566 DSBUFFERDESC bufdesc;
567 WAVEFORMATEX wfx, wfx1;
570 /* Create the DirectSound object */
571 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
572 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
573 DXGetErrorString8(rc));
577 /* We must call SetCooperativeLevel before creating primary buffer */
578 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
579 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
580 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
581 "%s\n",DXGetErrorString8(rc));
585 ZeroMemory(&bufdesc, sizeof(bufdesc));
586 bufdesc.dwSize=sizeof(bufdesc);
587 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
589 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
591 bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
592 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
593 ok((rc==DS_OK && primary!=NULL) || (rc == DSERR_CONTROLUNAVAIL),
594 "IDirectSound8_CreateSoundBuffer() failed to create a %sprimary buffer: "
595 "%s\n",has_3d?"3D ":"", DXGetErrorString8(rc));
596 if (rc == DSERR_CONTROLUNAVAIL)
597 trace(" No Primary\n");
598 else if (rc==DS_OK && primary!=NULL) {
599 rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
600 ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
601 DXGetErrorString8(rc));
606 rc=IDirectSoundBuffer_QueryInterface(primary,
607 &IID_IDirectSound3DListener,
609 ok(rc==DS_OK && listener!=NULL,
610 "IDirectSoundBuffer_QueryInterface() failed to get a 3D "
611 "listener %s\n",DXGetErrorString8(rc));
612 ref=IDirectSoundBuffer_Release(primary);
613 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
614 "should have 0\n",ref);
615 if (rc==DS_OK && listener!=NULL) {
616 DS3DLISTENER listener_param;
617 ZeroMemory(&listener_param,sizeof(listener_param));
618 /* DSOUND: Error: Invalid buffer */
619 rc=IDirectSound3DListener_GetAllParameters(listener,0);
620 ok(rc==DSERR_INVALIDPARAM,
621 "IDirectSound3dListener_GetAllParameters() should have "
622 "returned DSERR_INVALIDPARAM, returned: %s\n",
623 DXGetErrorString8(rc));
625 /* DSOUND: Error: Invalid buffer */
626 rc=IDirectSound3DListener_GetAllParameters(listener,
628 ok(rc==DSERR_INVALIDPARAM,
629 "IDirectSound3dListener_GetAllParameters() should have "
630 "returned DSERR_INVALIDPARAM, returned: %s\n",
631 DXGetErrorString8(rc));
633 listener_param.dwSize=sizeof(listener_param);
634 rc=IDirectSound3DListener_GetAllParameters(listener,
636 ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
637 "failed: %s\n",DXGetErrorString8(rc));
639 ok(listener==NULL, "IDirectSoundBuffer_QueryInterface() "
640 "failed but returned a listener anyway\n");
641 ok(rc!=DS_OK, "IDirectSoundBuffer_QueryInterface() succeeded "
642 "but returned a NULL listener\n");
644 ref=IDirectSound3DListener_Release(listener);
645 ok(ref==0,"IDirectSound3dListener_Release() listener has "
646 "%d references, should have 0\n",ref);
652 init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
654 ZeroMemory(&bufdesc, sizeof(bufdesc));
655 bufdesc.dwSize=sizeof(bufdesc);
656 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
658 bufdesc.dwFlags|=DSBCAPS_CTRL3D;
661 (DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
662 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
664 bufdesc.lpwfxFormat=&wfx;
666 /* a stereo 3D buffer should fail */
667 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
668 ok(rc==DSERR_INVALIDPARAM,
669 "IDirectSound8_CreateSoundBuffer(secondary) should have "
670 "returned DSERR_INVALIDPARAM, returned %s\n",
671 DXGetErrorString8(rc));
673 ref=IDirectSoundBuffer_Release(secondary);
674 init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
677 if (winetest_interactive) {
678 trace(" Testing a %s%ssecondary buffer %s%s%s%sat %dx%dx%d "
679 "with a primary buffer at %dx%dx%d\n",
680 has_3dbuffer?"3D ":"",
681 has_duplicate?"duplicated ":"",
682 listener!=NULL||move_sound?"with ":"",
683 move_listener?"moving ":"",
684 listener!=NULL?"listener ":"",
685 listener&&move_sound?"and moving sound ":move_sound?
687 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
688 wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
690 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
691 ok(rc==DS_OK && secondary!=NULL,"IDirectSound8_CreateSoundBuffer() "
692 "failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %s\n",
693 has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
694 listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
695 listener!=NULL?"listener ":"",
696 listener&&move_sound?"and moving sound ":move_sound?
698 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
699 getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
700 if (rc==DS_OK && secondary!=NULL) {
702 LONG refvol,vol,refpan,pan;
704 /* Check the initial secondary buffer's volume and pan */
705 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
706 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: "
707 "%s\n",DXGetErrorString8(rc));
708 ok(vol==0,"wrong volume for a new secondary buffer: %d\n",vol);
709 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
710 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: "
711 "%s\n",DXGetErrorString8(rc));
712 ok(pan==0,"wrong pan for a new secondary buffer: %d\n",pan);
714 /* Check that changing the secondary buffer's volume and pan
715 * does not impact the primary buffer's volume and pan
717 rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
718 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "
719 "%s\n",DXGetErrorString8(rc));
720 rc=IDirectSoundBuffer_GetPan(primary,&refpan);
721 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
722 "%s\n",DXGetErrorString8(rc));
724 rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
725 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
726 "%s\n",DXGetErrorString8(rc));
727 rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
728 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
729 "%s\n",DXGetErrorString8(rc));
730 ok(vol==-1000,"secondary: wrong volume %d instead of -1000\n",
732 rc=IDirectSoundBuffer_SetPan(secondary,-1000);
733 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
734 "%s\n",DXGetErrorString8(rc));
735 rc=IDirectSoundBuffer_GetPan(secondary,&pan);
736 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
737 "%s\n",DXGetErrorString8(rc));
738 ok(pan==-1000,"secondary: wrong pan %d instead of -1000\n",
741 rc=IDirectSoundBuffer_GetVolume(primary,&vol);
742 ok(rc==DS_OK,"IDirectSoundBuffer_`GetVolume(primary) failed: i"
743 "%s\n",DXGetErrorString8(rc));
744 ok(vol==refvol,"The primary volume changed from %d to %d\n",
746 rc=IDirectSoundBuffer_GetPan(primary,&pan);
747 ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
748 "%s\n",DXGetErrorString8(rc));
749 ok(pan==refpan,"The primary pan changed from %d to %d\n",
752 rc=IDirectSoundBuffer_SetVolume(secondary,0);
753 ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
754 "%s\n",DXGetErrorString8(rc));
755 rc=IDirectSoundBuffer_SetPan(secondary,0);
756 ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
757 "%s\n",DXGetErrorString8(rc));
760 LPDIRECTSOUNDBUFFER duplicated=NULL;
762 /* DSOUND: Error: Invalid source buffer */
763 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,0);
764 ok(rc==DSERR_INVALIDPARAM,
765 "IDirectSound8_DuplicateSoundBuffer() should have returned "
766 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
768 /* DSOUND: Error: Invalid dest buffer */
769 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,0);
770 ok(rc==DSERR_INVALIDPARAM,
771 "IDirectSound8_DuplicateSoundBuffer() should have returned "
772 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
774 /* DSOUND: Error: Invalid source buffer */
775 rc=IDirectSound8_DuplicateSoundBuffer(dso,0,&duplicated);
776 ok(rc==DSERR_INVALIDPARAM,
777 "IDirectSound8_DuplicateSoundBuffer() should have returned "
778 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
781 rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,
783 ok(rc==DS_OK && duplicated!=NULL,
784 "IDirectSound8_DuplicateSoundBuffer() failed to duplicate "
785 "a secondary buffer: %s\n",DXGetErrorString8(rc));
787 if (rc==DS_OK && duplicated!=NULL) {
788 ref=IDirectSoundBuffer_Release(secondary);
789 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
790 "references, should have 0\n",ref);
791 secondary=duplicated;
795 if (rc==DS_OK && secondary!=NULL) {
797 duration=(move_listener || move_sound?4.0:1.0);
798 test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
799 winetest_interactive,duration,has_3dbuffer,
800 listener,move_listener,move_sound);
801 ref=IDirectSoundBuffer_Release(secondary);
802 ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
803 "should have 0\n",has_duplicate?"duplicated":"secondary",
809 ref=IDirectSound3DListener_Release(listener);
810 ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
811 "references, should have 0\n",ref);
813 ref=IDirectSoundBuffer_Release(primary);
814 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
815 "should have 0\n",ref);
818 ok(primary==NULL,"IDirectSound8_CreateSoundBuffer(primary) failed "
819 "but primary created anyway\n");
820 ok(rc!=DS_OK,"IDirectSound8_CreateSoundBuffer(primary) succeeded "
821 "but primary not created\n");
823 ref=IDirectSoundBuffer_Release(primary);
824 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
825 "should have 0\n",ref);
829 /* Set the CooperativeLevel back to normal */
830 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
831 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
832 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
833 "%s\n",DXGetErrorString8(rc));
836 ref=IDirectSound8_Release(dso);
837 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
839 return DSERR_GENERIC;
844 static HRESULT test_for_driver8(LPGUID lpGuid)
847 LPDIRECTSOUND8 dso=NULL;
850 /* Create the DirectSound object */
851 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
852 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
853 "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
857 ref=IDirectSound8_Release(dso);
858 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
860 return DSERR_GENERIC;
865 static HRESULT test_primary8(LPGUID lpGuid)
868 LPDIRECTSOUND8 dso=NULL;
869 LPDIRECTSOUNDBUFFER primary=NULL;
870 DSBUFFERDESC bufdesc;
874 /* Create the DirectSound object */
875 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
876 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
877 DXGetErrorString8(rc));
881 /* Get the device capabilities */
882 ZeroMemory(&dscaps, sizeof(dscaps));
883 dscaps.dwSize=sizeof(dscaps);
884 rc=IDirectSound8_GetCaps(dso,&dscaps);
885 ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
889 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
890 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
891 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
892 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
893 "%s\n",DXGetErrorString8(rc));
897 /* Testing the primary buffer */
899 ZeroMemory(&bufdesc, sizeof(bufdesc));
900 bufdesc.dwSize=sizeof(bufdesc);
901 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN;
902 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
903 ok((rc==DS_OK && primary!=NULL) || (rc == DSERR_CONTROLUNAVAIL),
904 "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
905 "%s\n",DXGetErrorString8(rc));
906 if (rc == DSERR_CONTROLUNAVAIL)
907 trace(" No Primary\n");
908 else if (rc==DS_OK && primary!=NULL) {
909 test_buffer8(dso,&primary,1,TRUE,0,TRUE,0,winetest_interactive &&
910 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
911 if (winetest_interactive) {
914 volume = DSBVOLUME_MAX;
915 for (i = 0; i < 6; i++) {
916 test_buffer8(dso,&primary,1,TRUE,volume,TRUE,0,
917 winetest_interactive &&
918 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
920 volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
924 for (i = 0; i < 7; i++) {
925 test_buffer8(dso,&primary,1,TRUE,0,TRUE,pan,
926 winetest_interactive &&
927 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
928 pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
931 ref=IDirectSoundBuffer_Release(primary);
932 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
933 "should have 0\n",ref);
936 /* Set the CooperativeLevel back to normal */
937 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
938 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
939 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
940 "%s\n",DXGetErrorString8(rc));
943 ref=IDirectSound8_Release(dso);
944 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
946 return DSERR_GENERIC;
951 static HRESULT test_primary_3d8(LPGUID lpGuid)
954 LPDIRECTSOUND8 dso=NULL;
955 LPDIRECTSOUNDBUFFER primary=NULL;
956 DSBUFFERDESC bufdesc;
960 /* Create the DirectSound object */
961 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
962 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
963 DXGetErrorString8(rc));
967 /* Get the device capabilities */
968 ZeroMemory(&dscaps, sizeof(dscaps));
969 dscaps.dwSize=sizeof(dscaps);
970 rc=IDirectSound8_GetCaps(dso,&dscaps);
971 ok(rc==DS_OK,"IDirectSound8_GetCaps failed: %s\n",DXGetErrorString8(rc));
975 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
976 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
977 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
978 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
979 "%s\n",DXGetErrorString8(rc));
984 ZeroMemory(&bufdesc, sizeof(bufdesc));
985 bufdesc.dwSize=sizeof(bufdesc);
986 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
987 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
988 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() failed "
989 "to create a primary buffer: %s\n",DXGetErrorString8(rc));
990 if (rc==DS_OK && primary!=NULL) {
991 ref=IDirectSoundBuffer_Release(primary);
992 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
993 "should have 0\n",ref);
995 ZeroMemory(&bufdesc, sizeof(bufdesc));
996 bufdesc.dwSize=sizeof(bufdesc);
997 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
998 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
999 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() "
1000 "failed to create a 3D primary buffer: %s\n",DXGetErrorString8(rc));
1001 if (rc==DS_OK && primary!=NULL) {
1002 test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,
1003 winetest_interactive &&
1004 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
1005 ref=IDirectSoundBuffer_Release(primary);
1006 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1007 "should have 0\n",ref);
1010 /* Set the CooperativeLevel back to normal */
1011 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
1012 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
1013 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: "
1014 "%s\n",DXGetErrorString8(rc));
1017 ref=IDirectSound8_Release(dso);
1018 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
1020 return DSERR_GENERIC;
1025 static HRESULT test_primary_3d_with_listener8(LPGUID lpGuid)
1028 LPDIRECTSOUND8 dso=NULL;
1029 LPDIRECTSOUNDBUFFER primary=NULL;
1030 DSBUFFERDESC bufdesc;
1034 /* Create the DirectSound object */
1035 rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
1036 ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %s\n",
1037 DXGetErrorString8(rc));
1041 /* Get the device capabilities */
1042 ZeroMemory(&dscaps, sizeof(dscaps));
1043 dscaps.dwSize=sizeof(dscaps);
1044 rc=IDirectSound8_GetCaps(dso,&dscaps);
1045 ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
1049 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
1050 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
1051 rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
1052 ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: "
1053 "%s\n",DXGetErrorString8(rc));
1057 ZeroMemory(&bufdesc, sizeof(bufdesc));
1058 bufdesc.dwSize=sizeof(bufdesc);
1059 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
1060 rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
1061 ok(rc==DS_OK && primary!=NULL,"IDirectSound8_CreateSoundBuffer() failed "
1062 "to create a 3D primary buffer %s\n",DXGetErrorString8(rc));
1063 if (rc==DS_OK && primary!=NULL) {
1064 LPDIRECTSOUND3DLISTENER listener=NULL;
1065 rc=IDirectSoundBuffer_QueryInterface(primary,
1066 &IID_IDirectSound3DListener,
1067 (void **)&listener);
1068 ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface() "
1069 "failed to get a 3D listener: %s\n",DXGetErrorString8(rc));
1070 if (rc==DS_OK && listener!=NULL) {
1071 LPDIRECTSOUNDBUFFER temp_buffer=NULL;
1073 /* Checking the COM interface */
1074 rc=IDirectSoundBuffer_QueryInterface(primary,
1075 &IID_IDirectSoundBuffer,
1076 (LPVOID *)&temp_buffer);
1077 ok(rc==DS_OK && temp_buffer!=NULL,
1078 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1079 DXGetErrorString8(rc));
1080 ok(temp_buffer==primary,"COM interface broken: %p != %p\n",temp_buffer,primary);
1081 if (rc==DS_OK && temp_buffer!=NULL) {
1082 ref=IDirectSoundBuffer_Release(temp_buffer);
1083 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1084 "should have 1\n",ref);
1087 rc=IDirectSound3DListener_QueryInterface(listener,
1088 &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
1089 ok(rc==DS_OK && temp_buffer!=NULL,
1090 "IDirectSoundBuffer_QueryInterface() failed: %s\n",
1091 DXGetErrorString8(rc));
1092 ok(temp_buffer==primary,"COM interface broken: %p != %p\n",temp_buffer,primary);
1093 ref=IDirectSoundBuffer_Release(temp_buffer);
1094 ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
1095 "should have 1\n",ref);
1097 /* Testing the buffer */
1098 test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,
1099 winetest_interactive &&
1100 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
1101 1.0,0,listener,0,0);
1104 /* Testing the reference counting */
1105 ref=IDirectSound3DListener_Release(listener);
1106 ok(ref==0,"IDirectSound3DListener_Release() listener has %d "
1107 "references, should have 0\n",ref);
1110 /* Testing the reference counting */
1111 ref=IDirectSoundBuffer_Release(primary);
1112 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1113 "should have 0\n",ref);
1117 ref=IDirectSound8_Release(dso);
1118 ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
1120 return DSERR_GENERIC;
1125 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
1126 LPCSTR lpcstrModule, LPVOID lpContext)
1129 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
1131 rc = test_for_driver8(lpGuid);
1132 if (rc == DSERR_NODRIVER) {
1133 trace(" No Driver\n");
1135 } else if (rc == DSERR_ALLOCATED) {
1136 trace(" Already In Use\n");
1138 } else if (rc == E_FAIL) {
1139 trace(" No Device\n");
1143 trace(" Testing the primary buffer\n");
1144 test_primary8(lpGuid);
1146 trace(" Testing 3D primary buffer\n");
1147 test_primary_3d8(lpGuid);
1149 trace(" Testing 3D primary buffer with listener\n");
1150 test_primary_3d_with_listener8(lpGuid);
1152 /* Testing secondary buffers */
1153 test_secondary8(lpGuid,winetest_interactive,0,0,0,0,0,0);
1154 test_secondary8(lpGuid,winetest_interactive,0,0,0,1,0,0);
1156 /* Testing 3D secondary buffers */
1157 test_secondary8(lpGuid,winetest_interactive,1,0,0,0,0,0);
1158 test_secondary8(lpGuid,winetest_interactive,1,1,0,0,0,0);
1159 test_secondary8(lpGuid,winetest_interactive,1,1,0,1,0,0);
1160 test_secondary8(lpGuid,winetest_interactive,1,0,1,0,0,0);
1161 test_secondary8(lpGuid,winetest_interactive,1,0,1,1,0,0);
1162 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,0);
1163 test_secondary8(lpGuid,winetest_interactive,1,1,1,1,0,0);
1164 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,0);
1165 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,0,1);
1166 test_secondary8(lpGuid,winetest_interactive,1,1,1,0,1,1);
1171 static void ds3d8_tests(void)
1174 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
1175 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
1184 hDsound = LoadLibrary("dsound.dll");
1187 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
1189 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
1190 "DirectSoundEnumerateA");
1191 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
1192 "DirectSoundCreate8");
1193 if (pDirectSoundCreate8)
1196 skip("ds3d8 test skipped\n");
1198 FreeLibrary(hDsound);
1201 skip("dsound.dll not found!\n");