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