2 * Tests basic sound playback in DirectSound.
3 * In particular we test each standard Windows sound format to make sure
4 * we handle the sound card/driver quirks correctly.
6 * Part of this test involves playing test tones. But this only makes
7 * sense if someone is going to carefully listen to it, and would only
8 * bother everyone else.
9 * So this is only done if the test is being run in interactive mode.
11 * Copyright (c) 2002-2004 Francois Gouget
12 * Copyright (c) 2007 Maarten Lankhorst
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
36 /* MinGW doesn't have ksguid, needed for make crosstest to work. */
41 #include "dsound_test.h"
43 static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
44 static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
49 static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
58 DWORD speaker_config, new_speaker_config;
60 /* Try to Query for objects */
61 rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
62 ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IUnknown) failed: %s\n",
63 DXGetErrorString8(rc));
65 IDirectSound_Release(unknown);
67 rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
68 ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %s\n",
69 DXGetErrorString8(rc));
71 IDirectSound_Release(ds);
73 rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
74 ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
75 "should have failed: %s\n",DXGetErrorString8(rc));
77 IDirectSound8_Release(ds8);
79 if (initialized == FALSE) {
80 /* try uninitialized object */
81 rc=IDirectSound_GetCaps(dso,0);
82 ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps(NULL) "
83 "should have returned DSERR_UNINITIALIZED, returned: %s\n",
84 DXGetErrorString8(rc));
86 rc=IDirectSound_GetCaps(dso,&dscaps);
87 ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps() "
88 "should have returned DSERR_UNINITIALIZED, returned: %s\n",
89 DXGetErrorString8(rc));
91 rc=IDirectSound_Compact(dso);
92 ok(rc==DSERR_UNINITIALIZED,"IDirectSound_Compact() "
93 "should have returned DSERR_UNINITIALIZED, returned: %s\n",
94 DXGetErrorString8(rc));
96 rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
97 ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetSpeakerConfig() "
98 "should have returned DSERR_UNINITIALIZED, returned: %s\n",
99 DXGetErrorString8(rc));
101 rc=IDirectSound_Initialize(dso,lpGuid);
102 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
103 "IDirectSound_Initialize() failed: %s\n",DXGetErrorString8(rc));
104 if (rc==DSERR_NODRIVER) {
105 trace(" No Driver\n");
107 } else if (rc==E_FAIL) {
108 trace(" No Device\n");
110 } else if (rc==DSERR_ALLOCATED) {
111 trace(" Already In Use\n");
116 rc=IDirectSound_Initialize(dso,lpGuid);
117 ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound_Initialize() "
118 "should have returned DSERR_ALREADYINITIALIZED: %s\n",
119 DXGetErrorString8(rc));
121 /* DSOUND: Error: Invalid caps buffer */
122 rc=IDirectSound_GetCaps(dso,0);
123 ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps(NULL) "
124 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
125 DXGetErrorString8(rc));
127 ZeroMemory(&dscaps, sizeof(dscaps));
129 /* DSOUND: Error: Invalid caps buffer */
130 rc=IDirectSound_GetCaps(dso,&dscaps);
131 ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps() "
132 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
133 DXGetErrorString8(rc));
135 dscaps.dwSize=sizeof(dscaps);
137 /* DSOUND: Running on a certified driver */
138 rc=IDirectSound_GetCaps(dso,&dscaps);
139 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
141 rc=IDirectSound_Compact(dso);
142 ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound_Compact() failed: %s\n",
143 DXGetErrorString8(rc));
145 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
146 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
147 DXGetErrorString8(rc));
149 rc=IDirectSound_Compact(dso);
150 ok(rc==DS_OK,"IDirectSound_Compact() failed: %s\n",DXGetErrorString8(rc));
152 rc=IDirectSound_GetSpeakerConfig(dso,0);
153 ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetSpeakerConfig(NULL) "
154 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
155 DXGetErrorString8(rc));
157 rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
158 ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
159 DXGetErrorString8(rc));
161 speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
162 DSSPEAKER_GEOMETRY_WIDE);
163 rc=IDirectSound_SetSpeakerConfig(dso,speaker_config);
164 ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %s\n",
165 DXGetErrorString8(rc));
167 rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config);
168 ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
169 DXGetErrorString8(rc));
170 if (rc==DS_OK && speaker_config!=new_speaker_config)
171 trace("IDirectSound_GetSpeakerConfig() failed to set speaker "
172 "config: expected 0x%08x, got 0x%08x\n",
173 speaker_config,new_speaker_config);
177 ref=IDirectSound_Release(dso);
178 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
181 static void IDirectSound_tests(void)
184 LPDIRECTSOUND dso=NULL;
185 LPCLASSFACTORY cf=NULL;
187 trace("Testing IDirectSound\n");
189 rc=CoGetClassObject(&CLSID_DirectSound, CLSCTX_INPROC_SERVER, NULL,
190 &IID_IClassFactory, (void**)&cf);
191 ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
192 "failed: %s\n", DXGetErrorString8(rc));
194 rc=CoGetClassObject(&CLSID_DirectSound, CLSCTX_INPROC_SERVER, NULL,
195 &IID_IUnknown, (void**)&cf);
196 ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IUnknown) "
197 "failed: %s\n", DXGetErrorString8(rc));
199 /* try the COM class factory method of creation with no device specified */
200 rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
201 &IID_IDirectSound, (void**)&dso);
202 ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
203 DXGetErrorString8(rc));
205 IDirectSound_test(dso, FALSE, NULL);
207 /* try the COM class factory method of creation with default playback
208 * device specified */
209 rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
210 &IID_IDirectSound, (void**)&dso);
211 ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
212 DXGetErrorString8(rc));
214 IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback);
216 /* try the COM class factory method of creation with default voice
217 * playback device specified */
218 rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
219 &IID_IDirectSound, (void**)&dso);
220 ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
221 DXGetErrorString8(rc));
223 IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
225 /* try the COM class factory method of creation with a bad
227 rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
228 &CLSID_DirectSoundPrivate, (void**)&dso);
229 ok(rc==E_NOINTERFACE,
230 "CoCreateInstance(CLSID_DirectSound,CLSID_DirectSoundPrivate) "
231 "should have failed: %s\n",DXGetErrorString8(rc));
233 /* try the COM class factory method of creation with a bad
234 * GUID and IID specified */
235 rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
236 &IID_IDirectSound, (void**)&dso);
237 ok(rc==REGDB_E_CLASSNOTREG,
238 "CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound) "
239 "should have failed: %s\n",DXGetErrorString8(rc));
241 /* try with no device specified */
242 rc=pDirectSoundCreate(NULL,&dso,NULL);
243 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
244 "DirectSoundCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
246 IDirectSound_test(dso, TRUE, NULL);
248 /* try with default playback device specified */
249 rc=pDirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
250 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
251 "DirectSoundCreate(DSDEVID_DefaultPlayback) failed: %s\n",
252 DXGetErrorString8(rc));
253 if (rc==DS_OK && dso)
254 IDirectSound_test(dso, TRUE, NULL);
256 /* try with default voice playback device specified */
257 rc=pDirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
258 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
259 "DirectSoundCreate(DSDEVID_DefaultVoicePlayback) failed: %s\n",
260 DXGetErrorString8(rc));
261 if (rc==DS_OK && dso)
262 IDirectSound_test(dso, TRUE, NULL);
264 /* try with a bad device specified */
265 rc=pDirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
266 ok(rc==DSERR_NODRIVER,"DirectSoundCreate(DSDEVID_DefaultVoiceCapture) "
267 "should have failed: %s\n",DXGetErrorString8(rc));
268 if (rc==DS_OK && dso)
269 IDirectSound_Release(dso);
272 static HRESULT test_dsound(LPGUID lpGuid)
275 LPDIRECTSOUND dso=NULL;
278 /* DSOUND: Error: Invalid interface buffer */
279 rc=pDirectSoundCreate(lpGuid,0,NULL);
280 ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate() should have returned "
281 "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
283 /* Create the DirectSound object */
284 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
285 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
286 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
290 /* Try the enumerated device */
291 IDirectSound_test(dso, TRUE, lpGuid);
293 /* Try the COM class factory method of creation with enumerated device */
294 rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
295 &IID_IDirectSound, (void**)&dso);
296 ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
297 DXGetErrorString8(rc));
299 IDirectSound_test(dso, FALSE, lpGuid);
301 /* Create a DirectSound object */
302 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
303 ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
305 LPDIRECTSOUND dso1=NULL;
307 /* Create a second DirectSound object */
308 rc=pDirectSoundCreate(lpGuid,&dso1,NULL);
309 ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
311 /* Release the second DirectSound object */
312 ref=IDirectSound_Release(dso1);
313 ok(ref==0,"IDirectSound_Release() has %d references, should have "
315 ok(dso!=dso1,"DirectSound objects should be unique: dso=%p,dso1=%p\n",dso,dso1);
318 /* Release the first DirectSound object */
319 ref=IDirectSound_Release(dso);
320 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
323 return DSERR_GENERIC;
327 /* Create a DirectSound object */
328 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
329 ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
331 LPDIRECTSOUNDBUFFER secondary;
332 DSBUFFERDESC bufdesc;
335 init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
336 ZeroMemory(&bufdesc, sizeof(bufdesc));
337 bufdesc.dwSize=sizeof(bufdesc);
338 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
339 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
341 bufdesc.lpwfxFormat=&wfx;
342 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
343 ok(rc==DS_OK && secondary!=NULL,
344 "IDirectSound_CreateSoundBuffer() failed to create a secondary "
345 "buffer %s\n",DXGetErrorString8(rc));
346 if (rc==DS_OK && secondary!=NULL) {
347 LPDIRECTSOUND3DBUFFER buffer3d;
348 rc=IDirectSound_QueryInterface(secondary, &IID_IDirectSound3DBuffer,
350 ok(rc==DS_OK && buffer3d!=NULL,"IDirectSound_QueryInterface() "
351 "failed: %s\n",DXGetErrorString8(rc));
352 if (rc==DS_OK && buffer3d!=NULL) {
353 ref=IDirectSound3DBuffer_AddRef(buffer3d);
354 ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
355 "should have 2\n",ref);
357 ref=IDirectSoundBuffer_AddRef(secondary);
358 ok(ref==2,"IDirectSoundBuffer_AddRef() has %d references, "
359 "should have 2\n",ref);
361 /* release with buffer */
362 ref=IDirectSound_Release(dso);
363 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
366 return DSERR_GENERIC;
373 static HRESULT test_primary(LPGUID lpGuid)
376 LPDIRECTSOUND dso=NULL;
377 LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
378 DSBUFFERDESC bufdesc;
383 /* Create the DirectSound object */
384 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
385 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
386 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
390 /* Get the device capabilities */
391 ZeroMemory(&dscaps, sizeof(dscaps));
392 dscaps.dwSize=sizeof(dscaps);
393 rc=IDirectSound_GetCaps(dso,&dscaps);
394 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
398 /* DSOUND: Error: Invalid buffer description pointer */
399 rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL);
400 ok(rc==DSERR_INVALIDPARAM,
401 "IDirectSound_CreateSoundBuffer() should have failed: %s\n",
402 DXGetErrorString8(rc));
404 /* DSOUND: Error: Invalid buffer description pointer */
405 rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL);
406 ok(rc==DSERR_INVALIDPARAM && primary==0,
407 "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
408 "dsbo=%p\n",DXGetErrorString8(rc),primary);
410 /* DSOUND: Error: Invalid buffer description pointer */
411 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,0,NULL);
412 ok(rc==DSERR_INVALIDPARAM && primary==0,
413 "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
414 "dsbo=0x%p\n",DXGetErrorString8(rc),primary);
416 ZeroMemory(&bufdesc, sizeof(bufdesc));
418 /* DSOUND: Error: Invalid size */
419 /* DSOUND: Error: Invalid buffer description */
420 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
421 ok(rc==DSERR_INVALIDPARAM && primary==0,
422 "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
423 "primary=%p\n",DXGetErrorString8(rc),primary);
425 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
426 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
427 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
428 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
429 DXGetErrorString8(rc));
433 /* Testing the primary buffer */
435 ZeroMemory(&bufdesc, sizeof(bufdesc));
436 bufdesc.dwSize=sizeof(bufdesc);
437 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
438 bufdesc.lpwfxFormat = &wfx;
439 init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
440 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
441 ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() should have "
442 "returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc));
443 if (rc==DS_OK && primary!=NULL)
444 IDirectSoundBuffer_Release(primary);
447 ZeroMemory(&bufdesc, sizeof(bufdesc));
448 bufdesc.dwSize=sizeof(bufdesc);
449 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
450 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
451 ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
452 "IDirectSound_CreateSoundBuffer() failed to create a primary buffer: "
453 "%s\n",DXGetErrorString8(rc));
454 if (rc==DSERR_CONTROLUNAVAIL)
455 trace(" No Primary\n");
456 else if (rc==DS_OK && primary!=NULL) {
459 /* Try to create a second primary buffer */
460 /* DSOUND: Error: The primary buffer already exists.
461 * Any changes made to the buffer description will be ignored. */
462 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
463 ok(rc==DS_OK && second==primary,
464 "IDirectSound_CreateSoundBuffer() should have returned original "
465 "primary buffer: %s\n",DXGetErrorString8(rc));
466 ref=IDirectSoundBuffer_Release(second);
467 ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
468 "should have 1\n",ref);
470 /* Try to duplicate a primary buffer */
471 /* DSOUND: Error: Can't duplicate primary buffers */
472 rc=IDirectSound_DuplicateSoundBuffer(dso,primary,&third);
474 ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer() primary buffer "
475 "should have failed %s\n",DXGetErrorString8(rc));
477 rc=IDirectSoundBuffer_GetVolume(primary,&vol);
478 ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
479 DXGetErrorString8(rc));
481 if (winetest_interactive) {
482 trace("Playing a 5 seconds reference tone at the current "
485 trace("(the current volume is %d according to DirectSound)\n",
487 trace("All subsequent tones should be identical to this one.\n");
488 trace("Listen for stutter, changes in pitch, volume, etc.\n");
490 test_buffer(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive &&
491 !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0);
493 ref=IDirectSoundBuffer_Release(primary);
494 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
495 "should have 0\n",ref);
498 /* Set the CooperativeLevel back to normal */
499 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
500 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
501 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
502 DXGetErrorString8(rc));
505 ref=IDirectSound_Release(dso);
506 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
508 return DSERR_GENERIC;
514 * Test the primary buffer at different formats while keeping the
515 * secondary buffer at a constant format.
517 static HRESULT test_primary_secondary(LPGUID lpGuid)
520 LPDIRECTSOUND dso=NULL;
521 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
522 DSBUFFERDESC bufdesc;
524 WAVEFORMATEX wfx, wfx2;
527 /* Create the DirectSound object */
528 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
529 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
530 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
534 /* Get the device capabilities */
535 ZeroMemory(&dscaps, sizeof(dscaps));
536 dscaps.dwSize=sizeof(dscaps);
537 rc=IDirectSound_GetCaps(dso,&dscaps);
538 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
542 /* We must call SetCooperativeLevel before creating primary buffer */
543 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
544 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
545 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
546 DXGetErrorString8(rc));
550 ZeroMemory(&bufdesc, sizeof(bufdesc));
551 bufdesc.dwSize=sizeof(bufdesc);
552 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
553 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
554 ok(rc==DS_OK && primary!=NULL,
555 "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
556 "%s\n",DXGetErrorString8(rc));
558 if (rc==DS_OK && primary!=NULL) {
559 for (f=0;f<NB_FORMATS;f++) {
560 /* We must call SetCooperativeLevel to be allowed to call
562 /* DSOUND: Setting DirectSound cooperative level to
564 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
565 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
566 DXGetErrorString8(rc));
570 init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
573 rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
575 if (wfx.wBitsPerSample <= 16)
576 ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %s\n",
577 format_string(&wfx), DXGetErrorString8(rc));
579 ok(rc==DS_OK || rc == E_INVALIDARG, "SetFormat (%s) failed: %s\n",
580 format_string(&wfx), DXGetErrorString8(rc));
582 /* There is no guarantee that SetFormat will actually change the
583 * format to what we asked for. It depends on what the soundcard
584 * supports. So we must re-query the format.
586 rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
587 ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
588 DXGetErrorString8(rc));
590 (wfx.wFormatTag!=wfx2.wFormatTag ||
591 wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
592 wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
593 wfx.nChannels!=wfx2.nChannels)) {
594 trace("Requested primary format tag=0x%04x %dx%dx%d "
595 "avg.B/s=%d align=%d\n",
596 wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
597 wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
598 trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
599 wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
600 wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
603 /* Set the CooperativeLevel back to normal */
604 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
605 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
606 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
607 DXGetErrorString8(rc));
609 init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
612 ZeroMemory(&bufdesc, sizeof(bufdesc));
613 bufdesc.dwSize=sizeof(bufdesc);
614 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
615 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
617 bufdesc.lpwfxFormat=&wfx2;
618 if (winetest_interactive) {
619 trace(" Testing a primary buffer at %dx%dx%d with a "
620 "secondary buffer at %dx%dx%d\n",
621 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
622 wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
624 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
625 ok(rc==DS_OK && secondary!=NULL,
626 "IDirectSound_CreateSoundBuffer() failed to create a secondary "
627 "buffer %s\n",DXGetErrorString8(rc));
629 if (rc==DS_OK && secondary!=NULL) {
630 test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
631 winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
633 ref=IDirectSoundBuffer_Release(secondary);
634 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
635 "should have 0\n",ref);
639 ref=IDirectSoundBuffer_Release(primary);
640 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
641 "should have 0\n",ref);
644 /* Set the CooperativeLevel back to normal */
645 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
646 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
647 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
648 DXGetErrorString8(rc));
651 ref=IDirectSound_Release(dso);
652 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
654 return DSERR_GENERIC;
659 static HRESULT test_secondary(LPGUID lpGuid)
662 LPDIRECTSOUND dso=NULL;
663 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
664 DSBUFFERDESC bufdesc;
666 WAVEFORMATEX wfx, wfx1;
670 /* Create the DirectSound object */
671 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
672 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
673 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
677 /* Get the device capabilities */
678 ZeroMemory(&dscaps, sizeof(dscaps));
679 dscaps.dwSize=sizeof(dscaps);
680 rc=IDirectSound_GetCaps(dso,&dscaps);
681 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
685 /* We must call SetCooperativeLevel before creating primary buffer */
686 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
687 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
688 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
689 DXGetErrorString8(rc));
693 ZeroMemory(&bufdesc, sizeof(bufdesc));
694 bufdesc.dwSize=sizeof(bufdesc);
695 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
696 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
697 ok(rc==DS_OK && primary!=NULL,
698 "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
699 "%s\n",DXGetErrorString8(rc));
701 if (rc==DS_OK && primary!=NULL) {
702 rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
703 ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
704 DXGetErrorString8(rc));
708 for (f=0;f<NB_FORMATS;f++) {
709 WAVEFORMATEXTENSIBLE wfxe;
710 init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
713 ZeroMemory(&bufdesc, sizeof(bufdesc));
714 bufdesc.dwSize=sizeof(bufdesc);
715 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
716 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
718 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
719 ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() "
720 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
721 DXGetErrorString8(rc));
722 if (rc==DS_OK && secondary!=NULL)
723 IDirectSoundBuffer_Release(secondary);
726 ZeroMemory(&bufdesc, sizeof(bufdesc));
727 bufdesc.dwSize=sizeof(bufdesc);
728 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
729 bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
731 bufdesc.lpwfxFormat=&wfx;
732 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
733 if (gotdx8 || wfx.wBitsPerSample <= 16)
735 if (wfx.wBitsPerSample > 16)
736 ok(rc == DSERR_CONTROLUNAVAIL && !secondary, "IDirectSound_CreateSoundBuffer() "
737 "should have returned DSERR_CONTROLUNAVAIL and NULL, returned: %s %p\n",
738 DXGetErrorString8(rc), secondary);
740 ok(rc==DS_OK && secondary!=NULL,
741 "IDirectSound_CreateSoundBuffer() failed to create a secondary "
742 "buffer %s\n",DXGetErrorString8(rc));
745 ok(rc==E_INVALIDARG, "Creating %d bpp buffer on dx < 8 returned: %p %s\n",
746 wfx.wBitsPerSample, secondary, DXGetErrorString8(rc));
750 skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
751 /* Apparently they succeed with bogus values,
752 * which means that older dsound doesn't look at them
758 IDirectSoundBuffer_Release(secondary);
761 bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
763 wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
764 wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
765 wfxe.Format.cbSize = 1;
766 wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
767 wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO);
769 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
770 ok(rc==DSERR_INVALIDPARAM && !secondary,
771 "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
772 DXGetErrorString8(rc), secondary);
774 IDirectSoundBuffer_Release(secondary);
776 wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;
778 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
779 ok(DSERR_CONTROLUNAVAIL && !secondary,
780 "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
781 DXGetErrorString8(rc), secondary);
783 IDirectSoundBuffer_Release(secondary);
785 wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
786 wfxe.SubFormat = GUID_NULL;
787 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
788 ok(rc==DSERR_INVALIDPARAM && !secondary,
789 "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
790 DXGetErrorString8(rc), secondary);
792 IDirectSoundBuffer_Release(secondary);
793 wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
795 ++wfxe.Samples.wValidBitsPerSample;
796 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
797 ok(rc==DSERR_INVALIDPARAM && !secondary,
798 "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
799 DXGetErrorString8(rc), secondary);
801 IDirectSoundBuffer_Release(secondary);
802 --wfxe.Samples.wValidBitsPerSample;
804 wfxe.Samples.wValidBitsPerSample = 0;
805 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
806 ok(rc==DS_OK && secondary,
807 "IDirectSound_CreateSoundBuffer() returned: %s %p\n",
808 DXGetErrorString8(rc), secondary);
810 IDirectSoundBuffer_Release(secondary);
811 wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample;
813 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
814 ok(rc==DS_OK && secondary!=NULL,
815 "IDirectSound_CreateSoundBuffer() failed to create a secondary "
816 "buffer %s\n",DXGetErrorString8(rc));
819 if (rc==DS_OK && secondary!=NULL) {
820 if (winetest_interactive) {
821 trace(" Testing a secondary buffer at %dx%dx%d "
822 "with a primary buffer at %dx%dx%d\n",
823 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
824 wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
826 test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
827 winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
829 ref=IDirectSoundBuffer_Release(secondary);
830 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
831 "should have 0\n",ref);
835 ref=IDirectSoundBuffer_Release(primary);
836 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
837 "should have 0\n",ref);
840 /* Set the CooperativeLevel back to normal */
841 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
842 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
843 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
844 DXGetErrorString8(rc));
847 ref=IDirectSound_Release(dso);
848 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
850 return DSERR_GENERIC;
855 static HRESULT test_block_align(LPGUID lpGuid)
858 LPDIRECTSOUND dso=NULL;
859 LPDIRECTSOUNDBUFFER secondary=NULL;
860 DSBUFFERDESC bufdesc;
866 /* Create the DirectSound object */
867 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
868 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
869 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
873 init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2);
874 ZeroMemory(&bufdesc, sizeof(bufdesc));
875 bufdesc.dwSize=sizeof(bufdesc);
876 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
877 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1;
878 bufdesc.lpwfxFormat=&wfx;
879 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
880 ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() "
881 "should have returned DS_OK, returned: %s\n",
882 DXGetErrorString8(rc));
884 if (rc==DS_OK && secondary!=NULL) {
885 ZeroMemory(&dsbcaps, sizeof(dsbcaps));
886 dsbcaps.dwSize = sizeof(dsbcaps);
887 rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
888 ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
889 "returned: %s\n", DXGetErrorString8(rc));
890 if (rc==DS_OK && wfx.nBlockAlign > 1)
892 ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
893 "Buffer size not a multiple of nBlockAlign: requested %d, "
894 "got %d, should be %d\n", bufdesc.dwBufferBytes,
895 dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
897 rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 0);
898 ok(rc == DS_OK, "Could not set position to 0: %s\n", DXGetErrorString8(rc));
899 rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos, NULL);
900 ok(rc == DS_OK, "Could not get position: %s\n", DXGetErrorString8(rc));
901 rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 1);
902 ok(rc == DS_OK, "Could not set position to 1: %s\n", DXGetErrorString8(rc));
903 rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos2, NULL);
904 ok(rc == DS_OK, "Could not get new position: %s\n", DXGetErrorString8(rc));
905 ok(pos == pos2, "Positions not the same! Old position: %d, new position: %d\n", pos, pos2);
907 ref=IDirectSoundBuffer_Release(secondary);
908 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
909 "should have 0\n",ref);
912 ref=IDirectSound_Release(dso);
913 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
915 return DSERR_GENERIC;
923 } fmts[] = { { 8, 1 }, { 8, 2 }, { 16, 1 }, {16, 2 } };
925 static HRESULT test_frequency(LPGUID lpGuid)
928 LPDIRECTSOUND dso=NULL;
929 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
930 DSBUFFERDESC bufdesc;
932 WAVEFORMATEX wfx, wfx1;
935 int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
938 /* Create the DirectSound object */
939 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
940 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
941 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
945 /* Get the device capabilities */
946 ZeroMemory(&dscaps, sizeof(dscaps));
947 dscaps.dwSize=sizeof(dscaps);
948 rc=IDirectSound_GetCaps(dso,&dscaps);
949 ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
953 /* We must call SetCooperativeLevel before creating primary buffer */
954 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
955 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
956 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
957 DXGetErrorString8(rc));
961 ZeroMemory(&bufdesc, sizeof(bufdesc));
962 bufdesc.dwSize=sizeof(bufdesc);
963 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
964 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
965 ok(rc==DS_OK && primary!=NULL,
966 "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
967 "%s\n",DXGetErrorString8(rc));
969 if (rc==DS_OK && primary!=NULL) {
970 rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
971 ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
972 DXGetErrorString8(rc));
976 for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) {
977 for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) {
978 init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits,
981 ZeroMemory(&bufdesc, sizeof(bufdesc));
982 bufdesc.dwSize=sizeof(bufdesc);
983 bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY;
984 bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)*
985 BUFFER_LEN/1000,wfx.nBlockAlign);
986 bufdesc.lpwfxFormat=&wfx;
987 if (winetest_interactive) {
988 trace(" Testing a secondary buffer at %dx%dx%d "
989 "with a primary buffer at %dx%dx%d\n",
990 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
991 wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
993 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
994 ok(rc==DS_OK && secondary!=NULL,
995 "IDirectSound_CreateSoundBuffer() failed to create a secondary "
996 "buffer %s\n",DXGetErrorString8(rc));
998 if (rc==DS_OK && secondary!=NULL) {
999 test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
1000 winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]);
1002 ref=IDirectSoundBuffer_Release(secondary);
1003 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
1004 "should have 0\n",ref);
1009 ref=IDirectSoundBuffer_Release(primary);
1010 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
1011 "should have 0\n",ref);
1014 /* Set the CooperativeLevel back to normal */
1015 /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
1016 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
1017 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
1018 DXGetErrorString8(rc));
1021 ref=IDirectSound_Release(dso);
1022 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
1024 return DSERR_GENERIC;
1029 static unsigned int number;
1031 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
1032 LPCSTR lpcstrModule, LPVOID lpContext)
1035 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
1037 /* Don't test the primary device */
1040 ok (!lpcstrModule[0], "lpcstrModule(%s) != NULL\n", lpcstrModule);
1044 rc = test_dsound(lpGuid);
1045 if (rc == DSERR_NODRIVER)
1046 trace(" No Driver\n");
1047 else if (rc == DSERR_ALLOCATED)
1048 trace(" Already In Use\n");
1049 else if (rc == E_FAIL)
1050 trace(" No Device\n");
1052 test_block_align(lpGuid);
1053 test_primary(lpGuid);
1054 test_primary_secondary(lpGuid);
1055 test_secondary(lpGuid);
1056 test_frequency(lpGuid);
1062 static void dsound_tests(void)
1065 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
1066 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
1075 hDsound = LoadLibrary("dsound.dll");
1078 ok( FreeLibrary(hDsound), "FreeLibrary(1) returned %d\n", GetLastError());
1079 ok( FreeLibrary(hDsound), "FreeLibrary(2) returned %d\n", GetLastError());
1080 ok(!FreeLibrary(hDsound), "DirectSound DLL still loaded\n");
1083 hDsound = LoadLibrary("dsound.dll");
1086 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
1088 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
1089 "DirectSoundEnumerateA");
1090 pDirectSoundCreate = (void*)GetProcAddress(hDsound,
1091 "DirectSoundCreate");
1093 gotdx8 = !!GetProcAddress(hDsound, "DirectSoundCreate8");
1095 IDirectSound_tests();
1098 FreeLibrary(hDsound);
1101 skip("dsound.dll not found!\n");