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