2 * Unit tests for CLSID_DirectSoundPrivate property set functions
5 * Copyright (c) 2003 Robert Reif
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define NONAMELESSSTRUCT
23 #define NONAMELESSUNION
29 #include "wine/test.h"
37 #ifndef DSBCAPS_CTRLDEFAULT
38 #define DSBCAPS_CTRLDEFAULT \
39 DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
42 DEFINE_GUID(DSPROPSETID_VoiceManager
, \
43 0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
44 DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties
, \
45 0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
46 DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties
, \
47 0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
48 DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties
, \
49 0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
50 DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties
, \
51 0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
52 DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties
, \
53 0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
55 typedef HRESULT (CALLBACK
* MYPROC
)(REFCLSID
, REFIID
, LPVOID
*);
57 BOOL CALLBACK
callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data
,
60 trace("found device:\n");
62 data
->Type
== DIRECTSOUNDDEVICE_TYPE_EMULATED
? "Emulated" :
63 data
->Type
== DIRECTSOUNDDEVICE_TYPE_VXD
? "VxD" :
64 data
->Type
== DIRECTSOUNDDEVICE_TYPE_WDM
? "WDM" : "Unknown");
65 trace("\tDataFlow: %s\n",
66 data
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
? "Render" :
67 data
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
?
68 "Capture" : "Unknown");
69 trace("\tDeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
70 data
->DeviceId
.Data1
,data
->DeviceId
.Data2
,data
->DeviceId
.Data3
,
71 data
->DeviceId
.Data4
[0],data
->DeviceId
.Data4
[1],
72 data
->DeviceId
.Data4
[2],data
->DeviceId
.Data4
[3],
73 data
->DeviceId
.Data4
[4],data
->DeviceId
.Data4
[5],
74 data
->DeviceId
.Data4
[6],data
->DeviceId
.Data4
[7]);
75 trace("\tDescription: %s\n", data
->Description
);
76 trace("\tModule: %s\n", data
->Module
);
77 trace("\tInterface: %s\n", data
->Interface
);
78 trace("\tWaveDeviceId: %ld\n", data
->WaveDeviceId
);
83 static void propset_private_tests()
92 hDsound
= LoadLibrary("dsound.dll");
93 ok(hDsound
!=0,"LoadLibrary(dsound.dll) failed\n");
97 fProc
= (MYPROC
)GetProcAddress(hDsound
, "DllGetClassObject");
99 /* try direct sound first */
100 rc
= (fProc
)(&CLSID_DirectSound
, &IID_IClassFactory
, (void **)0);
101 ok(rc
==DSERR_INVALIDPARAM
,"DllGetClassObject(CLSID_DirectSound, "
102 "IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
103 "returned: %s\n",DXGetErrorString8(rc
));
105 rc
= (fProc
)(&CLSID_DirectSound
, &IID_IClassFactory
, (void **)(&pcf
));
106 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
107 "failed: %s\n",DXGetErrorString8(rc
));
111 /* direct sound doesn't have an IKsPropertySet */
112 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
114 ok(rc
==DSERR_INVALIDPARAM
, "CreateInstance(IID_IKsPropertySet) should have "
115 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc
));
117 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
119 ok(rc
==E_NOINTERFACE
, "CreateInstance(IID_IKsPropertySet) should have "
120 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc
));
122 /* and the direct sound 8 version */
123 rc
= (fProc
)(&CLSID_DirectSound8
, &IID_IClassFactory
, (void **)(&pcf
));
124 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
125 "failed: %s\n",DXGetErrorString8(rc
));
129 /* direct sound 8 doesn't have an IKsPropertySet */
130 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
132 ok(rc
==E_NOINTERFACE
, "CreateInstance(IID_IKsPropertySet) should have "
133 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc
));
135 /* try direct sound capture next */
136 rc
= (fProc
)(&CLSID_DirectSoundCapture
, &IID_IClassFactory
,
138 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
139 "failed: %s\n",DXGetErrorString8(rc
));
143 /* direct sound capture doesn't have an IKsPropertySet */
144 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
146 ok(rc
==E_NOINTERFACE
, "CreateInstance(IID_IKsPropertySet) should have "
147 "returned E_NOINTERFACE,returned: %s\n",DXGetErrorString8(rc
));
149 /* and the direct sound capture 8 version */
150 rc
= (fProc
)(&CLSID_DirectSoundCapture8
, &IID_IClassFactory
,
152 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
153 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc
));
157 /* direct sound capture 8 doesn't have an IKsPropertySet */
158 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
160 ok(rc
==E_NOINTERFACE
, "CreateInstance(IID_IKsPropertySet) should have "
161 "returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc
));
163 /* try direct sound full duplex next */
164 rc
= (fProc
)(&CLSID_DirectSoundFullDuplex
, &IID_IClassFactory
,
166 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
167 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc
));
171 /* direct sound full duplex doesn't have an IKsPropertySet */
172 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
174 ok(rc
==E_NOINTERFACE
, "CreateInstance(IID_IKsPropertySet) should have "
175 "returned NOINTERFACE, returned: %s\n",DXGetErrorString8(rc
));
177 /* try direct sound private last */
178 rc
= (fProc
)(&CLSID_DirectSoundPrivate
, &IID_IClassFactory
,
180 ok(pcf
!=0, "DllGetClassObject(CLSID_DirectSoundPrivate, "
181 "IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc
));
185 /* direct sound private does have an IKsPropertySet */
186 rc
= pcf
->lpVtbl
->CreateInstance(pcf
, NULL
, &IID_IKsPropertySet
,
188 ok(rc
==DS_OK
, "CreateInstance(IID_IKsPropertySet) failed: %s\n",
189 DXGetErrorString8(rc
));
193 rc
= pps
->lpVtbl
->QuerySupport(pps
, &DSPROPSETID_DirectSoundDevice
,
194 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
,
196 ok(rc
==DS_OK
, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
197 "DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %s\n",
198 DXGetErrorString8(rc
));
202 ok(support
& KSPROPERTY_SUPPORT_GET
,
203 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
204 "support = 0x%lx\n",support
);
205 ok(!(support
& KSPROPERTY_SUPPORT_SET
),
206 "Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
207 "support = 0x%lx\n",support
);
209 rc
= pps
->lpVtbl
->QuerySupport(pps
, &DSPROPSETID_DirectSoundDevice
,
210 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING
, &support
);
211 ok(rc
==DS_OK
, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
212 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %s\n",
213 DXGetErrorString8(rc
));
217 ok(support
& KSPROPERTY_SUPPORT_GET
,
218 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
219 "support = 0x%lx\n",support
);
220 ok(!(support
& KSPROPERTY_SUPPORT_SET
), "Shouldn't be able to set "
221 "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
224 rc
= pps
->lpVtbl
->QuerySupport(pps
, &DSPROPSETID_DirectSoundDevice
,
225 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE
,
227 ok(rc
==DS_OK
, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
228 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %s\n",
229 DXGetErrorString8(rc
));
233 ok(support
& KSPROPERTY_SUPPORT_GET
,
234 "Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
235 "support = 0x%lx\n",support
);
236 ok(!(support
& KSPROPERTY_SUPPORT_SET
),"Shouldn't be able to set "
237 "DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%lx\n",support
);
239 if (support
& KSPROPERTY_SUPPORT_GET
) {
240 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data
;
243 data
.Callback
= callback
;
246 rc
= pps
->lpVtbl
->Get(pps
, &DSPROPSETID_DirectSoundDevice
,
247 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE
,
248 NULL
, 0, &data
, sizeof(data
), &bytes
);
249 ok(rc
==DS_OK
, "Couldn't enumerate: 0x%lx\n",rc
);
253 FreeLibrary(hDsound
);
256 static HWND
get_hwnd()
258 HWND hwnd
=GetForegroundWindow();
260 hwnd
=GetDesktopWindow();
264 static BOOL WINAPI
dsenum_callback(LPGUID lpGuid
, LPCSTR lpcstrDescription
,
265 LPCSTR lpcstrModule
, LPVOID lpContext
)
268 LPDIRECTSOUND dso
=NULL
;
269 LPDIRECTSOUNDBUFFER primary
=NULL
,secondary
=NULL
;
270 DSBUFFERDESC bufdesc
;
274 trace("*** Testing %s - %s ***\n",lpcstrDescription
,lpcstrModule
);
276 rc
=DirectSoundCreate(lpGuid
,&dso
,NULL
);
277 ok(rc
==DS_OK
,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc
));
281 /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
282 /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
283 rc
=IDirectSound_SetCooperativeLevel(dso
,get_hwnd(),DSSCL_PRIORITY
);
284 ok(rc
==DS_OK
,"IDirectSound_SetCooperativeLevel() failed: %s\n",
285 DXGetErrorString8(rc
));
289 /* Testing 3D buffers */
291 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
292 bufdesc
.dwSize
=sizeof(bufdesc
);
293 bufdesc
.dwFlags
=DSBCAPS_PRIMARYBUFFER
|DSBCAPS_LOCHARDWARE
|DSBCAPS_CTRL3D
;
294 rc
=IDirectSound_CreateSoundBuffer(dso
,&bufdesc
,&primary
,NULL
);
295 ok(rc
==DS_OK
&&primary
!=NULL
,"IDirectSound_CreateSoundBuffer() failed to "
296 "create a hardware 3D primary buffer: %s\n",DXGetErrorString8(rc
));
297 if (rc
==DS_OK
&&primary
!=NULL
) {
298 ZeroMemory(&wfx
, sizeof(wfx
));
299 wfx
.wFormatTag
=WAVE_FORMAT_PCM
;
301 wfx
.wBitsPerSample
=16;
302 wfx
.nSamplesPerSec
=44100;
303 wfx
.nBlockAlign
=wfx
.nChannels
*wfx
.wBitsPerSample
/8;
304 wfx
.nAvgBytesPerSec
=wfx
.nSamplesPerSec
*wfx
.nBlockAlign
;
305 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
306 bufdesc
.dwSize
=sizeof(bufdesc
);
307 bufdesc
.dwFlags
=DSBCAPS_CTRLDEFAULT
|DSBCAPS_GETCURRENTPOSITION2
;
308 bufdesc
.dwBufferBytes
=wfx
.nAvgBytesPerSec
;
309 bufdesc
.lpwfxFormat
=&wfx
;
310 trace(" Testing a secondary buffer at %ldx%dx%d\n",
311 wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,wfx
.nChannels
);
312 rc
=IDirectSound_CreateSoundBuffer(dso
,&bufdesc
,&secondary
,NULL
);
313 ok(rc
==DS_OK
&&secondary
!=NULL
,"IDirectSound_CreateSoundBuffer() "
314 "failed to create a secondary buffer: %s\n",DXGetErrorString8(rc
));
315 if (rc
==DS_OK
&&secondary
!=NULL
) {
316 IKsPropertySet
* pPropertySet
=NULL
;
317 rc
=IDirectSoundBuffer_QueryInterface(secondary
,
319 (void **)&pPropertySet
);
320 /* it's not an error for this to fail */
323 trace(" Supports property sets\n");
324 /* it's not an error for these to fail */
325 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
326 &DSPROPSETID_VoiceManager
,
328 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
329 KSPROPERTY_SUPPORT_SET
)))
330 trace(" DSPROPSETID_VoiceManager supported\n");
332 trace(" DSPROPSETID_VoiceManager not supported\n");
333 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
334 &DSPROPSETID_EAX20_ListenerProperties
,0,&ulTypeSupport
);
335 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
336 KSPROPERTY_SUPPORT_SET
)))
337 trace(" DSPROPSETID_EAX20_ListenerProperties "
340 trace(" DSPROPSETID_EAX20_ListenerProperties not "
342 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
343 &DSPROPSETID_EAX20_BufferProperties
,0,&ulTypeSupport
);
344 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
345 KSPROPERTY_SUPPORT_SET
)))
346 trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
348 trace(" DSPROPSETID_EAX20_BufferProperties not "
350 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
351 &DSPROPSETID_I3DL2_ListenerProperties
,0,&ulTypeSupport
);
352 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
353 KSPROPERTY_SUPPORT_SET
)))
354 trace(" DSPROPSETID_I3DL2_ListenerProperties "
357 trace(" DSPROPSETID_I3DL2_ListenerProperties not "
359 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
360 &DSPROPSETID_I3DL2_BufferProperties
,0,&ulTypeSupport
);
361 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
362 KSPROPERTY_SUPPORT_SET
)))
363 trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
365 trace(" DSPROPSETID_I3DL2_BufferProperties not "
367 rc
=IKsPropertySet_QuerySupport(pPropertySet
,
368 &DSPROPSETID_ZOOMFX_BufferProperties
,0,&ulTypeSupport
);
369 if((rc
==DS_OK
)&&(ulTypeSupport
&(KSPROPERTY_SUPPORT_GET
|
370 KSPROPERTY_SUPPORT_SET
)))
371 trace(" DSPROPSETID_ZOOMFX_BufferProperties "
374 trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
376 ref
=IKsPropertySet_Release(pPropertySet
);
377 /* try a few common ones */
378 ok(ref
==0,"IKsPropertySet_Release() secondary has %d "
379 "references, should have 0\n",ref
);
381 trace(" Doesn't support property sets\n");
383 ref
=IDirectSoundBuffer_Release(secondary
);
384 ok(ref
==0,"IDirectSoundBuffer_Release() secondary has %d "
385 "references, should have 0\n",ref
);
388 ref
=IDirectSoundBuffer_Release(primary
);
389 ok(ref
==0,"IDirectSoundBuffer_Release() primary has %d references, "
390 "should have 0\n",ref
);
395 ref
=IDirectSound_Release(dso
);
396 ok(ref
==0,"IDirectSound_Release() has %d references, should have 0\n",
402 static void propset_buffer_tests()
405 rc
=DirectSoundEnumerateA(&dsenum_callback
,NULL
);
406 ok(rc
==DS_OK
,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc
));
411 propset_private_tests();
412 propset_buffer_tests();