TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / dsound / tests / propset.c
blob49e6f518ae40314881887d01374ab4d238256958
1 /*
2 * Unit tests for CLSID_DirectSoundPrivate property set functions
3 * (used by dxdiag)
5 * Copyright (c) 2003 Robert Reif
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
23 #include <windows.h>
25 #include "wine/test.h"
26 #include "mmsystem.h"
27 #include "dsound.h"
28 #include "dsconf.h"
30 #include "dsound_test.h"
32 #ifndef DSBCAPS_CTRLDEFAULT
33 #define DSBCAPS_CTRLDEFAULT \
34 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
35 #endif
37 #include "initguid.h"
39 DEFINE_GUID(DSPROPSETID_VoiceManager,
40 0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
41 DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties,
42 0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
43 DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties,
44 0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
45 DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties,
46 0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
47 DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties,
48 0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
49 DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties,
50 0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
52 static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
53 static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID*)=NULL;
54 static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
55 LPUNKNOWN)=NULL;
56 static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
57 LPUNKNOWN)=NULL;
58 static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
59 LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
60 static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
61 LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
62 static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
63 LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
64 LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
66 static BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
67 LPVOID context)
69 trace(" found device:\n");
70 trace(" Type: %s\n",
71 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
72 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
73 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
74 trace(" DataFlow: %s\n",
75 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
76 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
77 "Capture" : "Unknown");
78 trace(" DeviceId: %s\n", wine_dbgstr_guid(&data->DeviceId));
79 trace(" Description: %s\n", data->Description);
80 trace(" Module: %s\n", data->Module);
81 trace(" Interface: %s\n", data->Interface);
82 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
84 return TRUE;
87 static BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
88 LPVOID context)
90 char descriptionA[0x100];
91 char moduleA[MAX_PATH];
93 trace(" found device:\n");
94 trace(" Type: %s\n",
95 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
96 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
97 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
98 trace(" DataFlow: %s\n",
99 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
100 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
101 "Capture" : "Unknown");
102 trace(" DeviceId: %s\n", wine_dbgstr_guid(&data->DeviceId));
103 trace(" DescriptionA: %s\n", data->DescriptionA);
104 WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
105 trace(" DescriptionW: %s\n", descriptionA);
106 trace(" ModuleA: %s\n", data->ModuleA);
107 WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
108 trace(" ModuleW: %s\n", moduleA);
109 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
111 return TRUE;
114 static BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
115 LPVOID context)
117 trace(" found device:\n");
118 trace(" Type: %s\n",
119 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
120 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
121 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
122 trace(" DataFlow: %s\n",
123 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
124 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
125 "Capture" : "Unknown");
126 trace(" DeviceId: %s\n", wine_dbgstr_guid(&data->DeviceId));
127 trace(" Description: %s\n", data->Description);
128 trace(" Module: %s\n", data->Module);
129 trace(" Interface: %s\n", data->Interface);
130 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
132 return TRUE;
135 static BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
136 LPVOID context)
138 char descriptionA[0x100];
139 char moduleA[MAX_PATH];
140 char interfaceA[MAX_PATH];
142 trace("found device:\n");
143 trace("\tType: %s\n",
144 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
145 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
146 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
147 trace("\tDataFlow: %s\n",
148 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
149 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
150 "Capture" : "Unknown");
151 trace("\tDeviceId: %s\n", wine_dbgstr_guid(&data->DeviceId));
152 WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
153 WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
154 WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
155 trace("\tDescription: %s\n", descriptionA);
156 trace("\tModule: %s\n", moduleA);
157 trace("\tInterface: %s\n", interfaceA);
158 trace("\tWaveDeviceId: %d\n", data->WaveDeviceId);
160 return TRUE;
163 static void propset_private_tests(void)
165 HRESULT rc;
166 IClassFactory * pcf;
167 IKsPropertySet * pps;
168 ULONG support;
170 /* try direct sound first */
171 /* DSOUND: Error: Invalid interface buffer */
172 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, NULL);
173 ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
174 "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
175 "returned: %08x\n",rc);
177 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IDirectSound, (void **)(&pcf));
178 ok(rc==E_NOINTERFACE,"DllGetClassObject(CLSID_DirectSound, "
179 "IID_IDirectSound) should have returned E_NOINTERFACE, "
180 "returned: %08x\n",rc);
182 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
183 ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
184 "IID_IUnknown) failed: %08x\n",rc);
186 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
187 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
188 "failed: %08x\n",rc);
189 if (pcf==0)
190 return;
192 /* direct sound doesn't have an IKsPropertySet */
193 /* DSOUND: Error: Invalid interface buffer */
194 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
195 NULL);
196 ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
197 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
199 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
200 (void **)(&pps));
201 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
202 "returned E_NOINTERFACE, returned: %08x\n",rc);
204 /* and the direct sound 8 version */
205 if (pDirectSoundCreate8) {
206 rc = (pDllGetClassObject)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
207 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
208 "failed: %08x\n",rc);
209 if (pcf==0)
210 return;
212 /* direct sound 8 doesn't have an IKsPropertySet */
213 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
214 (void **)(&pps));
215 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
216 "returned E_NOINTERFACE, returned: %08x\n",rc);
219 /* try direct sound capture next */
220 if (pDirectSoundCaptureCreate) {
221 rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
222 (void **)(&pcf));
223 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
224 "failed: %08x\n",rc);
225 if (pcf==0)
226 return;
228 /* direct sound capture doesn't have an IKsPropertySet */
229 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
230 (void **)(&pps));
231 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
232 "returned E_NOINTERFACE,returned: %08x\n",rc);
235 /* and the direct sound capture 8 version */
236 if (pDirectSoundCaptureCreate8) {
237 rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
238 (void **)(&pcf));
239 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
240 "IID_IClassFactory) failed: %08x\n",rc);
241 if (pcf==0)
242 return;
244 /* direct sound capture 8 doesn't have an IKsPropertySet */
245 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
246 (void **)(&pps));
247 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
248 "returned E_NOINTERFACE, returned: %08x\n",rc);
251 /* try direct sound full duplex next */
252 if (pDirectSoundFullDuplexCreate) {
253 rc = (pDllGetClassObject)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
254 (void **)(&pcf));
255 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
256 "IID_IClassFactory) failed: %08x\n",rc);
257 if (pcf==0)
258 return;
260 /* direct sound full duplex doesn't have an IKsPropertySet */
261 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
262 (void **)(&pps));
263 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
264 "returned NOINTERFACE, returned: %08x\n",rc);
267 /* try direct sound private last */
268 rc = (pDllGetClassObject)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
269 (void **)(&pcf));
271 /* some early versions of Direct Sound do not have this */
272 if (rc==CLASS_E_CLASSNOTAVAILABLE)
273 return;
275 /* direct sound private does have an IKsPropertySet */
276 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
277 (void **)(&pps));
278 ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %08x\n",
279 rc);
280 if (rc!=DS_OK)
281 return;
283 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
284 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
285 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
286 &support);
287 ok(rc==DS_OK||rc==E_INVALIDARG,
288 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
289 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %08x\n",
290 rc);
291 if (rc!=DS_OK) {
292 if (rc==E_INVALIDARG)
293 trace(" Not Supported\n");
294 return;
297 ok(support & KSPROPERTY_SUPPORT_GET,
298 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
299 "support = 0x%x\n",support);
300 ok(!(support & KSPROPERTY_SUPPORT_SET),
301 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
302 "support = 0x%x\n",support);
304 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
305 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
306 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
307 &support);
308 ok(rc==DS_OK||rc==E_INVALIDARG,
309 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
310 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %08x\n",
311 rc);
312 if (rc!=DS_OK) {
313 if (rc==E_INVALIDARG)
314 trace(" Not Supported\n");
315 return;
318 ok(support & KSPROPERTY_SUPPORT_GET,
319 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
320 "support = 0x%x\n",support);
321 ok(!(support & KSPROPERTY_SUPPORT_SET),
322 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
323 "support = 0x%x\n",support);
325 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
326 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
327 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
328 &support);
329 ok(rc==DS_OK||rc==E_INVALIDARG,
330 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
331 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %08x\n",
332 rc);
333 if (rc!=DS_OK) {
334 if (rc==E_INVALIDARG)
335 trace(" Not Supported\n");
336 return;
339 ok(support & KSPROPERTY_SUPPORT_GET,
340 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
341 "support = 0x%x\n",support);
342 ok(!(support & KSPROPERTY_SUPPORT_SET),
343 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
344 "support = 0x%x\n",support);
346 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
347 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
348 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
349 &support);
350 ok(rc==DS_OK||rc==E_INVALIDARG,
351 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
352 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %08x\n",
353 rc);
354 if (rc!=DS_OK) {
355 if (rc==E_INVALIDARG)
356 trace(" Not Supported\n");
357 return;
360 ok(support & KSPROPERTY_SUPPORT_GET,
361 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
362 "support = 0x%x\n",support);
363 ok(!(support & KSPROPERTY_SUPPORT_SET),
364 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
365 "support = 0x%x\n",support);
367 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
368 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
369 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
370 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
371 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %08x\n",
372 rc);
373 if (rc!=DS_OK)
374 return;
376 ok(support & KSPROPERTY_SUPPORT_GET,
377 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
378 "support = 0x%x\n",support);
379 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
380 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
381 "0x%x\n",support);
383 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
384 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
385 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
386 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
387 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %08x\n",
388 rc);
389 if (rc!=DS_OK)
390 return;
392 ok(support & KSPROPERTY_SUPPORT_GET,
393 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
394 "support = 0x%x\n",support);
395 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
396 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
397 "0x%x\n",support);
399 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
400 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
401 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
402 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
403 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %08x\n",
404 rc);
405 if (rc!=DS_OK)
406 return;
408 ok(support & KSPROPERTY_SUPPORT_GET,
409 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
410 "support = 0x%x\n",support);
411 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
412 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
413 "0x%x\n",support);
415 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
416 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
417 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
418 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
419 &support);
420 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
421 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %08x\n",
422 rc);
423 if (rc!=DS_OK)
424 return;
426 ok(support & KSPROPERTY_SUPPORT_GET,
427 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
428 "support = 0x%x\n",support);
429 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
430 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%x\n",support);
432 if (support & KSPROPERTY_SUPPORT_GET) {
433 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
434 ULONG bytes;
436 data.Callback = callback;
437 data.Context = 0;
439 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
440 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
441 NULL, 0, &data, sizeof(data), &bytes);
442 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
445 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
446 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
447 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
448 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
449 &support);
450 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
451 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %08x\n",
452 rc);
453 if (rc!=DS_OK)
454 return;
456 ok(support & KSPROPERTY_SUPPORT_GET,
457 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
458 "support = 0x%x\n",support);
459 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
460 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%x\n",support);
462 if (support & KSPROPERTY_SUPPORT_GET) {
463 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
464 ULONG bytes;
466 data.Callback = callback1;
467 data.Context = 0;
469 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
470 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
471 NULL, 0, &data, sizeof(data), &bytes);
472 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
475 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
476 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
477 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
478 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
479 &support);
480 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
481 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %08x\n",
482 rc);
483 if (rc!=DS_OK)
484 return;
486 ok(support & KSPROPERTY_SUPPORT_GET,
487 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
488 "support = 0x%x\n",support);
489 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
490 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%x\n",support);
492 if (support & KSPROPERTY_SUPPORT_GET) {
493 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
494 ULONG bytes;
496 data.Callback = callbackA;
497 data.Context = 0;
499 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
500 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
501 NULL, 0, &data, sizeof(data), &bytes);
502 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
505 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
506 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
507 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
508 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
509 &support);
510 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
511 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %08x\n",
512 rc);
513 if (rc!=DS_OK)
514 return;
516 ok(support & KSPROPERTY_SUPPORT_GET,
517 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
518 "support = 0x%x\n",support);
519 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
520 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%x\n",support);
522 if (support & KSPROPERTY_SUPPORT_GET) {
523 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
524 ULONG bytes;
526 data.Callback = callbackW;
527 data.Context = 0;
529 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
530 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
531 NULL, 0, &data, sizeof(data), &bytes);
532 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
534 IKsPropertySet_Release(pps);
537 static unsigned driver_count = 0;
539 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
540 LPCSTR lpcstrModule, LPVOID lpContext)
542 HRESULT rc;
543 LPDIRECTSOUND dso=NULL;
544 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
545 DSBUFFERDESC bufdesc;
546 WAVEFORMATEX wfx;
547 int ref;
549 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
550 driver_count++;
552 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
553 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
554 "DirectSoundCreate() failed: %08x\n",rc);
555 if (rc!=DS_OK) {
556 if (rc==DSERR_NODRIVER)
557 trace(" No Driver\n");
558 else if (rc == DSERR_ALLOCATED)
559 trace(" Already In Use\n");
560 else if (rc == E_FAIL)
561 trace(" No Device\n");
562 goto EXIT;
565 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
566 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
567 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
568 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n",
569 rc);
570 if (rc!=DS_OK)
571 goto EXIT;
573 /* Testing 3D buffers */
574 primary=NULL;
575 ZeroMemory(&bufdesc, sizeof(bufdesc));
576 bufdesc.dwSize=sizeof(bufdesc);
577 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
578 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
579 ok((rc==DS_OK&&primary!=NULL)
580 || broken(rc==DSERR_INVALIDPARAM),
581 "IDirectSound_CreateSoundBuffer() failed to "
582 "create a hardware 3D primary buffer: %08x\n",rc);
583 if(rc==DSERR_INVALIDPARAM) {
584 skip("broken driver\n");
585 goto EXIT;
587 if (rc==DS_OK&&primary!=NULL) {
588 ZeroMemory(&wfx, sizeof(wfx));
589 wfx.wFormatTag=WAVE_FORMAT_PCM;
590 wfx.nChannels=1;
591 wfx.wBitsPerSample=16;
592 wfx.nSamplesPerSec=44100;
593 wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
594 wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
595 ZeroMemory(&bufdesc, sizeof(bufdesc));
596 bufdesc.dwSize=sizeof(bufdesc);
597 bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
598 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
599 bufdesc.lpwfxFormat=&wfx;
600 trace(" Testing a secondary buffer at %dx%dx%d\n",
601 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
602 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
603 ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
604 "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer: %08x\n",rc);
605 if (rc==DS_OK&&secondary!=NULL) {
606 IKsPropertySet * pPropertySet=NULL;
607 rc=IDirectSoundBuffer_QueryInterface(secondary,
608 &IID_IKsPropertySet,
609 (void **)&pPropertySet);
610 /* it's not an error for this to fail */
611 if(rc==DS_OK) {
612 ULONG ulTypeSupport;
613 trace(" Supports property sets\n");
614 /* it's not an error for these to fail */
615 rc=IKsPropertySet_QuerySupport(pPropertySet,
616 &DSPROPSETID_VoiceManager,
617 0,&ulTypeSupport);
618 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
619 KSPROPERTY_SUPPORT_SET)))
620 trace(" DSPROPSETID_VoiceManager supported\n");
621 else
622 trace(" DSPROPSETID_VoiceManager not supported\n");
623 rc=IKsPropertySet_QuerySupport(pPropertySet,
624 &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
625 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
626 KSPROPERTY_SUPPORT_SET)))
627 trace(" DSPROPSETID_EAX20_ListenerProperties "
628 "supported\n");
629 else
630 trace(" DSPROPSETID_EAX20_ListenerProperties not "
631 "supported\n");
632 rc=IKsPropertySet_QuerySupport(pPropertySet,
633 &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
634 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
635 KSPROPERTY_SUPPORT_SET)))
636 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
637 else
638 trace(" DSPROPSETID_EAX20_BufferProperties not "
639 "supported\n");
640 rc=IKsPropertySet_QuerySupport(pPropertySet,
641 &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
642 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
643 KSPROPERTY_SUPPORT_SET)))
644 trace(" DSPROPSETID_I3DL2_ListenerProperties "
645 "supported\n");
646 else
647 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
648 "supported\n");
649 rc=IKsPropertySet_QuerySupport(pPropertySet,
650 &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
651 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
652 KSPROPERTY_SUPPORT_SET)))
653 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
654 else
655 trace(" DSPROPSETID_I3DL2_BufferProperties not "
656 "supported\n");
657 rc=IKsPropertySet_QuerySupport(pPropertySet,
658 &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
659 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
660 KSPROPERTY_SUPPORT_SET)))
661 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
662 "supported\n");
663 else
664 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
665 "supported\n");
666 ref=IKsPropertySet_Release(pPropertySet);
667 /* try a few common ones */
668 ok(ref==0,"IKsPropertySet_Release() secondary has %d "
669 "references, should have 0\n",ref);
670 } else
671 trace(" Doesn't support property sets\n");
673 ref=IDirectSoundBuffer_Release(secondary);
674 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
675 "references, should have 0\n",ref);
678 ref=IDirectSoundBuffer_Release(primary);
679 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
680 "should have 0\n",ref);
683 EXIT:
684 if (dso!=NULL) {
685 ref=IDirectSound_Release(dso);
686 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
687 ref);
689 return TRUE;
692 static void propset_buffer_tests(void)
694 HRESULT rc;
695 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
696 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
697 trace("tested %u DirectSound drivers\n", driver_count);
700 START_TEST(propset)
702 HMODULE hDsound;
704 CoInitialize(NULL);
706 hDsound = LoadLibraryA("dsound.dll");
707 if (hDsound)
710 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
711 "DirectSoundEnumerateA");
712 pDllGetClassObject = (void *)GetProcAddress(hDsound,
713 "DllGetClassObject");
714 pDirectSoundCreate = (void*)GetProcAddress(hDsound,
715 "DirectSoundCreate");
716 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
717 "DirectSoundCreate8");
718 pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
719 "DirectSoundCaptureCreate");
720 pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,
721 "DirectSoundCaptureCreate8");
722 pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
723 "DirectSoundFullDuplexCreate");
725 propset_private_tests();
726 propset_buffer_tests();
728 FreeLibrary(hDsound);
730 else
731 skip("dsound.dll not found - skipping all tests\n");
733 CoUninitialize();