Merge from amd64 branch:
[reactos.git] / rostests / winetests / dsound / propset.c
1 /*
2 * Unit tests for CLSID_DirectSoundPrivate property set functions
3 * (used by dxdiag)
4 *
5 * Copyright (c) 2003 Robert Reif
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #define COBJMACROS
23 #include <windows.h>
24
25 #include "wine/test.h"
26 #include "dsound.h"
27 #include "dsconf.h"
28
29 #include "dsound_test.h"
30
31 #ifndef DSBCAPS_CTRLDEFAULT
32 #define DSBCAPS_CTRLDEFAULT \
33 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
34 #endif
35
36 #include "initguid.h"
37
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);
50
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;
64
65 static BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
66 LPVOID context)
67 {
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);
87
88 return TRUE;
89 }
90
91 static BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
92 LPVOID context)
93 {
94 char descriptionA[0x100];
95 char moduleA[MAX_PATH];
96
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);
119
120 return TRUE;
121 }
122
123 static BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
124 LPVOID context)
125 {
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);
145
146 return TRUE;
147 }
148
149 static BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
150 LPVOID context)
151 {
152 char descriptionA[0x100];
153 char moduleA[MAX_PATH];
154 char interfaceA[MAX_PATH];
155
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);
178
179 return TRUE;
180 }
181
182 static void propset_private_tests(void)
183 {
184 HRESULT rc;
185 IClassFactory * pcf;
186 IKsPropertySet * pps;
187 ULONG support;
188
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);
195
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);
200
201 rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
202 ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
203 "IID_IUnknown) failed: %08x\n",rc);
204
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;
210
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);
217
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);
222
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;
230
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);
236 }
237
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;
246
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);
252 }
253
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;
262
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);
268 }
269
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;
278
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);
284 }
285
286 /* try direct sound private last */
287 rc = (pDllGetClassObject)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
288 (void **)(&pcf));
289
290 /* some early versions of Direct Sound do not have this */
291 if (rc==CLASS_E_CLASSNOTAVAILABLE)
292 return;
293
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;
301
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;
314 }
315
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);
322
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;
335 }
336
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);
343
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;
356 }
357
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);
364
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;
377 }
378
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);
385
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;
394
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);
401
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;
410
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);
417
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;
426
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);
433
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;
444
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);
450
451 if (support & KSPROPERTY_SUPPORT_GET) {
452 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
453 ULONG bytes;
454
455 data.Callback = callback;
456 data.Context = 0;
457
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);
462 }
463
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;
474
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);
480
481 if (support & KSPROPERTY_SUPPORT_GET) {
482 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
483 ULONG bytes;
484
485 data.Callback = callback1;
486 data.Context = 0;
487
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);
492 }
493
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;
504
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);
510
511 if (support & KSPROPERTY_SUPPORT_GET) {
512 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
513 ULONG bytes;
514
515 data.Callback = callbackA;
516 data.Context = 0;
517
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);
522 }
523
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;
534
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);
540
541 if (support & KSPROPERTY_SUPPORT_GET) {
542 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
543 ULONG bytes;
544
545 data.Callback = callbackW;
546 data.Context = 0;
547
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);
552 }
553 }
554
555 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
556 LPCSTR lpcstrModule, LPVOID lpContext)
557 {
558 HRESULT rc;
559 LPDIRECTSOUND dso=NULL;
560 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
561 DSBUFFERDESC bufdesc;
562 WAVEFORMATEX wfx;
563 int ref;
564
565 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
566
567 rc=pDirectSoundCreate(lpGuid,&dso,NULL);
568 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
569 "DirectSoundCreate() failed: %08x\n",rc);
570 if (rc!=DS_OK) {
571 if (rc==DSERR_NODRIVER)
572 trace(" No Driver\n");
573 else if (rc == DSERR_ALLOCATED)
574 trace(" Already In Use\n");
575 else if (rc == E_FAIL)
576 trace(" No Device\n");
577 goto EXIT;
578 }
579
580 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
581 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
582 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
583 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n",
584 rc);
585 if (rc!=DS_OK)
586 goto EXIT;
587
588 /* Testing 3D buffers */
589 primary=NULL;
590 ZeroMemory(&bufdesc, sizeof(bufdesc));
591 bufdesc.dwSize=sizeof(bufdesc);
592 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
593 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
594 ok((rc==DS_OK&&primary!=NULL)
595 || broken(rc==DSERR_INVALIDPARAM),
596 "IDirectSound_CreateSoundBuffer() failed to "
597 "create a hardware 3D primary buffer: %08x\n",rc);
598 if(rc==DSERR_INVALIDPARAM) {
599 skip("broken driver\n");
600 goto EXIT;
601 }
602 if (rc==DS_OK&&primary!=NULL) {
603 ZeroMemory(&wfx, sizeof(wfx));
604 wfx.wFormatTag=WAVE_FORMAT_PCM;
605 wfx.nChannels=1;
606 wfx.wBitsPerSample=16;
607 wfx.nSamplesPerSec=44100;
608 wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
609 wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
610 ZeroMemory(&bufdesc, sizeof(bufdesc));
611 bufdesc.dwSize=sizeof(bufdesc);
612 bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
613 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
614 bufdesc.lpwfxFormat=&wfx;
615 trace(" Testing a secondary buffer at %dx%dx%d\n",
616 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
617 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
618 ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
619 "failed to create a secondary buffer: %08x\n",rc);
620 if (rc==DS_OK&&secondary!=NULL) {
621 IKsPropertySet * pPropertySet=NULL;
622 rc=IDirectSoundBuffer_QueryInterface(secondary,
623 &IID_IKsPropertySet,
624 (void **)&pPropertySet);
625 /* it's not an error for this to fail */
626 if(rc==DS_OK) {
627 ULONG ulTypeSupport;
628 trace(" Supports property sets\n");
629 /* it's not an error for these to fail */
630 rc=IKsPropertySet_QuerySupport(pPropertySet,
631 &DSPROPSETID_VoiceManager,
632 0,&ulTypeSupport);
633 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
634 KSPROPERTY_SUPPORT_SET)))
635 trace(" DSPROPSETID_VoiceManager supported\n");
636 else
637 trace(" DSPROPSETID_VoiceManager not supported\n");
638 rc=IKsPropertySet_QuerySupport(pPropertySet,
639 &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
640 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
641 KSPROPERTY_SUPPORT_SET)))
642 trace(" DSPROPSETID_EAX20_ListenerProperties "
643 "supported\n");
644 else
645 trace(" DSPROPSETID_EAX20_ListenerProperties not "
646 "supported\n");
647 rc=IKsPropertySet_QuerySupport(pPropertySet,
648 &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
649 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
650 KSPROPERTY_SUPPORT_SET)))
651 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
652 else
653 trace(" DSPROPSETID_EAX20_BufferProperties not "
654 "supported\n");
655 rc=IKsPropertySet_QuerySupport(pPropertySet,
656 &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
657 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
658 KSPROPERTY_SUPPORT_SET)))
659 trace(" DSPROPSETID_I3DL2_ListenerProperties "
660 "supported\n");
661 else
662 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
663 "supported\n");
664 rc=IKsPropertySet_QuerySupport(pPropertySet,
665 &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
666 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
667 KSPROPERTY_SUPPORT_SET)))
668 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
669 else
670 trace(" DSPROPSETID_I3DL2_BufferProperties not "
671 "supported\n");
672 rc=IKsPropertySet_QuerySupport(pPropertySet,
673 &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
674 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
675 KSPROPERTY_SUPPORT_SET)))
676 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
677 "supported\n");
678 else
679 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
680 "supported\n");
681 ref=IKsPropertySet_Release(pPropertySet);
682 /* try a few common ones */
683 ok(ref==0,"IKsPropertySet_Release() secondary has %d "
684 "references, should have 0\n",ref);
685 } else
686 trace(" Doesn't support property sets\n");
687
688 ref=IDirectSoundBuffer_Release(secondary);
689 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
690 "references, should have 0\n",ref);
691 }
692
693 ref=IDirectSoundBuffer_Release(primary);
694 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
695 "should have 0\n",ref);
696 }
697
698 EXIT:
699 if (dso!=NULL) {
700 ref=IDirectSound_Release(dso);
701 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
702 ref);
703 }
704 return 1;
705 }
706
707 static void propset_buffer_tests(void)
708 {
709 HRESULT rc;
710 rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
711 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
712 }
713
714 START_TEST(propset)
715 {
716 HMODULE hDsound;
717
718 CoInitialize(NULL);
719
720 hDsound = LoadLibrary("dsound.dll");
721 if (hDsound)
722 {
723
724 pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
725 "DirectSoundEnumerateA");
726 pDllGetClassObject = (void *)GetProcAddress(hDsound,
727 "DllGetClassObject");
728 pDirectSoundCreate = (void*)GetProcAddress(hDsound,
729 "DirectSoundCreate");
730 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
731 "DirectSoundCreate8");
732 pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
733 "DirectSoundCaptureCreate");
734 pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,
735 "DirectSoundCaptureCreate8");
736 pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
737 "DirectSoundFullDuplexCreate");
738
739 propset_private_tests();
740 propset_buffer_tests();
741
742 FreeLibrary(hDsound);
743 }
744 else
745 skip("dsound.dll not found!\n");
746
747 CoUninitialize();
748 }