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