Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / dsound / tests / propset.c
blob207b976332c9294e19ea8b20c089e8d07fa5c055
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define NONAMELESSSTRUCT
23 #define NONAMELESSUNION
24 #include <windows.h>
26 #include "wine/test.h"
27 #include "dsound.h"
28 #include "initguid.h"
29 #include "dsconf.h"
30 #include "dxerr8.h"
32 #include "dsound_test.h"
34 #ifndef DSBCAPS_CTRLDEFAULT
35 #define DSBCAPS_CTRLDEFAULT \
36 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
37 #endif
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 typedef HRESULT (CALLBACK * MYPROC)(REFCLSID, REFIID, LPVOID *);
54 static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
55 LPUNKNOWN)=NULL;
56 static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
57 LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
58 static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
59 LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
60 static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
61 LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
62 LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
64 BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
65 LPVOID context)
67 trace(" found device:\n");
68 trace(" Type: %s\n",
69 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
70 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
71 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
72 trace(" DataFlow: %s\n",
73 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
74 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
75 "Capture" : "Unknown");
76 trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
77 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
78 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
79 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
80 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
81 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
82 trace(" Description: %s\n", data->Description);
83 trace(" Module: %s\n", data->Module);
84 trace(" Interface: %s\n", data->Interface);
85 trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
87 return TRUE;
90 BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
91 LPVOID context)
93 char descriptionA[0x100];
94 char moduleA[MAX_PATH];
96 trace(" found device:\n");
97 trace(" Type: %s\n",
98 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
99 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
100 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
101 trace(" DataFlow: %s\n",
102 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
103 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
104 "Capture" : "Unknown");
105 trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
106 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
107 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
108 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
109 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
110 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
111 trace(" DescriptionA: %s\n", data->DescriptionA);
112 WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
113 trace(" DescriptionW: %s\n", descriptionA);
114 trace(" ModuleA: %s\n", data->ModuleA);
115 WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
116 trace(" ModuleW: %s\n", moduleA);
117 trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
119 return TRUE;
122 BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
123 LPVOID context)
125 trace(" found device:\n");
126 trace(" Type: %s\n",
127 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
128 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
129 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
130 trace(" DataFlow: %s\n",
131 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
132 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
133 "Capture" : "Unknown");
134 trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
135 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
136 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
137 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
138 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
139 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
140 trace(" Description: %s\n", data->Description);
141 trace(" Module: %s\n", data->Module);
142 trace(" Interface: %s\n", data->Interface);
143 trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
145 return TRUE;
148 BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
149 LPVOID context)
151 char descriptionA[0x100];
152 char moduleA[MAX_PATH];
153 char interfaceA[MAX_PATH];
155 trace("found device:\n");
156 trace("\tType: %s\n",
157 data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
158 data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
159 data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
160 trace("\tDataFlow: %s\n",
161 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
162 data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
163 "Capture" : "Unknown");
164 trace("\tDeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
165 data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
166 data->DeviceId.Data4[0],data->DeviceId.Data4[1],
167 data->DeviceId.Data4[2],data->DeviceId.Data4[3],
168 data->DeviceId.Data4[4],data->DeviceId.Data4[5],
169 data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
170 WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
171 WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
172 WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
173 trace("\tDescription: %s\n", descriptionA);
174 trace("\tModule: %s\n", moduleA);
175 trace("\tInterface: %s\n", interfaceA);
176 trace("\tWaveDeviceId: %ld\n", data->WaveDeviceId);
178 return TRUE;
181 static void propset_private_tests()
183 HMODULE hDsound;
184 HRESULT rc;
185 IClassFactory * pcf;
186 IKsPropertySet * pps;
187 MYPROC fProc;
188 ULONG support;
190 hDsound = LoadLibrary("dsound.dll");
191 ok(hDsound!=0,"LoadLibrary(dsound.dll) failed\n");
192 if (hDsound==0)
193 return;
195 fProc = (MYPROC)GetProcAddress(hDsound, "DllGetClassObject");
197 /* try direct sound first */
198 /* DSOUND: Error: Invalid interface buffer */
199 rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)0);
200 ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
201 "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
202 "returned: %s\n",DXGetErrorString8(rc));
204 rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
205 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
206 "failed: %s\n",DXGetErrorString8(rc));
207 if (pcf==0)
208 goto error;
210 /* direct sound doesn't have an IKsPropertySet */
211 /* DSOUND: Error: Invalid interface buffer */
212 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
213 (void **)0);
214 ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
215 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
217 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
218 (void **)(&pps));
219 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
220 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
222 /* and the direct sound 8 version */
223 if (pDirectSoundCreate8) {
224 rc = (fProc)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
225 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
226 "failed: %s\n",DXGetErrorString8(rc));
227 if (pcf==0)
228 goto error;
230 /* direct sound 8 doesn't have an IKsPropertySet */
231 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
232 (void **)(&pps));
233 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
234 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
237 /* try direct sound capture next */
238 if (pDirectSoundCaptureCreate) {
239 rc = (fProc)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
240 (void **)(&pcf));
241 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
242 "failed: %s\n",DXGetErrorString8(rc));
243 if (pcf==0)
244 goto error;
246 /* direct sound capture doesn't have an IKsPropertySet */
247 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
248 (void **)(&pps));
249 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
250 "returned E_NOINTERFACE,returned: %s\n",DXGetErrorString8(rc));
253 /* and the direct sound capture 8 version */
254 if (pDirectSoundCaptureCreate8) {
255 rc = (fProc)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
256 (void **)(&pcf));
257 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
258 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
259 if (pcf==0)
260 goto error;
262 /* direct sound capture 8 doesn't have an IKsPropertySet */
263 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
264 (void **)(&pps));
265 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
266 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
269 /* try direct sound full duplex next */
270 if (pDirectSoundFullDuplexCreate) {
271 rc = (fProc)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
272 (void **)(&pcf));
273 ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
274 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
275 if (pcf==0)
276 goto error;
278 /* direct sound full duplex doesn't have an IKsPropertySet */
279 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
280 (void **)(&pps));
281 ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
282 "returned NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
285 /* try direct sound private last */
286 rc = (fProc)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
287 (void **)(&pcf));
289 /* some early versions of Direct Sound do not have this */
290 if (pcf==0)
291 goto error;
293 /* direct sound private does have an IKsPropertySet */
294 rc = pcf->lpVtbl->CreateInstance(pcf, NULL, &IID_IKsPropertySet,
295 (void **)(&pps));
296 ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %s\n",
297 DXGetErrorString8(rc));
298 if (rc!=DS_OK)
299 goto error;
301 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
302 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
303 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
304 &support);
305 ok(rc==DS_OK||rc==E_INVALIDARG,
306 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
307 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %s\n",
308 DXGetErrorString8(rc));
309 if (rc!=DS_OK) {
310 if (rc==E_INVALIDARG)
311 trace(" Not Supported\n");
312 goto error;
315 ok(support & KSPROPERTY_SUPPORT_GET,
316 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
317 "support = 0x%lx\n",support);
318 ok(!(support & KSPROPERTY_SUPPORT_SET),
319 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
320 "support = 0x%lx\n",support);
322 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
323 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
324 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
325 &support);
326 ok(rc==DS_OK||rc==E_INVALIDARG,
327 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
328 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %s\n",
329 DXGetErrorString8(rc));
330 if (rc!=DS_OK) {
331 if (rc==E_INVALIDARG)
332 trace(" Not Supported\n");
333 goto error;
336 ok(support & KSPROPERTY_SUPPORT_GET,
337 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
338 "support = 0x%lx\n",support);
339 ok(!(support & KSPROPERTY_SUPPORT_SET),
340 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
341 "support = 0x%lx\n",support);
343 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
344 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
345 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
346 &support);
347 ok(rc==DS_OK||rc==E_INVALIDARG,
348 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
349 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %s\n",
350 DXGetErrorString8(rc));
351 if (rc!=DS_OK) {
352 if (rc==E_INVALIDARG)
353 trace(" Not Supported\n");
354 goto error;
357 ok(support & KSPROPERTY_SUPPORT_GET,
358 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
359 "support = 0x%lx\n",support);
360 ok(!(support & KSPROPERTY_SUPPORT_SET),
361 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
362 "support = 0x%lx\n",support);
364 /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
365 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
366 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
367 &support);
368 ok(rc==DS_OK||rc==E_INVALIDARG,
369 "QuerySupport(DSPROPSETID_DirectSoundDevice, "
370 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %s\n",
371 DXGetErrorString8(rc));
372 if (rc!=DS_OK) {
373 if (rc==E_INVALIDARG)
374 trace(" Not Supported\n");
375 goto error;
378 ok(support & KSPROPERTY_SUPPORT_GET,
379 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
380 "support = 0x%lx\n",support);
381 ok(!(support & KSPROPERTY_SUPPORT_SET),
382 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
383 "support = 0x%lx\n",support);
385 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
386 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
387 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
388 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
389 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %s\n",
390 DXGetErrorString8(rc));
391 if (rc!=DS_OK)
392 goto error;
394 ok(support & KSPROPERTY_SUPPORT_GET,
395 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
396 "support = 0x%lx\n",support);
397 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
398 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
399 "0x%lx\n",support);
401 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
402 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
403 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
404 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
405 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %s\n",
406 DXGetErrorString8(rc));
407 if (rc!=DS_OK)
408 goto error;
410 ok(support & KSPROPERTY_SUPPORT_GET,
411 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
412 "support = 0x%lx\n",support);
413 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
414 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
415 "0x%lx\n",support);
417 /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
418 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
419 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
420 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
421 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %s\n",
422 DXGetErrorString8(rc));
423 if (rc!=DS_OK)
424 goto error;
426 ok(support & KSPROPERTY_SUPPORT_GET,
427 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
428 "support = 0x%lx\n",support);
429 ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
430 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
431 "0x%lx\n",support);
433 /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
434 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
435 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
436 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
437 &support);
438 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
439 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %s\n",
440 DXGetErrorString8(rc));
441 if (rc!=DS_OK)
442 goto error;
444 ok(support & KSPROPERTY_SUPPORT_GET,
445 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
446 "support = 0x%lx\n",support);
447 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
448 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%lx\n",support);
450 if (support & KSPROPERTY_SUPPORT_GET) {
451 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
452 ULONG bytes;
454 data.Callback = callback;
455 data.Context = 0;
457 rc = pps->lpVtbl->Get(pps, &DSPROPSETID_DirectSoundDevice,
458 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
459 NULL, 0, &data, sizeof(data), &bytes);
460 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
463 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
464 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
465 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
466 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
467 &support);
468 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
469 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %s\n",
470 DXGetErrorString8(rc));
471 if (rc!=DS_OK)
472 goto error;
474 ok(support & KSPROPERTY_SUPPORT_GET,
475 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
476 "support = 0x%lx\n",support);
477 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
478 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%lx\n",support);
480 if (support & KSPROPERTY_SUPPORT_GET) {
481 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
482 ULONG bytes;
484 data.Callback = callback1;
485 data.Context = 0;
487 rc = pps->lpVtbl->Get(pps, &DSPROPSETID_DirectSoundDevice,
488 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
489 NULL, 0, &data, sizeof(data), &bytes);
490 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
493 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
494 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
495 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
496 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
497 &support);
498 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
499 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %s\n",
500 DXGetErrorString8(rc));
501 if (rc!=DS_OK)
502 goto error;
504 ok(support & KSPROPERTY_SUPPORT_GET,
505 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
506 "support = 0x%lx\n",support);
507 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
508 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%lx\n",support);
510 if (support & KSPROPERTY_SUPPORT_GET) {
511 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
512 ULONG bytes;
514 data.Callback = callbackA;
515 data.Context = 0;
517 rc = pps->lpVtbl->Get(pps, &DSPROPSETID_DirectSoundDevice,
518 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
519 NULL, 0, &data, sizeof(data), &bytes);
520 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
523 /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
524 trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
525 rc = pps->lpVtbl->QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
526 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
527 &support);
528 ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
529 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %s\n",
530 DXGetErrorString8(rc));
531 if (rc!=DS_OK)
532 goto error;
534 ok(support & KSPROPERTY_SUPPORT_GET,
535 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
536 "support = 0x%lx\n",support);
537 ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
538 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%lx\n",support);
540 if (support & KSPROPERTY_SUPPORT_GET) {
541 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
542 ULONG bytes;
544 data.Callback = callbackW;
545 data.Context = 0;
547 rc = pps->lpVtbl->Get(pps, &DSPROPSETID_DirectSoundDevice,
548 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
549 NULL, 0, &data, sizeof(data), &bytes);
550 ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
553 error:
554 FreeLibrary(hDsound);
557 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
558 LPCSTR lpcstrModule, LPVOID lpContext)
560 HRESULT rc;
561 LPDIRECTSOUND dso=NULL;
562 LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
563 DSBUFFERDESC bufdesc;
564 WAVEFORMATEX wfx;
565 int ref;
567 trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
569 rc=DirectSoundCreate(lpGuid,&dso,NULL);
570 ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
571 "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
572 if (rc!=DS_OK) {
573 if (rc==DSERR_NODRIVER)
574 trace(" No Driver\n");
575 else if (rc == DSERR_ALLOCATED)
576 trace(" Already In Use\n");
577 else if (rc == E_FAIL)
578 trace(" No Device\n");
579 goto EXIT;
582 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
583 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
584 rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
585 ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
586 DXGetErrorString8(rc));
587 if (rc!=DS_OK)
588 goto EXIT;
590 /* Testing 3D buffers */
591 primary=NULL;
592 ZeroMemory(&bufdesc, sizeof(bufdesc));
593 bufdesc.dwSize=sizeof(bufdesc);
594 bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
595 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
596 ok(rc==DS_OK&&primary!=NULL,"IDirectSound_CreateSoundBuffer() failed to "
597 "create a hardware 3D primary buffer: %s\n",DXGetErrorString8(rc));
598 if (rc==DS_OK&&primary!=NULL) {
599 ZeroMemory(&wfx, sizeof(wfx));
600 wfx.wFormatTag=WAVE_FORMAT_PCM;
601 wfx.nChannels=1;
602 wfx.wBitsPerSample=16;
603 wfx.nSamplesPerSec=44100;
604 wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
605 wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
606 ZeroMemory(&bufdesc, sizeof(bufdesc));
607 bufdesc.dwSize=sizeof(bufdesc);
608 bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
609 bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
610 bufdesc.lpwfxFormat=&wfx;
611 trace(" Testing a secondary buffer at %ldx%dx%d\n",
612 wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
613 rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
614 ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
615 "failed to create a secondary buffer: %s\n",DXGetErrorString8(rc));
616 if (rc==DS_OK&&secondary!=NULL) {
617 IKsPropertySet * pPropertySet=NULL;
618 rc=IDirectSoundBuffer_QueryInterface(secondary,
619 &IID_IKsPropertySet,
620 (void **)&pPropertySet);
621 /* it's not an error for this to fail */
622 if(rc==DS_OK) {
623 ULONG ulTypeSupport;
624 trace(" Supports property sets\n");
625 /* it's not an error for these to fail */
626 rc=IKsPropertySet_QuerySupport(pPropertySet,
627 &DSPROPSETID_VoiceManager,
628 0,&ulTypeSupport);
629 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
630 KSPROPERTY_SUPPORT_SET)))
631 trace(" DSPROPSETID_VoiceManager supported\n");
632 else
633 trace(" DSPROPSETID_VoiceManager not supported\n");
634 rc=IKsPropertySet_QuerySupport(pPropertySet,
635 &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
636 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
637 KSPROPERTY_SUPPORT_SET)))
638 trace(" DSPROPSETID_EAX20_ListenerProperties "
639 "supported\n");
640 else
641 trace(" DSPROPSETID_EAX20_ListenerProperties not "
642 "supported\n");
643 rc=IKsPropertySet_QuerySupport(pPropertySet,
644 &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
645 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
646 KSPROPERTY_SUPPORT_SET)))
647 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
648 else
649 trace(" DSPROPSETID_EAX20_BufferProperties not "
650 "supported\n");
651 rc=IKsPropertySet_QuerySupport(pPropertySet,
652 &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
653 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
654 KSPROPERTY_SUPPORT_SET)))
655 trace(" DSPROPSETID_I3DL2_ListenerProperties "
656 "supported\n");
657 else
658 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
659 "supported\n");
660 rc=IKsPropertySet_QuerySupport(pPropertySet,
661 &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
662 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
663 KSPROPERTY_SUPPORT_SET)))
664 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
665 else
666 trace(" DSPROPSETID_I3DL2_BufferProperties not "
667 "supported\n");
668 rc=IKsPropertySet_QuerySupport(pPropertySet,
669 &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
670 if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
671 KSPROPERTY_SUPPORT_SET)))
672 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
673 "supported\n");
674 else
675 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
676 "supported\n");
677 ref=IKsPropertySet_Release(pPropertySet);
678 /* try a few common ones */
679 ok(ref==0,"IKsPropertySet_Release() secondary has %d "
680 "references, should have 0\n",ref);
681 } else
682 trace(" Doesn't support property sets\n");
684 ref=IDirectSoundBuffer_Release(secondary);
685 ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
686 "references, should have 0\n",ref);
689 ref=IDirectSoundBuffer_Release(primary);
690 ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
691 "should have 0\n",ref);
694 EXIT:
695 if (dso!=NULL) {
696 ref=IDirectSound_Release(dso);
697 ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
698 ref);
700 return 1;
703 static void propset_buffer_tests()
705 HRESULT rc;
706 rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
707 ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
710 START_TEST(propset)
712 HMODULE hDsound;
714 CoInitialize(NULL);
716 hDsound = LoadLibraryA("dsound.dll");
717 if (!hDsound) {
718 trace("dsound.dll not found\n");
719 return;
722 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
724 pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
725 pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
726 pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate8");
727 pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,"DirectSoundFullDuplexCreate");
729 propset_private_tests();
730 propset_buffer_tests();
732 CoUninitialize();