wer: Add new stubbed wer.dll.
[wine/hramrach.git] / dlls / dsound / tests / propset.c
blob5007fccb3ca88f39eae3633bf7921c1fe473cc53
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 "dsound.h"
27 #include "dsconf.h"
29 #include "dsound_test.h"
31 #ifndef DSBCAPS_CTRLDEFAULT
32 #define DSBCAPS_CTRLDEFAULT \
33 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
34 #endif
36 #include "initguid.h"
38 DEFINE_GUID(DSPROPSETID_VoiceManager,
39 0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
40 DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties,
41 0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
42 DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties,
43 0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
44 DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties,
45 0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
46 DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties,
47 0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
48 DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties,
49 0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
51 static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
52 static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID*)=NULL;
53 static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
54 LPUNKNOWN)=NULL;
55 static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
56 LPUNKNOWN)=NULL;
57 static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
58 LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
59 static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
60 LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
61 static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
62 LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
63 LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
65 static BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
66 LPVOID context)
68 trace(" found device:\n");
69 trace(" Type: %s\n",
70 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
71 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
72 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
73 trace(" DataFlow: %s\n",
74 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
75 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
76 "Capture" : "Unknown");
77 trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
78 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
79 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
80 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
81 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
82 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
83 trace(" Description: %s\n", data->Description);
84 trace(" Module: %s\n", data->Module);
85 trace(" Interface: %s\n", data->Interface);
86 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
88 return TRUE;
91 static BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
92 LPVOID context)
94 char descriptionA[0x100];
95 char moduleA[MAX_PATH];
97 trace(" found device:\n");
98 trace(" Type: %s\n",
99 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
100 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
101 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
102 trace(" DataFlow: %s\n",
103 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
104 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
105 "Capture" : "Unknown");
106 trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
107 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
108 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
109 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
110 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
111 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
112 trace(" DescriptionA: %s\n", data->DescriptionA);
113 WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
114 trace(" DescriptionW: %s\n", descriptionA);
115 trace(" ModuleA: %s\n", data->ModuleA);
116 WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
117 trace(" ModuleW: %s\n", moduleA);
118 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
120 return TRUE;
123 static BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
124 LPVOID context)
126 trace(" found device:\n");
127 trace(" Type: %s\n",
128 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
129 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
130 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
131 trace(" DataFlow: %s\n",
132 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
133 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
134 "Capture" : "Unknown");
135 trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
136 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
137 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
138 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
139 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
140 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
141 trace(" Description: %s\n", data->Description);
142 trace(" Module: %s\n", data->Module);
143 trace(" Interface: %s\n", data->Interface);
144 trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
146 return TRUE;
149 static BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
150 LPVOID context)
152 char descriptionA[0x100];
153 char moduleA[MAX_PATH];
154 char interfaceA[MAX_PATH];
156 trace("found device:\n");
157 trace("\tType: %s\n",
158 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
159 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
160 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
161 trace("\tDataFlow: %s\n",
162 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
163 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
164 "Capture" : "Unknown");
165 trace("\tDeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
166 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
167 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
168 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
169 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
170 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
171 WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
172 WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
173 WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
174 trace("\tDescription: %s\n", descriptionA);
175 trace("\tModule: %s\n", moduleA);
176 trace("\tInterface: %s\n", interfaceA);
177 trace("\tWaveDeviceId: %d\n", data->WaveDeviceId);
179 return TRUE;
182 static void propset_private_tests(void)
184 HRESULT rc;
185 IClassFactory * pcf;
186 IKsPropertySet * pps;
187 ULONG support;
189 /* try direct sound first */
190 /* DSOUND: Error: Invalid interface buffer */
191 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, NULL);
192 ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
193 "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
194 "returned: %08x\n",rc);
196 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IDirectSound, (void **)(&pcf));
197 ok(rc==E_NOINTERFACE,"DllGetClassObject(CLSID_DirectSound, "
198 "IID_IDirectSound) should have returned E_NOINTERFACE, "
199 "returned: %08x\n",rc);
201 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
202 ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
203 "IID_IUnknown) failed: %08x\n",rc);
205 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
206 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
207 "failed: %08x\n",rc);
208 if (pcf==0)
209 return;
211 /* direct sound doesn't have an IKsPropertySet */
212 /* DSOUND: Error: Invalid interface buffer */
213 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
214 NULL);
215 ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
216 "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
218 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
219 (void **)(&pps));
220 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
221 "returned E_NOINTERFACE, returned: %08x\n",rc);
223 /* and the direct sound 8 version */
224 if (pDirectSoundCreate8) {
225 rc = (pDllGetClassObject)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
226 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
227 "failed: %08x\n",rc);
228 if (pcf==0)
229 return;
231 /* direct sound 8 doesn't have an IKsPropertySet */
232 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
233 (void **)(&pps));
234 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
235 "returned E_NOINTERFACE, returned: %08x\n",rc);
238 /* try direct sound capture next */
239 if (pDirectSoundCaptureCreate) {
240 rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
241 (void **)(&pcf));
242 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
243 "failed: %08x\n",rc);
244 if (pcf==0)
245 return;
247 /* direct sound capture doesn't have an IKsPropertySet */
248 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
249 (void **)(&pps));
250 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
251 "returned E_NOINTERFACE,returned: %08x\n",rc);
254 /* and the direct sound capture 8 version */
255 if (pDirectSoundCaptureCreate8) {
256 rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
257 (void **)(&pcf));
258 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
259 "IID_IClassFactory) failed: %08x\n",rc);
260 if (pcf==0)
261 return;
263 /* direct sound capture 8 doesn't have an IKsPropertySet */
264 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
265 (void **)(&pps));
266 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
267 "returned E_NOINTERFACE, returned: %08x\n",rc);
270 /* try direct sound full duplex next */
271 if (pDirectSoundFullDuplexCreate) {
272 rc = (pDllGetClassObject)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
273 (void **)(&pcf));
274 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
275 "IID_IClassFactory) failed: %08x\n",rc);
276 if (pcf==0)
277 return;
279 /* direct sound full duplex doesn't have an IKsPropertySet */
280 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
281 (void **)(&pps));
282 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
283 "returned NOINTERFACE, returned: %08x\n",rc);
286 /* try direct sound private last */
287 rc = (pDllGetClassObject)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
288 (void **)(&pcf));
290 /* some early versions of Direct Sound do not have this */
291 if (rc==CLASS_E_CLASSNOTAVAILABLE)
292 return;
294 /* direct sound private does have an IKsPropertySet */
295 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
296 (void **)(&pps));
297 ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %08x\n",
298 rc);
299 if (rc!=DS_OK)
300 return;
302 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
303 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
304 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
305 &support);
306 ok(rc==DS_OK||rc==E_INVALIDARG,
307 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
308 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %08x\n",
309 rc);
310 if (rc!=DS_OK) {
311 if (rc==E_INVALIDARG)
312 trace(" Not Supported\n");
313 return;
316 ok(support & KSPROPERTY_SUPPORT_GET,
317 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
318 "support = 0x%x\n",support);
319 ok(!(support & KSPROPERTY_SUPPORT_SET),
320 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
321 "support = 0x%x\n",support);
323 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
324 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
325 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
326 &support);
327 ok(rc==DS_OK||rc==E_INVALIDARG,
328 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
329 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %08x\n",
330 rc);
331 if (rc!=DS_OK) {
332 if (rc==E_INVALIDARG)
333 trace(" Not Supported\n");
334 return;
337 ok(support & KSPROPERTY_SUPPORT_GET,
338 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
339 "support = 0x%x\n",support);
340 ok(!(support & KSPROPERTY_SUPPORT_SET),
341 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
342 "support = 0x%x\n",support);
344 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
345 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
346 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
347 &support);
348 ok(rc==DS_OK||rc==E_INVALIDARG,
349 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
350 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %08x\n",
351 rc);
352 if (rc!=DS_OK) {
353 if (rc==E_INVALIDARG)
354 trace(" Not Supported\n");
355 return;
358 ok(support & KSPROPERTY_SUPPORT_GET,
359 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
360 "support = 0x%x\n",support);
361 ok(!(support & KSPROPERTY_SUPPORT_SET),
362 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
363 "support = 0x%x\n",support);
365 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
366 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
367 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
368 &support);
369 ok(rc==DS_OK||rc==E_INVALIDARG,
370 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
371 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %08x\n",
372 rc);
373 if (rc!=DS_OK) {
374 if (rc==E_INVALIDARG)
375 trace(" Not Supported\n");
376 return;
379 ok(support & KSPROPERTY_SUPPORT_GET,
380 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
381 "support = 0x%x\n",support);
382 ok(!(support & KSPROPERTY_SUPPORT_SET),
383 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
384 "support = 0x%x\n",support);
386 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
387 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
388 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
389 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
390 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %08x\n",
391 rc);
392 if (rc!=DS_OK)
393 return;
395 ok(support & KSPROPERTY_SUPPORT_GET,
396 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
397 "support = 0x%x\n",support);
398 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
399 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
400 "0x%x\n",support);
402 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
403 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
404 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
405 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
406 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %08x\n",
407 rc);
408 if (rc!=DS_OK)
409 return;
411 ok(support & KSPROPERTY_SUPPORT_GET,
412 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
413 "support = 0x%x\n",support);
414 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
415 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
416 "0x%x\n",support);
418 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
419 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
420 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
421 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
422 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %08x\n",
423 rc);
424 if (rc!=DS_OK)
425 return;
427 ok(support & KSPROPERTY_SUPPORT_GET,
428 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
429 "support = 0x%x\n",support);
430 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
431 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
432 "0x%x\n",support);
434 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
435 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
436 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
437 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
438 &support);
439 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
440 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %08x\n",
441 rc);
442 if (rc!=DS_OK)
443 return;
445 ok(support & KSPROPERTY_SUPPORT_GET,
446 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
447 "support = 0x%x\n",support);
448 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
449 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%x\n",support);
451 if (support & KSPROPERTY_SUPPORT_GET) {
452 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
453 ULONG bytes;
455 data.Callback = callback;
456 data.Context = 0;
458 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
459 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
460 NULL, 0, &data, sizeof(data), &bytes);
461 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
464 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
465 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
466 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
467 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
468 &support);
469 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
470 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %08x\n",
471 rc);
472 if (rc!=DS_OK)
473 return;
475 ok(support & KSPROPERTY_SUPPORT_GET,
476 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
477 "support = 0x%x\n",support);
478 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
479 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%x\n",support);
481 if (support & KSPROPERTY_SUPPORT_GET) {
482 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
483 ULONG bytes;
485 data.Callback = callback1;
486 data.Context = 0;
488 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
489 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
490 NULL, 0, &data, sizeof(data), &bytes);
491 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
494 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
495 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
496 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
497 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
498 &support);
499 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
500 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %08x\n",
501 rc);
502 if (rc!=DS_OK)
503 return;
505 ok(support & KSPROPERTY_SUPPORT_GET,
506 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
507 "support = 0x%x\n",support);
508 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
509 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%x\n",support);
511 if (support & KSPROPERTY_SUPPORT_GET) {
512 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
513 ULONG bytes;
515 data.Callback = callbackA;
516 data.Context = 0;
518 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
519 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
520 NULL, 0, &data, sizeof(data), &bytes);
521 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
524 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
525 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
526 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
527 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
528 &support);
529 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
530 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %08x\n",
531 rc);
532 if (rc!=DS_OK)
533 return;
535 ok(support & KSPROPERTY_SUPPORT_GET,
536 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
537 "support = 0x%x\n",support);
538 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
539 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%x\n",support);
541 if (support & KSPROPERTY_SUPPORT_GET) {
542 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
543 ULONG bytes;
545 data.Callback = callbackW;
546 data.Context = 0;
548 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
549 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
550 NULL, 0, &data, sizeof(data), &bytes);
551 ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
553 IKsPropertySet_Release(pps);
556 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
557 LPCSTR lpcstrModule, LPVOID lpContext)
559 HRESULT rc;
560 LPDIRECTSOUND dso=NULL;
561 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
562 DSBUFFERDESC bufdesc;
563 WAVEFORMATEX wfx;
564 int ref;
566 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
568 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
569 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
570 "DirectSoundCreate() failed: %08x\n",rc);
571 if (rc!=DS_OK) {
572 if (rc==DSERR_NODRIVER)
573 trace(" No Driver\n");
574 else if (rc == DSERR_ALLOCATED)
575 trace(" Already In Use\n");
576 else if (rc == E_FAIL)
577 trace(" No Device\n");
578 goto EXIT;
581 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
582 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
583 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
584 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n",
585 rc);
586 if (rc!=DS_OK)
587 goto EXIT;
589 /* Testing 3D buffers */
590 primary=NULL;
591 ZeroMemory(&bufdesc, sizeof(bufdesc));
592 bufdesc.dwSize=sizeof(bufdesc);
593 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
594 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
595 ok((rc==DS_OK&&primary!=NULL)
596 || broken(rc==DSERR_INVALIDPARAM),
597 "IDirectSound_CreateSoundBuffer() failed to "
598 "create a hardware 3D primary buffer: %08x\n",rc);
599 if(rc==DSERR_INVALIDPARAM) {
600 skip("broken driver\n");
601 goto EXIT;
603 if (rc==DS_OK&&primary!=NULL) {
604 ZeroMemory(&wfx, sizeof(wfx));
605 wfx.wFormatTag=WAVE_FORMAT_PCM;
606 wfx.nChannels=1;
607 wfx.wBitsPerSample=16;
608 wfx.nSamplesPerSec=44100;
609 wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
610 wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
611 ZeroMemory(&bufdesc, sizeof(bufdesc));
612 bufdesc.dwSize=sizeof(bufdesc);
613 bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
614 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
615 bufdesc.lpwfxFormat=&wfx;
616 trace(" Testing a secondary buffer at %dx%dx%d\n",
617 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
618 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
619 ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
620 "failed to create a secondary buffer: %08x\n",rc);
621 if (rc==DS_OK&&secondary!=NULL) {
622 IKsPropertySet * pPropertySet=NULL;
623 rc=IDirectSoundBuffer_QueryInterface(secondary,
624 &IID_IKsPropertySet,
625 (void **)&pPropertySet);
626 /* it's not an error for this to fail */
627 if(rc==DS_OK) {
628 ULONG ulTypeSupport;
629 trace(" Supports property sets\n");
630 /* it's not an error for these to fail */
631 rc=IKsPropertySet_QuerySupport(pPropertySet,
632 &DSPROPSETID_VoiceManager,
633 0,&ulTypeSupport);
634 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
635 KSPROPERTY_SUPPORT_SET)))
636 trace(" DSPROPSETID_VoiceManager supported\n");
637 else
638 trace(" DSPROPSETID_VoiceManager not supported\n");
639 rc=IKsPropertySet_QuerySupport(pPropertySet,
640 &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
641 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
642 KSPROPERTY_SUPPORT_SET)))
643 trace(" DSPROPSETID_EAX20_ListenerProperties "
644 "supported\n");
645 else
646 trace(" DSPROPSETID_EAX20_ListenerProperties not "
647 "supported\n");
648 rc=IKsPropertySet_QuerySupport(pPropertySet,
649 &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
650 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
651 KSPROPERTY_SUPPORT_SET)))
652 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
653 else
654 trace(" DSPROPSETID_EAX20_BufferProperties not "
655 "supported\n");
656 rc=IKsPropertySet_QuerySupport(pPropertySet,
657 &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
658 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
659 KSPROPERTY_SUPPORT_SET)))
660 trace(" DSPROPSETID_I3DL2_ListenerProperties "
661 "supported\n");
662 else
663 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
664 "supported\n");
665 rc=IKsPropertySet_QuerySupport(pPropertySet,
666 &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
667 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
668 KSPROPERTY_SUPPORT_SET)))
669 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
670 else
671 trace(" DSPROPSETID_I3DL2_BufferProperties not "
672 "supported\n");
673 rc=IKsPropertySet_QuerySupport(pPropertySet,
674 &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
675 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
676 KSPROPERTY_SUPPORT_SET)))
677 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
678 "supported\n");
679 else
680 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
681 "supported\n");
682 ref=IKsPropertySet_Release(pPropertySet);
683 /* try a few common ones */
684 ok(ref==0,"IKsPropertySet_Release() secondary has %d "
685 "references, should have 0\n",ref);
686 } else
687 trace(" Doesn't support property sets\n");
689 ref=IDirectSoundBuffer_Release(secondary);
690 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
691 "references, should have 0\n",ref);
694 ref=IDirectSoundBuffer_Release(primary);
695 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
696 "should have 0\n",ref);
699 EXIT:
700 if (dso!=NULL) {
701 ref=IDirectSound_Release(dso);
702 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
703 ref);
705 return 1;
708 static void propset_buffer_tests(void)
710 HRESULT rc;
711 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
712 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
715 START_TEST(propset)
717 HMODULE hDsound;
719 CoInitialize(NULL);
721 hDsound = LoadLibrary("dsound.dll");
722 if (hDsound)
725 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
726 "DirectSoundEnumerateA");
727 pDllGetClassObject = (void *)GetProcAddress(hDsound,
728 "DllGetClassObject");
729 pDirectSoundCreate = (void*)GetProcAddress(hDsound,
730 "DirectSoundCreate");
731 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
732 "DirectSoundCreate8");
733 pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
734 "DirectSoundCaptureCreate");
735 pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,
736 "DirectSoundCaptureCreate8");
737 pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
738 "DirectSoundFullDuplexCreate");
740 propset_private_tests();
741 propset_buffer_tests();
743 FreeLibrary(hDsound);
745 else
746 skip("dsound.dll not found!\n");
748 CoUninitialize();