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"
35 #include "dsound_test.h"
41 LPDIRECTSOUNDBUFFER dsbo
;
49 static int buffer_refill8(play_state_t
* state
, DWORD size
)
55 if (size
>state
->wave_len
-state
->written
)
56 size
=state
->wave_len
-state
->written
;
58 rc
=IDirectSoundBuffer_Lock(state
->dsbo
,state
->offset
,size
,
59 &ptr1
,&len1
,&ptr2
,&len2
,0);
60 ok(rc
==DS_OK
,"IDirectSoundBuffer_Lock() failed: %08x\n", rc
);
64 memcpy(ptr1
,state
->wave
+state
->written
,len1
);
67 memcpy(ptr2
,state
->wave
+state
->written
,len2
);
70 state
->offset
=state
->written
% state
->buffer_size
;
71 rc
=IDirectSoundBuffer_Unlock(state
->dsbo
,ptr1
,len1
,ptr2
,len2
);
72 ok(rc
==DS_OK
,"IDirectSoundBuffer_Unlock() failed: %08x\n", rc
);
78 static int buffer_silence8(play_state_t
* state
, DWORD size
)
85 rc
=IDirectSoundBuffer_Lock(state
->dsbo
,state
->offset
,size
,
86 &ptr1
,&len1
,&ptr2
,&len2
,0);
87 ok(rc
==DS_OK
,"IDirectSoundBuffer_Lock() failed: %08x\n", rc
);
91 s
=(state
->wfx
->wBitsPerSample
==8?0x80:0);
96 state
->offset
=(state
->offset
+size
) % state
->buffer_size
;
97 rc
=IDirectSoundBuffer_Unlock(state
->dsbo
,ptr1
,len1
,ptr2
,len2
);
98 ok(rc
==DS_OK
,"IDirectSoundBuffer_Unlock() failed: %08x\n", rc
);
104 static BOOL
buffer_service8(play_state_t
* state
)
106 DWORD last_play_pos
,play_pos
,buf_free
;
109 rc
=IDirectSoundBuffer_GetCurrentPosition(state
->dsbo
,&play_pos
,NULL
);
110 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetCurrentPosition() failed: %08x\n", rc
);
115 /* Update the amount played */
116 last_play_pos
=state
->played
% state
->buffer_size
;
117 if (play_pos
<last_play_pos
)
118 state
->played
+=state
->buffer_size
-last_play_pos
+play_pos
;
120 state
->played
+=play_pos
-last_play_pos
;
122 if (winetest_debug
> 1)
123 trace("buf size=%d last_play_pos=%d play_pos=%d played=%d / %d\n",
124 state
->buffer_size
,last_play_pos
,play_pos
,state
->played
,
127 if (state
->played
>state
->wave_len
)
129 /* Everything has been played */
133 /* Refill the buffer */
134 if (state
->offset
<=play_pos
)
135 buf_free
=play_pos
-state
->offset
;
137 buf_free
=state
->buffer_size
-state
->offset
+play_pos
;
139 if (winetest_debug
> 1)
140 trace("offset=%d free=%d written=%d / %d\n",
141 state
->offset
,buf_free
,state
->written
,state
->wave_len
);
145 if (state
->written
<state
->wave_len
)
147 int w
=buffer_refill8(state
,buf_free
);
151 if (state
->written
==state
->wave_len
&& winetest_debug
> 1)
152 trace("last sound byte at %d\n",
153 (state
->written
% state
->buffer_size
));
157 /* Fill with silence */
158 if (winetest_debug
> 1)
159 trace("writing %d bytes of silence\n",buf_free
);
160 if (buffer_silence8(state
,buf_free
)==-1)
166 if (winetest_debug
> 1)
167 trace("stopping playback\n");
168 rc
=IDirectSoundBuffer_Stop(state
->dsbo
);
169 ok(rc
==DS_OK
,"IDirectSoundBuffer_Stop() failed: %08x\n", rc
);
173 void test_buffer8(LPDIRECTSOUND8 dso
, LPDIRECTSOUNDBUFFER
* dsbo
,
174 BOOL is_primary
, BOOL set_volume
, LONG volume
,
175 BOOL set_pan
, LONG pan
, BOOL play
, double duration
,
176 BOOL buffer3d
, LPDIRECTSOUND3DLISTENER listener
,
177 BOOL move_listener
, BOOL move_sound
)
181 WAVEFORMATEX wfx
,wfx2
;
182 DWORD size
,status
,freq
;
186 /* DSOUND: Error: Invalid caps pointer */
187 rc
=IDirectSoundBuffer_GetCaps(*dsbo
,0);
188 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundBuffer_GetCaps() should have "
189 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc
);
191 ZeroMemory(&dsbcaps
, sizeof(dsbcaps
));
193 /* DSOUND: Error: Invalid caps pointer */
194 rc
=IDirectSoundBuffer_GetCaps(*dsbo
,&dsbcaps
);
195 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundBuffer_GetCaps() should have "
196 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc
);
198 dsbcaps
.dwSize
=sizeof(dsbcaps
);
199 rc
=IDirectSoundBuffer_GetCaps(*dsbo
,&dsbcaps
);
200 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc
);
201 if (rc
==DS_OK
&& winetest_debug
> 1) {
202 trace(" Caps: flags=0x%08x size=%d\n",dsbcaps
.dwFlags
,
203 dsbcaps
.dwBufferBytes
);
206 /* Query the format size. */
208 rc
=IDirectSoundBuffer_GetFormat(*dsbo
,NULL
,0,&size
);
209 ok(rc
==DS_OK
&& size
!=0,"IDirectSoundBuffer_GetFormat() should have "
210 "returned the needed size: rc=%08x size=%d\n",rc
,size
);
212 ok(size
== sizeof(WAVEFORMATEX
) || size
== sizeof(WAVEFORMATEXTENSIBLE
),
213 "Expected a correct structure size, got %d\n", size
);
215 if (size
== sizeof(WAVEFORMATEX
)) {
216 rc
=IDirectSoundBuffer_GetFormat(*dsbo
,&wfx
,size
,NULL
);
217 ieee
= (wfx
.wFormatTag
== WAVE_FORMAT_IEEE_FLOAT
);
218 } else if (size
== sizeof(WAVEFORMATEXTENSIBLE
)) {
219 WAVEFORMATEXTENSIBLE wfxe
;
220 rc
=IDirectSoundBuffer_GetFormat(*dsbo
,(WAVEFORMATEX
*)&wfxe
,size
,NULL
);
222 ieee
= IsEqualGUID(&wfxe
.SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
);
226 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc
);
227 if (rc
==DS_OK
&& winetest_debug
> 1) {
228 trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
229 is_primary
? "Primary" : "Secondary",
230 wfx
.wFormatTag
,wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,
231 wfx
.nChannels
,wfx
.nAvgBytesPerSec
,wfx
.nBlockAlign
);
234 /* DSOUND: Error: Invalid frequency buffer */
235 rc
=IDirectSoundBuffer_GetFrequency(*dsbo
,0);
236 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundBuffer_GetFrequency() should have "
237 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc
);
239 /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
240 rc
=IDirectSoundBuffer_GetFrequency(*dsbo
,&freq
);
241 ok((rc
==DS_OK
&& !is_primary
) || (rc
==DSERR_CONTROLUNAVAIL
&&is_primary
) ||
242 (rc
==DSERR_CONTROLUNAVAIL
&&!(dsbcaps
.dwFlags
&DSBCAPS_CTRLFREQUENCY
)),
243 "IDirectSoundBuffer_GetFrequency() failed: %08x\n",rc
);
245 ok(freq
==wfx
.nSamplesPerSec
,"The frequency returned by GetFrequency "
246 "%d does not match the format %d\n",freq
,wfx
.nSamplesPerSec
);
249 /* DSOUND: Error: Invalid status pointer */
250 rc
=IDirectSoundBuffer_GetStatus(*dsbo
,0);
251 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundBuffer_GetStatus() should have "
252 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc
);
254 rc
=IDirectSoundBuffer_GetStatus(*dsbo
,&status
);
255 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc
);
256 ok(status
==0,"status=0x%x instead of 0\n",status
);
260 /* We must call SetCooperativeLevel to be allowed to call SetFormat */
261 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
262 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
263 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) "
264 "failed: %08x\n",rc
);
268 /* DSOUND: Error: Invalid format pointer */
269 rc
=IDirectSoundBuffer_SetFormat(*dsbo
,0);
270 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundBuffer_SetFormat() should have "
271 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc
);
273 init_format(&wfx2
,WAVE_FORMAT_PCM
,11025,16,2);
274 rc
=IDirectSoundBuffer_SetFormat(*dsbo
,&wfx2
);
275 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
276 format_string(&wfx2
), rc
);
278 /* There is no guarantee that SetFormat will actually change the
279 * format to what we asked for. It depends on what the soundcard
280 * supports. So we must re-query the format.
282 rc
=IDirectSoundBuffer_GetFormat(*dsbo
,&wfx
,sizeof(wfx
),NULL
);
283 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc
);
285 (wfx
.wFormatTag
!=wfx2
.wFormatTag
||
286 wfx
.nSamplesPerSec
!=wfx2
.nSamplesPerSec
||
287 wfx
.wBitsPerSample
!=wfx2
.wBitsPerSample
||
288 wfx
.nChannels
!=wfx2
.nChannels
)) {
289 trace("Requested format tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
290 wfx2
.wFormatTag
,wfx2
.nSamplesPerSec
,wfx2
.wBitsPerSample
,
291 wfx2
.nChannels
,wfx2
.nAvgBytesPerSec
,wfx2
.nBlockAlign
);
292 trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
293 wfx
.wFormatTag
,wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,
294 wfx
.nChannels
,wfx
.nAvgBytesPerSec
,wfx
.nBlockAlign
);
297 ZeroMemory(&new_dsbcaps
, sizeof(new_dsbcaps
));
298 new_dsbcaps
.dwSize
= sizeof(new_dsbcaps
);
299 rc
=IDirectSoundBuffer_GetCaps(*dsbo
,&new_dsbcaps
);
300 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc
);
301 if (rc
==DS_OK
&& winetest_debug
> 1) {
302 trace(" new Caps: flags=0x%08x size=%d\n",new_dsbcaps
.dwFlags
,
303 new_dsbcaps
.dwBufferBytes
);
306 /* Check for primary buffer size change */
307 ok(new_dsbcaps
.dwBufferBytes
== dsbcaps
.dwBufferBytes
,
308 " buffer size changed after SetFormat() - "
309 "previous size was %u, current size is %u\n",
310 dsbcaps
.dwBufferBytes
, new_dsbcaps
.dwBufferBytes
);
311 dsbcaps
.dwBufferBytes
= new_dsbcaps
.dwBufferBytes
;
313 /* Check for primary buffer flags change */
314 ok(new_dsbcaps
.dwFlags
== dsbcaps
.dwFlags
,
315 " flags changed after SetFormat() - "
316 "previous flags were %08x, current flags are %08x\n",
317 dsbcaps
.dwFlags
, new_dsbcaps
.dwFlags
);
319 /* Set the CooperativeLevel back to normal */
320 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
321 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_NORMAL
);
322 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
323 "failed: %08x\n",rc
);
328 DS3DLISTENER listener_param
;
329 LPDIRECTSOUND3DBUFFER buffer
=NULL
;
330 DS3DBUFFER buffer_param
;
331 DWORD start_time
,now
;
335 if (winetest_interactive
) {
336 trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration
,
337 wfx
.nSamplesPerSec
, wfx
.wBitsPerSample
,wfx
.nChannels
);
341 /* We must call SetCooperativeLevel to be allowed to call Lock */
342 /* DSOUND: Setting DirectSound cooperative level to
343 * DSSCL_WRITEPRIMARY */
344 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),
347 "IDirectSound8_SetCooperativeLevel(DSSCL_WRITEPRIMARY) failed: %08x\n",rc
);
352 LPDIRECTSOUNDBUFFER temp_buffer
;
354 rc
=IDirectSoundBuffer_QueryInterface(*dsbo
,&IID_IDirectSound3DBuffer
,
356 ok(rc
==DS_OK
,"IDirectSoundBuffer_QueryInterface() failed: %08x\n", 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: %08x\n", rc
);
365 ok(temp_buffer
==*dsbo
,"COM interface broken: %p != %p\n",
367 ref
=IDirectSoundBuffer_Release(temp_buffer
);
368 ok(ref
==1,"IDirectSoundBuffer_Release() has %d references, "
369 "should have 1\n",ref
);
371 ref
=IDirectSoundBuffer_Release(*dsbo
);
372 ok(ref
==0,"IDirectSoundBuffer_Release() has %d references, "
373 "should have 0\n",ref
);
375 rc
=IDirectSound3DBuffer_QueryInterface(buffer
,
376 &IID_IDirectSoundBuffer
,
378 ok(rc
==DS_OK
&& *dsbo
!=NULL
,"IDirectSound3DBuffer_QueryInterface() "
379 "failed: %08x\n",rc
);
381 /* DSOUND: Error: Invalid buffer */
382 rc
=IDirectSound3DBuffer_GetAllParameters(buffer
,0);
383 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSound3DBuffer_GetAllParameters() "
384 "failed: %08x\n",rc
);
386 ZeroMemory(&buffer_param
, sizeof(buffer_param
));
388 /* DSOUND: Error: Invalid buffer */
389 rc
=IDirectSound3DBuffer_GetAllParameters(buffer
,&buffer_param
);
390 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSound3DBuffer_GetAllParameters() "
391 "failed: %08x\n",rc
);
393 buffer_param
.dwSize
=sizeof(buffer_param
);
394 rc
=IDirectSound3DBuffer_GetAllParameters(buffer
,&buffer_param
);
395 ok(rc
==DS_OK
,"IDirectSound3DBuffer_GetAllParameters() failed: %08x\n", rc
);
398 if (dsbcaps
.dwFlags
& DSBCAPS_CTRLVOLUME
) {
400 rc
=IDirectSoundBuffer_GetVolume(*dsbo
,&val
);
401 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc
);
403 rc
=IDirectSoundBuffer_SetVolume(*dsbo
,volume
);
404 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetVolume() failed: %08x\n", rc
);
406 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
407 rc
=IDirectSoundBuffer_GetVolume(*dsbo
,&volume
);
408 ok(rc
==DSERR_CONTROLUNAVAIL
,"IDirectSoundBuffer_GetVolume() "
409 "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc
);
414 if (dsbcaps
.dwFlags
& DSBCAPS_CTRLPAN
) {
416 rc
=IDirectSoundBuffer_GetPan(*dsbo
,&val
);
417 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetPan() failed: %08x\n", rc
);
419 rc
=IDirectSoundBuffer_SetPan(*dsbo
,pan
);
420 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetPan() failed: %08x\n", rc
);
422 /* DSOUND: Error: Buffer does not have CTRLPAN */
423 rc
=IDirectSoundBuffer_GetPan(*dsbo
,&pan
);
424 ok(rc
==DSERR_CONTROLUNAVAIL
,"IDirectSoundBuffer_GetPan() "
425 "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc
);
429 /* try an offset past the end of the buffer */
430 rc
= IDirectSoundBuffer_Lock(*dsbo
, dsbcaps
.dwBufferBytes
, 0, &buffer1
,
431 &length1
, NULL
, NULL
,
432 DSBLOCK_ENTIREBUFFER
);
433 ok(rc
==DSERR_INVALIDPARAM
, "IDirectSoundBuffer_Lock() should have "
434 "returned DSERR_INVALIDPARAM, returned %08x\n", rc
);
436 /* try a size larger than the buffer */
437 rc
= IDirectSoundBuffer_Lock(*dsbo
, 0, dsbcaps
.dwBufferBytes
+ 1,
438 &buffer1
, &length1
, NULL
, NULL
,
439 DSBLOCK_FROMWRITECURSOR
);
440 ok(rc
==DSERR_INVALIDPARAM
, "IDirectSoundBuffer_Lock() should have "
441 "returned DSERR_INVALIDPARAM, returned %08x\n", rc
);
443 state
.wave
=wave_generate_la(&wfx
,duration
,&state
.wave_len
,ieee
);
447 state
.buffer_size
=dsbcaps
.dwBufferBytes
;
448 state
.played
=state
.written
=state
.offset
=0;
449 buffer_refill8(&state
,state
.buffer_size
);
451 rc
=IDirectSoundBuffer_Play(*dsbo
,0,0,DSBPLAY_LOOPING
);
452 ok(rc
==DS_OK
,"IDirectSoundBuffer_Play() failed: %08x\n", rc
);
454 rc
=IDirectSoundBuffer_GetStatus(*dsbo
,&status
);
455 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc
);
456 ok(status
==(DSBSTATUS_PLAYING
|DSBSTATUS_LOOPING
),
457 "GetStatus: bad status: %x\n",status
);
460 ZeroMemory(&listener_param
,sizeof(listener_param
));
461 listener_param
.dwSize
=sizeof(listener_param
);
462 rc
=IDirectSound3DListener_GetAllParameters(listener
,&listener_param
);
463 ok(rc
==DS_OK
,"IDirectSound3dListener_GetAllParameters() "
464 "failed: %08x\n",rc
);
466 listener_param
.vPosition
.x
= -5.0f
;
467 listener_param
.vVelocity
.x
= (float)(10.0/duration
);
469 rc
=IDirectSound3DListener_SetAllParameters(listener
,
472 ok(rc
==DS_OK
,"IDirectSound3dListener_SetPosition() failed: %08x\n", rc
);
476 buffer_param
.vPosition
.x
= 100.0f
;
477 buffer_param
.vVelocity
.x
= (float)(-200.0/duration
);
479 buffer_param
.flMinDistance
= 10;
480 rc
=IDirectSound3DBuffer_SetAllParameters(buffer
,&buffer_param
,
482 ok(rc
==DS_OK
,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc
);
485 start_time
=GetTickCount();
486 while (buffer_service8(&state
)) {
487 WaitForSingleObject(GetCurrentProcess(),TIME_SLICE
);
489 if (listener
&& move_listener
) {
490 listener_param
.vPosition
.x
= (float)(-5.0+10.0*(now
-start_time
)/1000/duration
);
491 if (winetest_debug
>2)
492 trace("listener position=%g\n",listener_param
.vPosition
.x
);
493 rc
=IDirectSound3DListener_SetPosition(listener
,
494 listener_param
.vPosition
.x
,listener_param
.vPosition
.y
,
495 listener_param
.vPosition
.z
,DS3D_IMMEDIATE
);
496 ok(rc
==DS_OK
,"IDirectSound3dListener_SetPosition() failed: %08x\n",rc
);
498 if (buffer3d
&& move_sound
) {
499 buffer_param
.vPosition
.x
= (float)(100-200.0*(now
-start_time
)/1000/duration
);
500 if (winetest_debug
>2)
501 trace("sound position=%g\n",buffer_param
.vPosition
.x
);
502 rc
=IDirectSound3DBuffer_SetPosition(buffer
,
503 buffer_param
.vPosition
.x
,buffer_param
.vPosition
.y
,
504 buffer_param
.vPosition
.z
,DS3D_IMMEDIATE
);
505 ok(rc
==DS_OK
,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc
);
508 /* Check the sound duration was within 10% of the expected value */
510 ok(fabs(1000*duration
-now
+start_time
)<=100*duration
,
511 "The sound played for %d ms instead of %g ms\n",
512 now
-start_time
,1000*duration
);
514 HeapFree(GetProcessHeap(), 0, state
.wave
);
516 /* Set the CooperativeLevel back to normal */
517 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
518 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_NORMAL
);
519 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
520 "failed: %08x\n",rc
);
523 ref
=IDirectSound3DBuffer_Release(buffer
);
524 ok(ref
==0,"IDirectSound3DBuffer_Release() has %d references, "
525 "should have 0\n",ref
);
530 static HRESULT
test_secondary8(LPGUID lpGuid
, BOOL play
,
531 BOOL has_3d
, BOOL has_3dbuffer
,
532 BOOL has_listener
, BOOL has_duplicate
,
533 BOOL move_listener
, BOOL move_sound
)
536 LPDIRECTSOUND8 dso
=NULL
;
537 LPDIRECTSOUNDBUFFER primary
=NULL
,secondary
=NULL
;
538 LPDIRECTSOUND3DLISTENER listener
=NULL
;
539 DSBUFFERDESC bufdesc
;
540 WAVEFORMATEX wfx
, wfx1
;
543 /* Create the DirectSound object */
544 rc
= DirectSoundCreate8(lpGuid
, &dso
, NULL
);
545 ok(rc
==DS_OK
||rc
==DSERR_NODRIVER
,"DirectSoundCreate8() failed: %08x\n", rc
);
549 /* We must call SetCooperativeLevel before creating primary buffer */
550 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
551 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
552 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc
);
556 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
557 bufdesc
.dwSize
=sizeof(bufdesc
);
558 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
;
560 bufdesc
.dwFlags
|=DSBCAPS_CTRL3D
;
562 bufdesc
.dwFlags
|=(DSBCAPS_CTRLVOLUME
|DSBCAPS_CTRLPAN
);
563 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
564 ok((rc
==DS_OK
&& primary
!=NULL
) || (rc
== DSERR_CONTROLUNAVAIL
),
565 "IDirectSound8_CreateSoundBuffer() failed to create a %sprimary buffer: %08x\n",has_3d
?"3D ":"", rc
);
566 if (rc
== DSERR_CONTROLUNAVAIL
)
567 trace(" No Primary\n");
568 else if (rc
==DS_OK
&& primary
!=NULL
) {
569 rc
=IDirectSoundBuffer_GetFormat(primary
,&wfx1
,sizeof(wfx1
),NULL
);
570 ok(rc
==DS_OK
,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc
);
575 rc
=IDirectSoundBuffer_QueryInterface(primary
,
576 &IID_IDirectSound3DListener
,
578 ok(rc
==DS_OK
&& listener
!=NULL
,
579 "IDirectSoundBuffer_QueryInterface() failed to get a 3D "
580 "listener %08x\n",rc
);
581 ref
=IDirectSoundBuffer_Release(primary
);
582 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
583 "should have 0\n",ref
);
584 if (rc
==DS_OK
&& listener
!=NULL
) {
585 DS3DLISTENER listener_param
;
586 ZeroMemory(&listener_param
,sizeof(listener_param
));
587 /* DSOUND: Error: Invalid buffer */
588 rc
=IDirectSound3DListener_GetAllParameters(listener
,0);
589 ok(rc
==DSERR_INVALIDPARAM
,
590 "IDirectSound3dListener_GetAllParameters() should have "
591 "returned DSERR_INVALIDPARAM, returned: %08x\n", rc
);
593 /* DSOUND: Error: Invalid buffer */
594 rc
=IDirectSound3DListener_GetAllParameters(listener
,
596 ok(rc
==DSERR_INVALIDPARAM
,
597 "IDirectSound3dListener_GetAllParameters() should have "
598 "returned DSERR_INVALIDPARAM, returned: %08x\n", rc
);
600 listener_param
.dwSize
=sizeof(listener_param
);
601 rc
=IDirectSound3DListener_GetAllParameters(listener
,
603 ok(rc
==DS_OK
,"IDirectSound3dListener_GetAllParameters() "
604 "failed: %08x\n",rc
);
606 ok(listener
==NULL
, "IDirectSoundBuffer_QueryInterface() "
607 "failed but returned a listener anyway\n");
608 ok(rc
!=DS_OK
, "IDirectSoundBuffer_QueryInterface() succeeded "
609 "but returned a NULL listener\n");
611 ref
=IDirectSound3DListener_Release(listener
);
612 ok(ref
==0,"IDirectSound3dListener_Release() listener has "
613 "%d references, should have 0\n",ref
);
619 init_format(&wfx
,WAVE_FORMAT_PCM
,22050,16,2);
621 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
622 bufdesc
.dwSize
=sizeof(bufdesc
);
623 bufdesc
.dwFlags
=DSBCAPS_GETCURRENTPOSITION2
;
625 bufdesc
.dwFlags
|=DSBCAPS_CTRL3D
;
628 (DSBCAPS_CTRLFREQUENCY
|DSBCAPS_CTRLVOLUME
|DSBCAPS_CTRLPAN
);
629 bufdesc
.dwBufferBytes
=align(wfx
.nAvgBytesPerSec
*BUFFER_LEN
/1000,
631 bufdesc
.lpwfxFormat
=&wfx
;
633 /* a stereo 3D buffer should fail */
634 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&secondary
,NULL
);
635 ok(rc
==DSERR_INVALIDPARAM
,
636 "IDirectSound8_CreateSoundBuffer(secondary) should have "
637 "returned DSERR_INVALIDPARAM, returned %08x\n", rc
);
638 init_format(&wfx
,WAVE_FORMAT_PCM
,22050,16,1);
640 /* Invalid flag combination */
641 bufdesc
.dwFlags
|=DSBCAPS_CTRLPAN
;
642 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&secondary
,NULL
);
643 ok(rc
==DSERR_INVALIDPARAM
,
644 "IDirectSound8_CreateSoundBuffer(secondary) should have "
645 "returned DSERR_INVALIDPARAM, returned %08x\n", rc
);
646 bufdesc
.dwFlags
&=~DSBCAPS_CTRLPAN
;
649 if (winetest_interactive
) {
650 trace(" Testing a %s%ssecondary buffer %s%s%s%sat %dx%dx%d "
651 "with a primary buffer at %dx%dx%d\n",
652 has_3dbuffer
?"3D ":"",
653 has_duplicate
?"duplicated ":"",
654 listener
!=NULL
||move_sound
?"with ":"",
655 move_listener
?"moving ":"",
656 listener
!=NULL
?"listener ":"",
657 listener
&&move_sound
?"and moving sound ":move_sound
?
659 wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,wfx
.nChannels
,
660 wfx1
.nSamplesPerSec
,wfx1
.wBitsPerSample
,wfx1
.nChannels
);
662 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&secondary
,NULL
);
663 ok(rc
==DS_OK
&& secondary
!=NULL
,"IDirectSound8_CreateSoundBuffer() "
664 "failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %08x\n",
665 has_3dbuffer
?"3D ":"", has_duplicate
?"duplicated ":"",
666 listener
!=NULL
||move_sound
?"with ":"", move_listener
?"moving ":"",
667 listener
!=NULL
?"listener ":"",
668 listener
&&move_sound
?"and moving sound ":move_sound
?
670 wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,wfx
.nChannels
,
671 getDSBCAPS(bufdesc
.dwFlags
),rc
);
672 if (rc
==DS_OK
&& secondary
!=NULL
) {
674 LONG refvol
,vol
,refpan
,pan
;
676 /* Check the initial secondary buffer's volume and pan */
677 rc
=IDirectSoundBuffer_GetVolume(secondary
,&vol
);
678 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetVolume(secondary) failed: %08x\n",rc
);
679 ok(vol
==0,"wrong volume for a new secondary buffer: %d\n",vol
);
680 rc
=IDirectSoundBuffer_GetPan(secondary
,&pan
);
681 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetPan(secondary) failed: %08x\n",rc
);
682 ok(pan
==0,"wrong pan for a new secondary buffer: %d\n",pan
);
684 /* Check that changing the secondary buffer's volume and pan
685 * does not impact the primary buffer's volume and pan
687 rc
=IDirectSoundBuffer_GetVolume(primary
,&refvol
);
688 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetVolume(primary) failed: %08x\n",rc
);
689 rc
=IDirectSoundBuffer_GetPan(primary
,&refpan
);
690 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetPan(primary) failed: %08x\n",rc
);
692 rc
=IDirectSoundBuffer_SetVolume(secondary
,-1000);
693 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc
);
694 rc
=IDirectSoundBuffer_GetVolume(secondary
,&vol
);
695 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc
);
696 ok(vol
==-1000,"secondary: wrong volume %d instead of -1000\n",
698 rc
=IDirectSoundBuffer_SetPan(secondary
,-1000);
699 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc
);
700 rc
=IDirectSoundBuffer_GetPan(secondary
,&pan
);
701 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetPan(secondary) failed: %08x\n",rc
);
702 ok(pan
==-1000,"secondary: wrong pan %d instead of -1000\n",
705 rc
=IDirectSoundBuffer_GetVolume(primary
,&vol
);
706 ok(rc
==DS_OK
,"IDirectSoundBuffer_`GetVolume(primary) failed: i%08x\n",rc
);
707 ok(vol
==refvol
,"The primary volume changed from %d to %d\n",
709 rc
=IDirectSoundBuffer_GetPan(primary
,&pan
);
710 ok(rc
==DS_OK
,"IDirectSoundBuffer_GetPan(primary) failed: %08x\n",rc
);
711 ok(pan
==refpan
,"The primary pan changed from %d to %d\n",
714 rc
=IDirectSoundBuffer_SetVolume(secondary
,0);
715 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc
);
716 rc
=IDirectSoundBuffer_SetPan(secondary
,0);
717 ok(rc
==DS_OK
,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc
);
721 rc
=IDirectSoundBuffer_GetPan(secondary
,&pan
);
722 ok(rc
==DSERR_CONTROLUNAVAIL
,"IDirectSoundBuffer_GetPan() "
723 "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc
);
724 rc
=IDirectSoundBuffer_SetPan(secondary
,0);
725 ok(rc
==DSERR_CONTROLUNAVAIL
,"IDirectSoundBuffer_SetPan() "
726 "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc
);
730 LPDIRECTSOUNDBUFFER duplicated
=NULL
;
732 /* DSOUND: Error: Invalid source buffer */
733 rc
=IDirectSound8_DuplicateSoundBuffer(dso
,0,0);
734 ok(rc
==DSERR_INVALIDPARAM
,
735 "IDirectSound8_DuplicateSoundBuffer() should have returned "
736 "DSERR_INVALIDPARAM, returned: %08x\n",rc
);
738 /* DSOUND: Error: Invalid dest buffer */
739 rc
=IDirectSound8_DuplicateSoundBuffer(dso
,secondary
,0);
740 ok(rc
==DSERR_INVALIDPARAM
,
741 "IDirectSound8_DuplicateSoundBuffer() should have returned "
742 "DSERR_INVALIDPARAM, returned: %08x\n",rc
);
744 /* DSOUND: Error: Invalid source buffer */
745 rc
=IDirectSound8_DuplicateSoundBuffer(dso
,0,&duplicated
);
746 ok(rc
==DSERR_INVALIDPARAM
,
747 "IDirectSound8_DuplicateSoundBuffer() should have returned "
748 "DSERR_INVALIDPARAM, returned: %08x\n",rc
);
751 rc
=IDirectSound8_DuplicateSoundBuffer(dso
,secondary
,
753 ok(rc
==DS_OK
&& duplicated
!=NULL
,
754 "IDirectSound8_DuplicateSoundBuffer() failed to duplicate "
755 "a secondary buffer: %08x\n",rc
);
757 if (rc
==DS_OK
&& duplicated
!=NULL
) {
758 ref
=IDirectSoundBuffer_Release(secondary
);
759 ok(ref
==0,"IDirectSoundBuffer_Release() secondary has %d "
760 "references, should have 0\n",ref
);
761 secondary
=duplicated
;
765 if (rc
==DS_OK
&& secondary
!=NULL
) {
767 duration
=(move_listener
|| move_sound
?4.0:1.0);
768 test_buffer8(dso
,&secondary
,FALSE
,FALSE
,0,FALSE
,0,
769 winetest_interactive
,duration
,has_3dbuffer
,
770 listener
,move_listener
,move_sound
);
771 ref
=IDirectSoundBuffer_Release(secondary
);
772 ok(ref
==0,"IDirectSoundBuffer_Release() %s has %d references, "
773 "should have 0\n",has_duplicate
?"duplicated":"secondary",
780 ref
=IDirectSound3DListener_Release(listener
);
781 ok(ref
==0,"IDirectSound3dListener_Release() listener has %d "
782 "references, should have 0\n",ref
);
785 ref
=IDirectSoundBuffer_Release(primary
);
786 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
787 "should have 0\n",ref
);
790 ok(primary
==NULL
,"IDirectSound8_CreateSoundBuffer(primary) failed "
791 "but primary created anyway\n");
792 ok(rc
!=DS_OK
,"IDirectSound8_CreateSoundBuffer(primary) succeeded "
793 "but primary not created\n");
795 ref
=IDirectSoundBuffer_Release(primary
);
796 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
797 "should have 0\n",ref
);
801 /* Set the CooperativeLevel back to normal */
802 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
803 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_NORMAL
);
804 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n",rc
);
807 ref
=IDirectSound8_Release(dso
);
808 ok(ref
==0,"IDirectSound8_Release() has %d references, should have 0\n",ref
);
810 return DSERR_GENERIC
;
815 static HRESULT
test_for_driver8(LPGUID lpGuid
)
818 LPDIRECTSOUND8 dso
=NULL
;
821 /* Create the DirectSound object */
822 rc
= DirectSoundCreate8(lpGuid
, &dso
, NULL
);
823 ok(rc
==DS_OK
||rc
==DSERR_NODRIVER
||rc
==DSERR_ALLOCATED
||rc
==E_FAIL
,
824 "DirectSoundCreate8() failed: %08x\n",rc
);
828 ref
=IDirectSound8_Release(dso
);
829 ok(ref
==0,"IDirectSound8_Release() has %d references, should have 0\n",ref
);
831 return DSERR_GENERIC
;
836 static HRESULT
test_primary8(LPGUID lpGuid
)
839 LPDIRECTSOUND8 dso
=NULL
;
840 LPDIRECTSOUNDBUFFER primary
=NULL
;
841 DSBUFFERDESC bufdesc
;
845 /* Create the DirectSound object */
846 rc
= DirectSoundCreate8(lpGuid
, &dso
, NULL
);
847 ok(rc
==DS_OK
||rc
==DSERR_NODRIVER
,"DirectSoundCreate8() failed: %08x\n", rc
);
851 /* Get the device capabilities */
852 ZeroMemory(&dscaps
, sizeof(dscaps
));
853 dscaps
.dwSize
=sizeof(dscaps
);
854 rc
=IDirectSound8_GetCaps(dso
,&dscaps
);
855 ok(rc
==DS_OK
,"IDirectSound8_GetCaps() failed: %08x\n",rc
);
859 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
860 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
861 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
862 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc
);
866 /* Testing the primary buffer */
868 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
869 bufdesc
.dwSize
=sizeof(bufdesc
);
870 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
|DSBCAPS_CTRLVOLUME
|DSBCAPS_CTRLPAN
;
871 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
872 ok((rc
==DS_OK
&& primary
!=NULL
) || (rc
== DSERR_CONTROLUNAVAIL
),
873 "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: %08x\n",rc
);
874 if (rc
== DSERR_CONTROLUNAVAIL
)
875 trace(" No Primary\n");
876 else if (rc
==DS_OK
&& primary
!=NULL
) {
877 test_buffer8(dso
,&primary
,TRUE
,TRUE
,0,TRUE
,0,
878 winetest_interactive
&& !(dscaps
.dwFlags
& DSCAPS_EMULDRIVER
),
879 1.0,FALSE
,NULL
,FALSE
,FALSE
);
880 if (winetest_interactive
) {
883 volume
= DSBVOLUME_MAX
;
884 for (i
= 0; i
< 6; i
++) {
885 test_buffer8(dso
,&primary
,TRUE
,TRUE
,volume
,TRUE
,0,
886 winetest_interactive
&& !(dscaps
.dwFlags
& DSCAPS_EMULDRIVER
),
887 1.0,FALSE
,NULL
,FALSE
,FALSE
);
888 volume
-= ((DSBVOLUME_MAX
-DSBVOLUME_MIN
) / 40);
892 for (i
= 0; i
< 7; i
++) {
893 test_buffer8(dso
,&primary
,TRUE
,TRUE
,0,TRUE
,pan
,
894 winetest_interactive
&& !(dscaps
.dwFlags
& DSCAPS_EMULDRIVER
),
895 1.0,FALSE
,NULL
,FALSE
,FALSE
);
896 pan
+= ((DSBPAN_RIGHT
-DSBPAN_LEFT
) / 6);
899 ref
=IDirectSoundBuffer_Release(primary
);
900 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
901 "should have 0\n",ref
);
904 /* Set the CooperativeLevel back to normal */
905 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
906 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_NORMAL
);
907 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n",rc
);
910 ref
=IDirectSound8_Release(dso
);
911 ok(ref
==0,"IDirectSound8_Release() has %d references, should have 0\n",ref
);
913 return DSERR_GENERIC
;
918 static HRESULT
test_primary_3d8(LPGUID lpGuid
)
921 LPDIRECTSOUND8 dso
=NULL
;
922 LPDIRECTSOUNDBUFFER primary
=NULL
;
923 DSBUFFERDESC bufdesc
;
927 /* Create the DirectSound object */
928 rc
= DirectSoundCreate8(lpGuid
, &dso
, NULL
);
929 ok(rc
==DS_OK
||rc
==DSERR_NODRIVER
,"DirectSoundCreate8() failed: %08x\n", rc
);
933 /* Get the device capabilities */
934 ZeroMemory(&dscaps
, sizeof(dscaps
));
935 dscaps
.dwSize
=sizeof(dscaps
);
936 rc
=IDirectSound8_GetCaps(dso
,&dscaps
);
937 ok(rc
==DS_OK
,"IDirectSound8_GetCaps failed: %08x\n",rc
);
941 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
942 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
943 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
944 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc
);
949 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
950 bufdesc
.dwSize
=sizeof(bufdesc
);
951 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
;
952 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
953 ok(rc
==DS_OK
&& primary
!=NULL
,"IDirectSound8_CreateSoundBuffer() failed "
954 "to create a primary buffer: %08x\n",rc
);
955 if (rc
==DS_OK
&& primary
!=NULL
) {
956 ref
=IDirectSoundBuffer_Release(primary
);
957 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
958 "should have 0\n",ref
);
960 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
961 bufdesc
.dwSize
=sizeof(bufdesc
);
962 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
|DSBCAPS_CTRL3D
;
963 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
964 ok(rc
==DS_OK
&& primary
!=NULL
,"IDirectSound8_CreateSoundBuffer() "
965 "failed to create a 3D primary buffer: %08x\n",rc
);
966 if (rc
==DS_OK
&& primary
!=NULL
) {
967 test_buffer8(dso
,&primary
,TRUE
,FALSE
,0,FALSE
,0,
968 winetest_interactive
&& !(dscaps
.dwFlags
& DSCAPS_EMULDRIVER
),
969 1.0,FALSE
,NULL
,FALSE
,FALSE
);
970 ref
=IDirectSoundBuffer_Release(primary
);
971 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
972 "should have 0\n",ref
);
975 /* Set the CooperativeLevel back to normal */
976 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
977 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_NORMAL
);
978 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n",rc
);
981 ref
=IDirectSound8_Release(dso
);
982 ok(ref
==0,"IDirectSound8_Release() has %d references, should have 0\n",ref
);
984 return DSERR_GENERIC
;
989 static HRESULT
test_primary_3d_with_listener8(LPGUID lpGuid
)
992 LPDIRECTSOUND8 dso
=NULL
;
993 LPDIRECTSOUNDBUFFER primary
=NULL
;
994 DSBUFFERDESC bufdesc
;
998 /* Create the DirectSound object */
999 rc
= DirectSoundCreate8(lpGuid
, &dso
, NULL
);
1000 ok(rc
==DS_OK
||rc
==DSERR_NODRIVER
,"DirectSoundCreate8() failed: %08x\n", rc
);
1004 /* Get the device capabilities */
1005 ZeroMemory(&dscaps
, sizeof(dscaps
));
1006 dscaps
.dwSize
=sizeof(dscaps
);
1007 rc
=IDirectSound8_GetCaps(dso
,&dscaps
);
1008 ok(rc
==DS_OK
,"IDirectSound8_GetCaps() failed: %08x\n",rc
);
1012 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
1013 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
1014 rc
=IDirectSound8_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
1015 ok(rc
==DS_OK
,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc
);
1019 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
1020 bufdesc
.dwSize
=sizeof(bufdesc
);
1021 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
|DSBCAPS_CTRL3D
;
1022 rc
=IDirectSound8_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
1023 ok(rc
==DS_OK
&& primary
!=NULL
,"IDirectSound8_CreateSoundBuffer() failed "
1024 "to create a 3D primary buffer %08x\n",rc
);
1025 if (rc
==DS_OK
&& primary
!=NULL
) {
1026 LPDIRECTSOUND3DLISTENER listener
=NULL
;
1027 rc
=IDirectSoundBuffer_QueryInterface(primary
,
1028 &IID_IDirectSound3DListener
,
1029 (void **)&listener
);
1030 ok(rc
==DS_OK
&& listener
!=NULL
,"IDirectSoundBuffer_QueryInterface() "
1031 "failed to get a 3D listener: %08x\n",rc
);
1032 if (rc
==DS_OK
&& listener
!=NULL
) {
1033 LPDIRECTSOUNDBUFFER temp_buffer
=NULL
;
1035 /* Checking the COM interface */
1036 rc
=IDirectSoundBuffer_QueryInterface(primary
,
1037 &IID_IDirectSoundBuffer
,
1038 (LPVOID
*)&temp_buffer
);
1039 ok(rc
==DS_OK
&& temp_buffer
!=NULL
,
1040 "IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc
);
1041 ok(temp_buffer
==primary
,"COM interface broken: %p != %p\n",temp_buffer
,primary
);
1042 if (rc
==DS_OK
&& temp_buffer
!=NULL
) {
1043 ref
=IDirectSoundBuffer_Release(temp_buffer
);
1044 ok(ref
==1,"IDirectSoundBuffer_Release() has %d references, "
1045 "should have 1\n",ref
);
1048 rc
=IDirectSound3DListener_QueryInterface(listener
,
1049 &IID_IDirectSoundBuffer
,(LPVOID
*)&temp_buffer
);
1050 ok(rc
==DS_OK
&& temp_buffer
!=NULL
,
1051 "IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc
);
1052 ok(temp_buffer
==primary
,"COM interface broken: %p != %p\n",temp_buffer
,primary
);
1053 ref
=IDirectSoundBuffer_Release(temp_buffer
);
1054 ok(ref
==1,"IDirectSoundBuffer_Release() has %d references, "
1055 "should have 1\n",ref
);
1057 /* Testing the buffer */
1058 test_buffer8(dso
,&primary
,TRUE
,FALSE
,0,FALSE
,0,
1059 winetest_interactive
&& !(dscaps
.dwFlags
& DSCAPS_EMULDRIVER
),
1060 1.0,FALSE
,listener
,FALSE
,FALSE
);
1063 /* Testing the reference counting */
1064 ref
=IDirectSound3DListener_Release(listener
);
1065 ok(ref
==0,"IDirectSound3DListener_Release() listener has %d "
1066 "references, should have 0\n",ref
);
1069 /* Testing the reference counting */
1070 ref
=IDirectSoundBuffer_Release(primary
);
1071 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
1072 "should have 0\n",ref
);
1076 ref
=IDirectSound8_Release(dso
);
1077 ok(ref
==0,"IDirectSound8_Release() has %d references, should have 0\n",ref
);
1079 return DSERR_GENERIC
;
1084 static unsigned driver_count
= 0;
1086 static BOOL WINAPI
dsenum_callback(LPGUID lpGuid
, LPCSTR lpcstrDescription
,
1087 LPCSTR lpcstrModule
, LPVOID lpContext
)
1090 trace("*** Testing %s - %s ***\n",lpcstrDescription
,lpcstrModule
);
1093 rc
= test_for_driver8(lpGuid
);
1094 if (rc
== DSERR_NODRIVER
) {
1095 trace(" No Driver\n");
1097 } else if (rc
== DSERR_ALLOCATED
) {
1098 trace(" Already In Use\n");
1100 } else if (rc
== E_FAIL
) {
1101 trace(" No Device\n");
1105 trace(" Testing the primary buffer\n");
1106 test_primary8(lpGuid
);
1108 trace(" Testing 3D primary buffer\n");
1109 test_primary_3d8(lpGuid
);
1111 trace(" Testing 3D primary buffer with listener\n");
1112 test_primary_3d_with_listener8(lpGuid
);
1114 /* Testing secondary buffers */
1115 test_secondary8(lpGuid
,winetest_interactive
,FALSE
,FALSE
,FALSE
,FALSE
,FALSE
,FALSE
);
1116 test_secondary8(lpGuid
,winetest_interactive
,FALSE
,FALSE
,FALSE
,TRUE
, FALSE
,FALSE
);
1118 /* Testing 3D secondary buffers */
1119 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, FALSE
,FALSE
,FALSE
,FALSE
,FALSE
);
1120 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, FALSE
,FALSE
,FALSE
,FALSE
);
1121 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, FALSE
,TRUE
, FALSE
,FALSE
);
1122 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, FALSE
,TRUE
, FALSE
,FALSE
,FALSE
);
1123 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, FALSE
,TRUE
, TRUE
, FALSE
,FALSE
);
1124 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, TRUE
, FALSE
,FALSE
,FALSE
);
1125 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, TRUE
, TRUE
, FALSE
,FALSE
);
1126 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, TRUE
, FALSE
,TRUE
, FALSE
);
1127 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, TRUE
, FALSE
,FALSE
,TRUE
);
1128 test_secondary8(lpGuid
,winetest_interactive
,TRUE
, TRUE
, TRUE
, FALSE
,TRUE
, TRUE
);
1133 static void ds3d8_tests(void)
1136 rc
= DirectSoundEnumerateA(dsenum_callback
, NULL
);
1137 ok(rc
==DS_OK
,"DirectSoundEnumerateA() failed: %08x\n",rc
);
1138 trace("tested %u DirectSound drivers\n", driver_count
);