dsound/tests: Remove unneeded NONAMELESS* macros.
[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 "initguid.h"
28 #include "dsconf.h"
29 #include "dxerr8.h"
30
31 #include "dsound_test.h"
32
33 #ifndef DSBCAPS_CTRLDEFAULT
34 #define DSBCAPS_CTRLDEFAULT \
35         DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
36 #endif
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 typedef HRESULT  (CALLBACK * MYPROC)(REFCLSID, REFIID, LPVOID *);
52
53 static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
54     LPUNKNOWN)=NULL;
55 static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
56     LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
57 static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
58     LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
59 static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
60     LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
61     LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
62
63 BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
64                        LPVOID context)
65 {
66     trace("  found device:\n");
67     trace("    Type: %s\n",
68           data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
69           data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
70           data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
71     trace("    DataFlow: %s\n",
72           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
73           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
74           "Capture" : "Unknown");
75     trace("    DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
76           data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
77           data->DeviceId.Data4[0],data->DeviceId.Data4[1],
78           data->DeviceId.Data4[2],data->DeviceId.Data4[3],
79           data->DeviceId.Data4[4],data->DeviceId.Data4[5],
80           data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
81     trace("    Description: %s\n", data->Description);
82     trace("    Module: %s\n", data->Module);
83     trace("    Interface: %s\n", data->Interface);
84     trace("    WaveDeviceId: %d\n", data->WaveDeviceId);
85
86     return TRUE;
87 }
88
89 BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
90                         LPVOID context)
91 {
92     char descriptionA[0x100];
93     char moduleA[MAX_PATH];
94
95     trace("  found device:\n");
96     trace("    Type: %s\n",
97           data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
98           data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
99           data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
100     trace("    DataFlow: %s\n",
101           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
102           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
103           "Capture" : "Unknown");
104     trace("    DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
105           data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
106           data->DeviceId.Data4[0],data->DeviceId.Data4[1],
107           data->DeviceId.Data4[2],data->DeviceId.Data4[3],
108           data->DeviceId.Data4[4],data->DeviceId.Data4[5],
109           data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
110     trace("    DescriptionA: %s\n", data->DescriptionA);
111     WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
112     trace("    DescriptionW: %s\n", descriptionA);
113     trace("    ModuleA: %s\n", data->ModuleA);
114     WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
115     trace("    ModuleW: %s\n", moduleA);
116     trace("    WaveDeviceId: %d\n", data->WaveDeviceId);
117
118     return TRUE;
119 }
120
121 BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
122                         LPVOID context)
123 {
124     trace("  found device:\n");
125     trace("    Type: %s\n",
126           data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
127           data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
128           data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
129     trace("    DataFlow: %s\n",
130           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
131           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
132           "Capture" : "Unknown");
133     trace("    DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
134           data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
135           data->DeviceId.Data4[0],data->DeviceId.Data4[1],
136           data->DeviceId.Data4[2],data->DeviceId.Data4[3],
137           data->DeviceId.Data4[4],data->DeviceId.Data4[5],
138           data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
139     trace("    Description: %s\n", data->Description);
140     trace("    Module: %s\n", data->Module);
141     trace("    Interface: %s\n", data->Interface);
142     trace("    WaveDeviceId: %d\n", data->WaveDeviceId);
143
144     return TRUE;
145 }
146
147 BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
148                         LPVOID context)
149 {
150     char descriptionA[0x100];
151     char moduleA[MAX_PATH];
152     char interfaceA[MAX_PATH];
153
154     trace("found device:\n");
155     trace("\tType: %s\n",
156           data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
157           data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
158           data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
159     trace("\tDataFlow: %s\n",
160           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
161           data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
162           "Capture" : "Unknown");
163     trace("\tDeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
164           data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
165           data->DeviceId.Data4[0],data->DeviceId.Data4[1],
166           data->DeviceId.Data4[2],data->DeviceId.Data4[3],
167           data->DeviceId.Data4[4],data->DeviceId.Data4[5],
168           data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
169     WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
170     WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
171     WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
172     trace("\tDescription: %s\n", descriptionA);
173     trace("\tModule: %s\n", moduleA);
174     trace("\tInterface: %s\n", interfaceA);
175     trace("\tWaveDeviceId: %d\n", data->WaveDeviceId);
176
177     return TRUE;
178 }
179
180 static void propset_private_tests(void)
181 {
182     HMODULE hDsound;
183     HRESULT rc;
184     IClassFactory * pcf;
185     IKsPropertySet * pps;
186     MYPROC fProc;
187     ULONG support;
188
189     hDsound = LoadLibrary("dsound.dll");
190     ok(hDsound!=0,"LoadLibrary(dsound.dll) failed\n");
191     if (hDsound==0)
192         return;
193
194     fProc = (MYPROC)GetProcAddress(hDsound, "DllGetClassObject");
195
196     /* try direct sound first */
197     /* DSOUND: Error: Invalid interface buffer */
198     rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)0);
199     ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
200        "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
201        "returned: %s\n",DXGetErrorString8(rc));
202
203     rc = (fProc)(&CLSID_DirectSound, &IID_IDirectSound, (void **)(&pcf));
204     ok(rc==E_NOINTERFACE,"DllGetClassObject(CLSID_DirectSound, "
205        "IID_IDirectSound) should have returned E_NOINTERFACE, "
206        "returned: %s\n",DXGetErrorString8(rc));
207
208     rc = (fProc)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
209     ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
210        "IID_IUnknown) failed: %s\n",DXGetErrorString8(rc));
211
212     rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
213     ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
214        "failed: %s\n",DXGetErrorString8(rc));
215     if (pcf==0)
216         goto error;
217
218     /* direct sound doesn't have an IKsPropertySet */
219     /* DSOUND: Error: Invalid interface buffer */
220     rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
221                                      (void **)0);
222     ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
223        "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
224
225     rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
226                                      (void **)(&pps));
227     ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
228        "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
229
230     /* and the direct sound 8 version */
231     if (pDirectSoundCreate8) {
232         rc = (fProc)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
233         ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
234            "failed: %s\n",DXGetErrorString8(rc));
235         if (pcf==0)
236             goto error;
237
238         /* direct sound 8 doesn't have an IKsPropertySet */
239         rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
240                                          (void **)(&pps));
241         ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
242            "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
243     }
244
245     /* try direct sound capture next */
246     if (pDirectSoundCaptureCreate) {
247         rc = (fProc)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
248                      (void **)(&pcf));
249         ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
250            "failed: %s\n",DXGetErrorString8(rc));
251         if (pcf==0)
252             goto error;
253
254         /* direct sound capture doesn't have an IKsPropertySet */
255         rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
256                                          (void **)(&pps));
257         ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
258            "returned E_NOINTERFACE,returned: %s\n",DXGetErrorString8(rc));
259     }
260
261     /* and the direct sound capture 8 version */
262     if (pDirectSoundCaptureCreate8) {
263         rc = (fProc)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
264                      (void **)(&pcf));
265         ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
266            "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
267         if (pcf==0)
268             goto error;
269
270         /* direct sound capture 8 doesn't have an IKsPropertySet */
271         rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
272                                          (void **)(&pps));
273         ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
274            "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
275     }
276
277     /* try direct sound full duplex next */
278     if (pDirectSoundFullDuplexCreate) {
279         rc = (fProc)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
280                      (void **)(&pcf));
281         ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
282            "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
283         if (pcf==0)
284             goto error;
285
286         /* direct sound full duplex doesn't have an IKsPropertySet */
287         rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
288                                          (void **)(&pps));
289         ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
290            "returned NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
291     }
292
293     /* try direct sound private last */
294     rc = (fProc)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
295                  (void **)(&pcf));
296
297     /* some early versions of Direct Sound do not have this */
298     if (pcf==0)
299         goto error;
300
301     /* direct sound private does have an IKsPropertySet */
302     rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
303                                      (void **)(&pps));
304     ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %s\n",
305        DXGetErrorString8(rc));
306     if (rc!=DS_OK)
307         goto error;
308
309     /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
310     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
311                                    DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
312                                    &support);
313     ok(rc==DS_OK||rc==E_INVALIDARG,
314        "QuerySupport(DSPROPSETID_DirectSoundDevice, "
315        "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %s\n",
316        DXGetErrorString8(rc));
317     if (rc!=DS_OK) {
318         if (rc==E_INVALIDARG)
319             trace("  Not Supported\n");
320         goto error;
321     }
322
323     ok(support & KSPROPERTY_SUPPORT_GET,
324        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
325        "support = 0x%x\n",support);
326     ok(!(support & KSPROPERTY_SUPPORT_SET),
327        "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
328        "support = 0x%x\n",support);
329
330     /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
331     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
332                                    DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
333                                    &support);
334     ok(rc==DS_OK||rc==E_INVALIDARG,
335        "QuerySupport(DSPROPSETID_DirectSoundDevice, "
336        "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %s\n",
337        DXGetErrorString8(rc));
338     if (rc!=DS_OK) {
339         if (rc==E_INVALIDARG)
340             trace("  Not Supported\n");
341         goto error;
342     }
343
344     ok(support & KSPROPERTY_SUPPORT_GET,
345        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
346        "support = 0x%x\n",support);
347     ok(!(support & KSPROPERTY_SUPPORT_SET),
348        "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
349        "support = 0x%x\n",support);
350
351     /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
352     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
353                                    DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
354                                    &support);
355     ok(rc==DS_OK||rc==E_INVALIDARG,
356        "QuerySupport(DSPROPSETID_DirectSoundDevice, "
357        "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %s\n",
358        DXGetErrorString8(rc));
359     if (rc!=DS_OK) {
360         if (rc==E_INVALIDARG)
361             trace("  Not Supported\n");
362         goto error;
363     }
364
365     ok(support & KSPROPERTY_SUPPORT_GET,
366        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
367        "support = 0x%x\n",support);
368     ok(!(support & KSPROPERTY_SUPPORT_SET),
369        "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
370        "support = 0x%x\n",support);
371
372     /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
373     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
374                                    DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
375                                    &support);
376     ok(rc==DS_OK||rc==E_INVALIDARG,
377        "QuerySupport(DSPROPSETID_DirectSoundDevice, "
378        "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %s\n",
379        DXGetErrorString8(rc));
380     if (rc!=DS_OK) {
381         if (rc==E_INVALIDARG)
382             trace("  Not Supported\n");
383         goto error;
384     }
385
386     ok(support & KSPROPERTY_SUPPORT_GET,
387        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
388        "support = 0x%x\n",support);
389     ok(!(support & KSPROPERTY_SUPPORT_SET),
390        "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
391        "support = 0x%x\n",support);
392
393     /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
394     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
395         DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
396     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
397        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %s\n",
398        DXGetErrorString8(rc));
399     if (rc!=DS_OK)
400         goto error;
401
402     ok(support & KSPROPERTY_SUPPORT_GET,
403        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
404        "support = 0x%x\n",support);
405     ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
406        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
407        "0x%x\n",support);
408
409     /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
410     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
411         DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
412     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
413        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %s\n",
414        DXGetErrorString8(rc));
415     if (rc!=DS_OK)
416         goto error;
417
418     ok(support & KSPROPERTY_SUPPORT_GET,
419        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
420        "support = 0x%x\n",support);
421     ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
422        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
423        "0x%x\n",support);
424
425     /* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
426     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
427         DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
428     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
429        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %s\n",
430        DXGetErrorString8(rc));
431     if (rc!=DS_OK)
432         goto error;
433
434     ok(support & KSPROPERTY_SUPPORT_GET,
435        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
436        "support = 0x%x\n",support);
437     ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
438        "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
439        "0x%x\n",support);
440
441     /* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
442     trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
443     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
444                                    DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
445                                    &support);
446     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
447        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %s\n",
448        DXGetErrorString8(rc));
449     if (rc!=DS_OK)
450         goto error;
451
452     ok(support & KSPROPERTY_SUPPORT_GET,
453        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
454        "support = 0x%x\n",support);
455     ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
456        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%x\n",support);
457
458     if (support & KSPROPERTY_SUPPORT_GET) {
459         DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
460         ULONG bytes;
461
462         data.Callback = callback;
463         data.Context = 0;
464
465         rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
466                               DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
467                               NULL, 0, &data, sizeof(data), &bytes);
468         ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
469    }
470
471     /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
472     trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
473     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
474                                    DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
475                                    &support);
476     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
477        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %s\n",
478        DXGetErrorString8(rc));
479     if (rc!=DS_OK)
480         goto error;
481
482     ok(support & KSPROPERTY_SUPPORT_GET,
483        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
484        "support = 0x%x\n",support);
485     ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
486        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%x\n",support);
487
488     if (support & KSPROPERTY_SUPPORT_GET) {
489         DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
490         ULONG bytes;
491
492         data.Callback = callback1;
493         data.Context = 0;
494
495         rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
496                               DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
497                               NULL, 0, &data, sizeof(data), &bytes);
498         ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
499     }
500
501     /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
502     trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
503     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
504                                    DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
505                                    &support);
506     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
507        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %s\n",
508        DXGetErrorString8(rc));
509     if (rc!=DS_OK)
510         goto error;
511
512     ok(support & KSPROPERTY_SUPPORT_GET,
513        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
514        "support = 0x%x\n",support);
515     ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
516        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%x\n",support);
517
518     if (support & KSPROPERTY_SUPPORT_GET) {
519         DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
520         ULONG bytes;
521
522         data.Callback = callbackA;
523         data.Context = 0;
524
525         rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
526                               DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
527                               NULL, 0, &data, sizeof(data), &bytes);
528         ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
529     }
530
531     /* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
532     trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
533     rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
534                                    DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
535                                    &support);
536     ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
537        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %s\n",
538        DXGetErrorString8(rc));
539     if (rc!=DS_OK)
540         goto error;
541
542     ok(support & KSPROPERTY_SUPPORT_GET,
543        "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
544        "support = 0x%x\n",support);
545     ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
546        "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%x\n",support);
547
548     if (support & KSPROPERTY_SUPPORT_GET) {
549         DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
550         ULONG bytes;
551
552         data.Callback = callbackW;
553         data.Context = 0;
554
555         rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
556                               DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
557                               NULL, 0, &data, sizeof(data), &bytes);
558         ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
559     }
560
561 error:
562     FreeLibrary(hDsound);
563 }
564
565 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
566                                    LPCSTR lpcstrModule, LPVOID lpContext)
567 {
568     HRESULT rc;
569     LPDIRECTSOUND dso=NULL;
570     LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
571     DSBUFFERDESC bufdesc;
572     WAVEFORMATEX wfx;
573     int ref;
574
575     trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
576
577     rc=DirectSoundCreate(lpGuid,&dso,NULL);
578     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
579        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
580     if (rc!=DS_OK) {
581         if (rc==DSERR_NODRIVER)
582             trace("  No Driver\n");
583         else if (rc == DSERR_ALLOCATED)
584             trace("  Already In Use\n");
585         else if (rc == E_FAIL)
586             trace("  No Device\n");
587         goto EXIT;
588     }
589
590     /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
591     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
592     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
593     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
594        DXGetErrorString8(rc));
595     if (rc!=DS_OK)
596         goto EXIT;
597
598     /* Testing 3D buffers */
599     primary=NULL;
600     ZeroMemory(&bufdesc, sizeof(bufdesc));
601     bufdesc.dwSize=sizeof(bufdesc);
602     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
603     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
604     ok(rc==DS_OK&&primary!=NULL,"IDirectSound_CreateSoundBuffer() failed to "
605        "create a hardware 3D primary buffer: %s\n",DXGetErrorString8(rc));
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,"IDirectSound_CreateSoundBuffer() "
623            "failed to create a secondary buffer: %s\n",DXGetErrorString8(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=DirectSoundEnumerateA(&dsenum_callback,NULL);
715     ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
716 }
717
718 START_TEST(propset)
719 {
720     HMODULE hDsound;
721
722     CoInitialize(NULL);
723
724     hDsound = LoadLibraryA("dsound.dll");
725     if (!hDsound) {
726         trace("dsound.dll not found\n");
727         return;
728     }
729
730     trace("DLL Version: %s\n", get_file_version("dsound.dll"));
731
732     pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
733     pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
734     pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate8");
735     pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,"DirectSoundFullDuplexCreate");
736
737     propset_private_tests();
738     propset_buffer_tests();
739
740     CoUninitialize();
741 }