Assorted spelling fixes.
[wine/wine64.git] / dlls / dsound / tests / propset.c
blob2c11afa23b48b9d1382c9ed64e91fd13217ded27
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 NONAMELESSSTRUCT
23 #define NONAMELESSUNION
24 #define COBJMACROS
25 #include <windows.h>
27 #include "wine/test.h"
28 #include "dsound.h"
29 #include "initguid.h"
30 #include "dsconf.h"
31 #include "dxerr8.h"
33 #include "dsound_test.h"
35 #ifndef DSBCAPS_CTRLDEFAULT
36 #define DSBCAPS_CTRLDEFAULT \
37 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
38 #endif
40 DEFINE_GUID(DSPROPSETID_VoiceManager, \
41 0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
42 DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties, \
43 0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
44 DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties, \
45 0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
46 DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties, \
47 0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
48 DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties, \
49 0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
50 DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties, \
51 0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
53 typedef HRESULT (CALLBACK * MYPROC)(REFCLSID, REFIID, LPVOID *);
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 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: {%08lx-%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: %ld\n", data->WaveDeviceId);
88 return TRUE;
91 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: {%08lx-%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: %ld\n", data->WaveDeviceId);
120 return TRUE;
123 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: {%08lx-%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: %ld\n", data->WaveDeviceId);
146 return TRUE;
149 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: {%08lx-%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: %ld\n", data->WaveDeviceId);
179 return TRUE;
182 static void propset_private_tests(void)
184 HMODULE hDsound;
185 HRESULT rc;
186 IClassFactory * pcf;
187 IKsPropertySet * pps;
188 MYPROC fProc;
189 ULONG support;
191 hDsound = LoadLibrary("dsound.dll");
192 ok(hDsound!=0,"LoadLibrary(dsound.dll) failed\n");
193 if (hDsound==0)
194 return;
196 fProc = (MYPROC)GetProcAddress(hDsound, "DllGetClassObject");
198 /* try direct sound first */
199 /* DSOUND: Error: Invalid interface buffer */
200 rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)0);
201 ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
202 "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
203 "returned: %s\n",DXGetErrorString8(rc));
205 rc = (fProc)(&CLSID_DirectSound, &IID_IDirectSound, (void **)(&pcf));
206 ok(rc==E_NOINTERFACE,"DllGetClassObject(CLSID_DirectSound, "
207 "IID_IDirectSound) should have returned E_NOINTERFACE, "
208 "returned: %s\n",DXGetErrorString8(rc));
210 rc = (fProc)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
211 ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
212 "IID_IUnknown) failed: %s\n",DXGetErrorString8(rc));
214 rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
215 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
216 "failed: %s\n",DXGetErrorString8(rc));
217 if (pcf==0)
218 goto error;
220 /* direct sound doesn't have an IKsPropertySet */
221 /* DSOUND: Error: Invalid interface buffer */
222 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
223 (void **)0);
224 ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
225 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
227 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
228 (void **)(&pps));
229 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
230 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
232 /* and the direct sound 8 version */
233 if (pDirectSoundCreate8) {
234 rc = (fProc)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
235 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
236 "failed: %s\n",DXGetErrorString8(rc));
237 if (pcf==0)
238 goto error;
240 /* direct sound 8 doesn't have an IKsPropertySet */
241 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
242 (void **)(&pps));
243 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
244 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
247 /* try direct sound capture next */
248 if (pDirectSoundCaptureCreate) {
249 rc = (fProc)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
250 (void **)(&pcf));
251 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
252 "failed: %s\n",DXGetErrorString8(rc));
253 if (pcf==0)
254 goto error;
256 /* direct sound capture doesn't have an IKsPropertySet */
257 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
258 (void **)(&pps));
259 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
260 "returned E_NOINTERFACE,returned: %s\n",DXGetErrorString8(rc));
263 /* and the direct sound capture 8 version */
264 if (pDirectSoundCaptureCreate8) {
265 rc = (fProc)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
266 (void **)(&pcf));
267 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
268 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
269 if (pcf==0)
270 goto error;
272 /* direct sound capture 8 doesn't have an IKsPropertySet */
273 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
274 (void **)(&pps));
275 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
276 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
279 /* try direct sound full duplex next */
280 if (pDirectSoundFullDuplexCreate) {
281 rc = (fProc)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
282 (void **)(&pcf));
283 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
284 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
285 if (pcf==0)
286 goto error;
288 /* direct sound full duplex doesn't have an IKsPropertySet */
289 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
290 (void **)(&pps));
291 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
292 "returned NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
295 /* try direct sound private last */
296 rc = (fProc)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
297 (void **)(&pcf));
299 /* some early versions of Direct Sound do not have this */
300 if (pcf==0)
301 goto error;
303 /* direct sound private does have an IKsPropertySet */
304 rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
305 (void **)(&pps));
306 ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %s\n",
307 DXGetErrorString8(rc));
308 if (rc!=DS_OK)
309 goto error;
311 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
312 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
313 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
314 &support);
315 ok(rc==DS_OK||rc==E_INVALIDARG,
316 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
317 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %s\n",
318 DXGetErrorString8(rc));
319 if (rc!=DS_OK) {
320 if (rc==E_INVALIDARG)
321 trace(" Not Supported\n");
322 goto error;
325 ok(support & KSPROPERTY_SUPPORT_GET,
326 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
327 "support = 0x%lx\n",support);
328 ok(!(support & KSPROPERTY_SUPPORT_SET),
329 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
330 "support = 0x%lx\n",support);
332 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
333 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
334 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
335 &support);
336 ok(rc==DS_OK||rc==E_INVALIDARG,
337 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
338 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %s\n",
339 DXGetErrorString8(rc));
340 if (rc!=DS_OK) {
341 if (rc==E_INVALIDARG)
342 trace(" Not Supported\n");
343 goto error;
346 ok(support & KSPROPERTY_SUPPORT_GET,
347 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
348 "support = 0x%lx\n",support);
349 ok(!(support & KSPROPERTY_SUPPORT_SET),
350 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
351 "support = 0x%lx\n",support);
353 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
354 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
355 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
356 &support);
357 ok(rc==DS_OK||rc==E_INVALIDARG,
358 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
359 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %s\n",
360 DXGetErrorString8(rc));
361 if (rc!=DS_OK) {
362 if (rc==E_INVALIDARG)
363 trace(" Not Supported\n");
364 goto error;
367 ok(support & KSPROPERTY_SUPPORT_GET,
368 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
369 "support = 0x%lx\n",support);
370 ok(!(support & KSPROPERTY_SUPPORT_SET),
371 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
372 "support = 0x%lx\n",support);
374 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
375 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
376 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
377 &support);
378 ok(rc==DS_OK||rc==E_INVALIDARG,
379 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
380 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %s\n",
381 DXGetErrorString8(rc));
382 if (rc!=DS_OK) {
383 if (rc==E_INVALIDARG)
384 trace(" Not Supported\n");
385 goto error;
388 ok(support & KSPROPERTY_SUPPORT_GET,
389 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
390 "support = 0x%lx\n",support);
391 ok(!(support & KSPROPERTY_SUPPORT_SET),
392 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
393 "support = 0x%lx\n",support);
395 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
396 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
397 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
398 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
399 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %s\n",
400 DXGetErrorString8(rc));
401 if (rc!=DS_OK)
402 goto error;
404 ok(support & KSPROPERTY_SUPPORT_GET,
405 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
406 "support = 0x%lx\n",support);
407 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
408 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
409 "0x%lx\n",support);
411 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
412 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
413 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
414 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
415 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %s\n",
416 DXGetErrorString8(rc));
417 if (rc!=DS_OK)
418 goto error;
420 ok(support & KSPROPERTY_SUPPORT_GET,
421 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
422 "support = 0x%lx\n",support);
423 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
424 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
425 "0x%lx\n",support);
427 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
428 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
429 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
430 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
431 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %s\n",
432 DXGetErrorString8(rc));
433 if (rc!=DS_OK)
434 goto error;
436 ok(support & KSPROPERTY_SUPPORT_GET,
437 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
438 "support = 0x%lx\n",support);
439 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
440 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
441 "0x%lx\n",support);
443 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
444 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
445 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
446 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
447 &support);
448 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
449 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %s\n",
450 DXGetErrorString8(rc));
451 if (rc!=DS_OK)
452 goto error;
454 ok(support & KSPROPERTY_SUPPORT_GET,
455 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
456 "support = 0x%lx\n",support);
457 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
458 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%lx\n",support);
460 if (support & KSPROPERTY_SUPPORT_GET) {
461 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
462 ULONG bytes;
464 data.Callback = callback;
465 data.Context = 0;
467 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
468 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
469 NULL, 0, &data, sizeof(data), &bytes);
470 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
473 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
474 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
475 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
476 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
477 &support);
478 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
479 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %s\n",
480 DXGetErrorString8(rc));
481 if (rc!=DS_OK)
482 goto error;
484 ok(support & KSPROPERTY_SUPPORT_GET,
485 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
486 "support = 0x%lx\n",support);
487 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
488 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%lx\n",support);
490 if (support & KSPROPERTY_SUPPORT_GET) {
491 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
492 ULONG bytes;
494 data.Callback = callback1;
495 data.Context = 0;
497 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
498 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
499 NULL, 0, &data, sizeof(data), &bytes);
500 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
503 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
504 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
505 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
506 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
507 &support);
508 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
509 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %s\n",
510 DXGetErrorString8(rc));
511 if (rc!=DS_OK)
512 goto error;
514 ok(support & KSPROPERTY_SUPPORT_GET,
515 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
516 "support = 0x%lx\n",support);
517 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
518 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%lx\n",support);
520 if (support & KSPROPERTY_SUPPORT_GET) {
521 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
522 ULONG bytes;
524 data.Callback = callbackA;
525 data.Context = 0;
527 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
528 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
529 NULL, 0, &data, sizeof(data), &bytes);
530 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
533 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
534 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
535 rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
536 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
537 &support);
538 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
539 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %s\n",
540 DXGetErrorString8(rc));
541 if (rc!=DS_OK)
542 goto error;
544 ok(support & KSPROPERTY_SUPPORT_GET,
545 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
546 "support = 0x%lx\n",support);
547 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
548 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%lx\n",support);
550 if (support & KSPROPERTY_SUPPORT_GET) {
551 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
552 ULONG bytes;
554 data.Callback = callbackW;
555 data.Context = 0;
557 rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
558 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
559 NULL, 0, &data, sizeof(data), &bytes);
560 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
563 error:
564 FreeLibrary(hDsound);
567 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
568 LPCSTR lpcstrModule, LPVOID lpContext)
570 HRESULT rc;
571 LPDIRECTSOUND dso=NULL;
572 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
573 DSBUFFERDESC bufdesc;
574 WAVEFORMATEX wfx;
575 int ref;
577 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
579 rc=DirectSoundCreate(lpGuid,&dso,NULL);
580 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
581 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
582 if (rc!=DS_OK) {
583 if (rc==DSERR_NODRIVER)
584 trace(" No Driver\n");
585 else if (rc == DSERR_ALLOCATED)
586 trace(" Already In Use\n");
587 else if (rc == E_FAIL)
588 trace(" No Device\n");
589 goto EXIT;
592 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
593 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
594 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
595 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
596 DXGetErrorString8(rc));
597 if (rc!=DS_OK)
598 goto EXIT;
600 /* Testing 3D buffers */
601 primary=NULL;
602 ZeroMemory(&bufdesc, sizeof(bufdesc));
603 bufdesc.dwSize=sizeof(bufdesc);
604 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
605 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
606 ok(rc==DS_OK&&primary!=NULL,"IDirectSound_CreateSoundBuffer() failed to "
607 "create a hardware 3D primary buffer: %s\n",DXGetErrorString8(rc));
608 if (rc==DS_OK&&primary!=NULL) {
609 ZeroMemory(&wfx, sizeof(wfx));
610 wfx.wFormatTag=WAVE_FORMAT_PCM;
611 wfx.nChannels=1;
612 wfx.wBitsPerSample=16;
613 wfx.nSamplesPerSec=44100;
614 wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
615 wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
616 ZeroMemory(&bufdesc, sizeof(bufdesc));
617 bufdesc.dwSize=sizeof(bufdesc);
618 bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
619 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
620 bufdesc.lpwfxFormat=&wfx;
621 trace(" Testing a secondary buffer at %ldx%dx%d\n",
622 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
623 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
624 ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
625 "failed to create a secondary buffer: %s\n",DXGetErrorString8(rc));
626 if (rc==DS_OK&&secondary!=NULL) {
627 IKsPropertySet * pPropertySet=NULL;
628 rc=IDirectSoundBuffer_QueryInterface(secondary,
629 &IID_IKsPropertySet,
630 (void **)&pPropertySet);
631 /* it's not an error for this to fail */
632 if(rc==DS_OK) {
633 ULONG ulTypeSupport;
634 trace(" Supports property sets\n");
635 /* it's not an error for these to fail */
636 rc=IKsPropertySet_QuerySupport(pPropertySet,
637 &DSPROPSETID_VoiceManager,
638 0,&ulTypeSupport);
639 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
640 KSPROPERTY_SUPPORT_SET)))
641 trace(" DSPROPSETID_VoiceManager supported\n");
642 else
643 trace(" DSPROPSETID_VoiceManager not supported\n");
644 rc=IKsPropertySet_QuerySupport(pPropertySet,
645 &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
646 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
647 KSPROPERTY_SUPPORT_SET)))
648 trace(" DSPROPSETID_EAX20_ListenerProperties "
649 "supported\n");
650 else
651 trace(" DSPROPSETID_EAX20_ListenerProperties not "
652 "supported\n");
653 rc=IKsPropertySet_QuerySupport(pPropertySet,
654 &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
655 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
656 KSPROPERTY_SUPPORT_SET)))
657 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
658 else
659 trace(" DSPROPSETID_EAX20_BufferProperties not "
660 "supported\n");
661 rc=IKsPropertySet_QuerySupport(pPropertySet,
662 &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
663 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
664 KSPROPERTY_SUPPORT_SET)))
665 trace(" DSPROPSETID_I3DL2_ListenerProperties "
666 "supported\n");
667 else
668 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
669 "supported\n");
670 rc=IKsPropertySet_QuerySupport(pPropertySet,
671 &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
672 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
673 KSPROPERTY_SUPPORT_SET)))
674 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
675 else
676 trace(" DSPROPSETID_I3DL2_BufferProperties not "
677 "supported\n");
678 rc=IKsPropertySet_QuerySupport(pPropertySet,
679 &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
680 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
681 KSPROPERTY_SUPPORT_SET)))
682 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
683 "supported\n");
684 else
685 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
686 "supported\n");
687 ref=IKsPropertySet_Release(pPropertySet);
688 /* try a few common ones */
689 ok(ref==0,"IKsPropertySet_Release() secondary has %d "
690 "references, should have 0\n",ref);
691 } else
692 trace(" Doesn't support property sets\n");
694 ref=IDirectSoundBuffer_Release(secondary);
695 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
696 "references, should have 0\n",ref);
699 ref=IDirectSoundBuffer_Release(primary);
700 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
701 "should have 0\n",ref);
704 EXIT:
705 if (dso!=NULL) {
706 ref=IDirectSound_Release(dso);
707 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
708 ref);
710 return 1;
713 static void propset_buffer_tests(void)
715 HRESULT rc;
716 rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
717 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
720 START_TEST(propset)
722 HMODULE hDsound;
724 CoInitialize(NULL);
726 hDsound = LoadLibraryA("dsound.dll");
727 if (!hDsound) {
728 trace("dsound.dll not found\n");
729 return;
732 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
734 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
735 pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
736 pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate8");
737 pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,"DirectSoundFullDuplexCreate");
739 propset_private_tests();
740 propset_buffer_tests();
742 CoUninitialize();