3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2002 TransGaming Technologies, Inc.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
36 #include "wine/debug.h"
40 #include "dsound_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
51 #include "dsound_private.h"
54 DIRECTSOUNDDEVICE_DATAFLOW_RENDER
,
55 DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
56 } DIRECTSOUNDDEVICE_DATAFLOW
;
58 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
{
60 DIRECTSOUNDDEVICE_DATAFLOW DataFlow
;
62 } DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
;
64 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
{
66 DIRECTSOUNDDEVICE_DATAFLOW DataFlow
;
68 } DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
;
71 DIRECTSOUNDDEVICE_TYPE_EMULATED
,
72 DIRECTSOUNDDEVICE_TYPE_VXD
,
73 DIRECTSOUNDDEVICE_TYPE_WDM
74 } DIRECTSOUNDDEVICE_TYPE
;
76 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
{
78 CHAR DescriptionA
[0x100];
79 WCHAR DescriptionW
[0x100];
80 CHAR ModuleA
[MAX_PATH
];
81 WCHAR ModuleW
[MAX_PATH
];
82 DIRECTSOUNDDEVICE_TYPE Type
;
83 DIRECTSOUNDDEVICE_DATAFLOW DataFlow
;
86 } DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
;
88 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
{
89 DIRECTSOUNDDEVICE_TYPE Type
;
90 DIRECTSOUNDDEVICE_DATAFLOW DataFlow
;
96 } DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
;
98 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
{
99 DIRECTSOUNDDEVICE_TYPE Type
;
100 DIRECTSOUNDDEVICE_DATAFLOW DataFlow
;
106 } DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
;
108 typedef struct _DSDRIVERDESC
{
117 LPVOID pvDirectDrawHeap
;
118 DWORD dwMemStartAddress
;
119 DWORD dwMemEndAddress
;
120 DWORD dwMemAllocExtra
;
123 } DSDRIVERDESC
,*PDSDRIVERDESC
;
125 #ifndef E_PROP_ID_UNSUPPORTED
126 #define E_PROP_ID_UNSUPPORTED ((HRESULT)0x80070490)
129 #ifndef DRV_QUERYDSOUNDDESC
130 #define DRV_QUERYDSOUNDDESC (DRV_RESERVED + 21)
133 typedef BOOL (CALLBACK
*LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1
)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
, LPVOID
);
134 typedef BOOL (CALLBACK
*LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA
)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
, LPVOID
);
135 typedef BOOL (CALLBACK
*LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW
)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
, LPVOID
);
137 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
{
138 LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1 Callback
;
140 } DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
;
142 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
{
143 LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA Callback
;
145 } DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
;
147 typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
{
148 LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW Callback
;
150 } DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
;
152 DEFINE_GUID(DSPROPSETID_DirectSoundDevice
,0x84624f82,0x25ec,0x11d1,0xa4,0xd8,0x00,0xc0,0x4f,0xc2,0x8a,0xca);
155 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
= 1,
156 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
= 2,
157 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
= 3,
158 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
= 4,
159 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
= 5,
160 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
= 6,
161 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
= 7,
162 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
= 8,
163 } DSPROPERTY_DIRECTSOUNDDEVICE
;
165 #ifndef ULongToHandle
166 #define ULongToHandle(ul) ((HANDLE)(ULONG_PTR)(ul))
168 #ifndef UlongToHandle
169 #define UlongToHandle(ul) ULongToHandle(ul)
174 typedef struct IKsPrivatePropertySetImpl
{
175 IKsPropertySet IKsPropertySet_iface
;
177 } IKsPrivatePropertySetImpl
;
179 /*******************************************************************************
180 * IKsPrivatePropertySet
183 static inline IKsPrivatePropertySetImpl
*impl_from_IKsPropertySet(IKsPropertySet
*iface
)
185 return CONTAINING_RECORD(iface
, IKsPrivatePropertySetImpl
, IKsPropertySet_iface
);
188 /* IUnknown methods */
189 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QueryInterface(
190 IKsPropertySet
*iface
,
194 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
195 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
197 if (IsEqualIID(riid
, &IID_IUnknown
) ||
198 IsEqualIID(riid
, &IID_IKsPropertySet
)) {
200 IUnknown_AddRef(iface
);
204 return E_NOINTERFACE
;
207 static ULONG WINAPI
IKsPrivatePropertySetImpl_AddRef(IKsPropertySet
*iface
)
209 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
210 ULONG ref
= InterlockedIncrement(&(This
->ref
));
211 TRACE("(%p) ref was %u\n", This
, ref
- 1);
215 static ULONG WINAPI
IKsPrivatePropertySetImpl_Release(IKsPropertySet
*iface
)
217 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
218 ULONG ref
= InterlockedDecrement(&(This
->ref
));
219 TRACE("(%p) ref was %u\n", This
, ref
+ 1);
222 HeapFree(GetProcessHeap(), 0, This
);
223 TRACE("(%p) released\n", This
);
228 static HRESULT
DSPROPERTY_WaveDeviceMappingW(
233 HRESULT hr
= DSERR_INVALIDPARAM
;
234 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd
;
235 TRACE("(pPropData=%p,cbPropData=%u,pcbReturned=%p)\n",
236 pPropData
,cbPropData
,pcbReturned
);
240 WARN("invalid parameter: pPropData\n");
241 return DSERR_INVALIDPARAM
;
244 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
247 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
248 wodn
= waveOutGetNumDevs();
249 for (wod
= 0; wod
< wodn
; wod
++) {
252 res
= waveOutGetDevCapsW(wod
, &capsW
, sizeof(capsW
));
253 if (res
== MMSYSERR_NOERROR
) {
254 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
255 ppd
->DeviceId
= DSOUND_renderer_guid
;
256 ppd
->DeviceId
.Data4
[7] = wod
;
258 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
259 debugstr_w(ppd
->DeviceName
));
264 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
267 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
268 widn
= waveInGetNumDevs();
269 for (wid
= 0; wid
< widn
; wid
++) {
272 res
= waveInGetDevCapsW(wid
, &capsW
, sizeof(capsW
));
273 if (res
== MMSYSERR_NOERROR
) {
274 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
275 ppd
->DeviceId
= DSOUND_capture_guid
;
276 ppd
->DeviceId
.Data4
[7] = wid
;
278 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
279 debugstr_w(ppd
->DeviceName
));
287 *pcbReturned
= cbPropData
;
292 static HRESULT
DSPROPERTY_WaveDeviceMappingA(
297 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA data
;
298 DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
*ppd
= pPropData
;
302 TRACE("(pPropData=%p,cbPropData=%u,pcbReturned=%p)\n",
303 pPropData
,cbPropData
,pcbReturned
);
305 if (!ppd
|| !ppd
->DeviceName
) {
306 WARN("invalid parameter: ppd=%p\n", ppd
);
307 return DSERR_INVALIDPARAM
;
310 data
.DataFlow
= ppd
->DataFlow
;
311 len
= strlen(ppd
->DeviceName
)+1;
312 data
.DeviceName
= HeapAlloc(GetProcessHeap(), 0, len
);
313 if (!data
.DeviceName
)
314 return E_OUTOFMEMORY
;
315 MultiByteToWideChar(CP_ACP
, 0, ppd
->DeviceName
, -1, data
.DeviceName
, len
);
317 hr
= DSPROPERTY_WaveDeviceMappingW(&data
, cbPropData
, pcbReturned
);
318 HeapFree(GetProcessHeap(), 0, data
.DeviceName
);
319 ppd
->DeviceId
= data
.DeviceId
;
322 *pcbReturned
= cbPropData
;
327 static HRESULT
DSPROPERTY_DescriptionW(
332 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd
= pPropData
;
335 ULONG wod
, wid
, wodn
, widn
;
338 TRACE("pPropData=%p,cbPropData=%u,pcbReturned=%p)\n",
339 pPropData
,cbPropData
,pcbReturned
);
341 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
342 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
343 /* default device of type specified by ppd->DataFlow */
344 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
345 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
346 ppd
->DeviceId
= DSDEVID_DefaultCapture
;
347 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
348 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
349 ppd
->DeviceId
= DSDEVID_DefaultPlayback
;
351 WARN("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
352 return E_PROP_ID_UNSUPPORTED
;
356 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
358 wodn
= waveOutGetNumDevs();
359 widn
= waveInGetNumDevs();
360 wid
= wod
= dev_guid
.Data4
[7];
361 if (!memcmp(&dev_guid
, &DSOUND_renderer_guid
, sizeof(GUID
)-1)
364 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
365 ppd
->WaveDeviceId
= wod
;
367 else if (!memcmp(&dev_guid
, &DSOUND_capture_guid
, sizeof(GUID
)-1)
370 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
371 ppd
->WaveDeviceId
= wid
;
375 WARN("Device not found\n");
376 return E_PROP_ID_UNSUPPORTED
;
379 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
)
380 err
= waveOutMessage(UlongToHandle(wod
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0);
382 err
= waveInMessage(UlongToHandle(wod
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0);
384 if (err
!= MMSYSERR_NOERROR
)
386 WARN("waveMessage(DRV_QUERYDSOUNDDESC) failed!\n");
387 return E_PROP_ID_UNSUPPORTED
;
391 /* FIXME: Still a memory leak.. */
393 static WCHAR wInterface
[] = { 'I','n','t','e','r','f','a','c','e',0 };
395 modlen
= strlen(desc
.szDrvname
)+1;
396 desclen
= strlen(desc
.szDesc
)+1;
397 ppd
->Module
= HeapAlloc(GetProcessHeap(),0,modlen
*sizeof(WCHAR
));
398 ppd
->Description
= HeapAlloc(GetProcessHeap(),0,desclen
*sizeof(WCHAR
));
399 ppd
->Interface
= wInterface
;
400 if (!ppd
->Description
|| !ppd
->Module
)
402 WARN("Out of memory\n");
403 HeapFree(GetProcessHeap(), 0, ppd
->Description
);
404 HeapFree(GetProcessHeap(), 0, ppd
->Module
);
405 ppd
->Description
= ppd
->Module
= NULL
;
406 return E_OUTOFMEMORY
;
409 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->Module
, modlen
);
410 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->Description
, desclen
);
413 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
416 *pcbReturned
= sizeof(*ppd
);
417 TRACE("*pcbReturned=%u\n", *pcbReturned
);
423 static HRESULT
DSPROPERTY_EnumerateW(
428 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd
= pPropData
;
429 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data
;
432 TRACE("(pPropData=%p,cbPropData=%u,pcbReturned=%p)\n",
433 pPropData
,cbPropData
,pcbReturned
);
438 if (!ppd
|| !ppd
->Callback
)
440 WARN("Invalid ppd %p\n", ppd
);
441 return E_PROP_ID_UNSUPPORTED
;
444 wodn
= waveOutGetNumDevs();
445 widn
= waveInGetNumDevs();
447 data
.DeviceId
= DSOUND_renderer_guid
;
448 for (i
= 0; i
< wodn
; ++i
)
451 data
.DeviceId
.Data4
[7] = i
;
452 hr
= DSPROPERTY_DescriptionW(&data
, sizeof(data
), NULL
);
455 ERR("DescriptionW failed!\n");
458 ret
= ppd
->Callback(&data
, ppd
->Context
);
459 HeapFree(GetProcessHeap(), 0, data
.Module
);
460 HeapFree(GetProcessHeap(), 0, data
.Description
);
465 data
.DeviceId
= DSOUND_capture_guid
;
466 for (i
= 0; i
< widn
; ++i
)
469 data
.DeviceId
.Data4
[7] = i
;
470 hr
= DSPROPERTY_DescriptionW(&data
, sizeof(data
), NULL
);
473 ERR("DescriptionW failed!\n");
476 ret
= ppd
->Callback(&data
, ppd
->Context
);
477 HeapFree(GetProcessHeap(), 0, data
.Module
);
478 HeapFree(GetProcessHeap(), 0, data
.Description
);
485 static void DSPROPERTY_descWtoA(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
*dataW
,
486 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
*dataA
)
488 DWORD modlen
, desclen
;
489 static char Interface
[] = "Interface";
491 modlen
= lstrlenW(dataW
->Module
)+1;
492 desclen
= lstrlenW(dataW
->Description
)+1;
493 dataA
->Type
= dataW
->Type
;
494 dataA
->DataFlow
= dataW
->DataFlow
;
495 dataA
->DeviceId
= dataW
->DeviceId
;
496 dataA
->WaveDeviceId
= dataW
->WaveDeviceId
;
497 dataA
->Interface
= Interface
;
498 dataA
->Module
= HeapAlloc(GetProcessHeap(), 0, modlen
);
499 dataA
->Description
= HeapAlloc(GetProcessHeap(), 0, desclen
);
501 WideCharToMultiByte(CP_ACP
, 0, dataW
->Module
, -1, dataA
->Module
, modlen
, NULL
, NULL
);
502 if (dataA
->Description
)
503 WideCharToMultiByte(CP_ACP
, 0, dataW
->Description
, -1, dataA
->Description
, desclen
, NULL
, NULL
);
506 static void DSPROPERTY_descWto1(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
*dataW
,
507 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
*data1
)
509 data1
->DeviceId
= dataW
->DeviceId
;
510 lstrcpynW(data1
->ModuleW
, dataW
->Module
, sizeof(data1
->ModuleW
)/sizeof(*data1
->ModuleW
));
511 lstrcpynW(data1
->DescriptionW
, dataW
->Description
, sizeof(data1
->DescriptionW
)/sizeof(*data1
->DescriptionW
));
512 WideCharToMultiByte(CP_ACP
, 0, data1
->DescriptionW
, -1, data1
->DescriptionA
, sizeof(data1
->DescriptionA
), NULL
, NULL
);
513 WideCharToMultiByte(CP_ACP
, 0, data1
->ModuleW
, -1, data1
->ModuleA
, sizeof(data1
->ModuleA
), NULL
, NULL
);
514 data1
->Type
= dataW
->Type
;
515 data1
->DataFlow
= dataW
->DataFlow
;
516 data1
->WaveDeviceId
= data1
->Devnode
= dataW
->WaveDeviceId
;
519 static BOOL CALLBACK
DSPROPERTY_enumWtoA(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
*descW
, void *data
)
521 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA descA
;
522 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
*ppd
= data
;
525 DSPROPERTY_descWtoA(descW
, &descA
);
526 ret
= ppd
->Callback(&descA
, ppd
->Context
);
527 HeapFree(GetProcessHeap(), 0, descA
.Module
);
528 HeapFree(GetProcessHeap(), 0, descA
.Description
);
532 static HRESULT
DSPROPERTY_EnumerateA(
537 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data
;
538 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
*ppd
= pPropData
;
540 if(cbPropData
< sizeof(*ppd
))
541 return DSERR_INVALIDPARAM
;
543 if (!ppd
|| !ppd
->Callback
)
545 WARN("Invalid ppd %p\n", ppd
);
546 return E_PROP_ID_UNSUPPORTED
;
549 data
.Callback
= DSPROPERTY_enumWtoA
;
552 return DSPROPERTY_EnumerateW(&data
, cbPropData
, pcbReturned
);
555 static BOOL CALLBACK
DSPROPERTY_enumWto1(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
*descW
, void *data
)
557 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA desc1
;
558 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
*ppd
= data
;
561 DSPROPERTY_descWto1(descW
, &desc1
);
562 ret
= ppd
->Callback(&desc1
, ppd
->Context
);
566 static HRESULT
DSPROPERTY_Enumerate1(
571 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data
;
572 DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
*ppd
= pPropData
;
574 if(cbPropData
< sizeof(*ppd
))
575 return DSERR_INVALIDPARAM
;
577 if (!ppd
|| !ppd
->Callback
)
579 WARN("Invalid ppd %p\n", ppd
);
580 return E_PROP_ID_UNSUPPORTED
;
583 data
.Callback
= DSPROPERTY_enumWto1
;
586 return DSPROPERTY_EnumerateW(&data
, cbPropData
, pcbReturned
);
589 static HRESULT
DSPROPERTY_DescriptionA(
594 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data
;
595 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
*ppd
= pPropData
;
598 if(cbPropData
< sizeof(*ppd
))
599 return DSERR_INVALIDPARAM
;
602 *pcbReturned
= sizeof(*ppd
);
606 data
.DeviceId
= ppd
->DeviceId
;
607 data
.DataFlow
= ppd
->DataFlow
;
608 hr
= DSPROPERTY_DescriptionW(&data
, sizeof(data
), NULL
);
611 DSPROPERTY_descWtoA(&data
, ppd
);
612 HeapFree(GetProcessHeap(), 0, data
.Module
);
613 HeapFree(GetProcessHeap(), 0, data
.Interface
);
617 static HRESULT
DSPROPERTY_Description1(
622 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data
;
623 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
*ppd
= pPropData
;
626 if(cbPropData
< sizeof(*ppd
))
627 return DSERR_INVALIDPARAM
;
630 *pcbReturned
= sizeof(*ppd
);
634 data
.DeviceId
= ppd
->DeviceId
;
635 data
.DataFlow
= ppd
->DataFlow
;
636 hr
= DSPROPERTY_DescriptionW(&data
, sizeof(data
), NULL
);
639 DSPROPERTY_descWto1(&data
, ppd
);
640 HeapFree(GetProcessHeap(), 0, data
.Module
);
641 HeapFree(GetProcessHeap(), 0, data
.Interface
);
645 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Get(
646 IKsPropertySet
*iface
,
649 LPVOID pInstanceData
,
650 ULONG cbInstanceData
,
655 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
656 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%u,pInstanceData=%p,cbInstanceData=%u,pPropData=%p,cbPropData=%u,pcbReturned=%p)\n",
657 This
,debugstr_guid(guidPropSet
),dwPropID
,
658 pInstanceData
,cbInstanceData
,
659 pPropData
,cbPropData
,pcbReturned
);
661 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
663 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
664 return DSPROPERTY_WaveDeviceMappingA(pPropData
,cbPropData
,pcbReturned
);
665 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
666 return DSPROPERTY_Description1(pPropData
,cbPropData
,pcbReturned
);
667 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
668 return DSPROPERTY_Enumerate1(pPropData
,cbPropData
,pcbReturned
);
669 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
670 return DSPROPERTY_WaveDeviceMappingW(pPropData
,cbPropData
,pcbReturned
);
671 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
672 return DSPROPERTY_DescriptionA(pPropData
,cbPropData
,pcbReturned
);
673 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
674 return DSPROPERTY_DescriptionW(pPropData
,cbPropData
,pcbReturned
);
675 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
676 return DSPROPERTY_EnumerateA(pPropData
,cbPropData
,pcbReturned
);
677 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
678 return DSPROPERTY_EnumerateW(pPropData
,cbPropData
,pcbReturned
);
680 FIXME("unsupported ID: %u\n",dwPropID
);
684 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
689 FIXME("*pcbReturned=%u\n", *pcbReturned
);
692 return E_PROP_ID_UNSUPPORTED
;
695 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Set(
696 IKsPropertySet
*iface
,
699 LPVOID pInstanceData
,
700 ULONG cbInstanceData
,
704 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
706 FIXME("(%p)->(%s,%u,%p,%u,%p,%u), stub!\n",This
,
707 debugstr_guid(guidPropSet
),dwPropID
,
708 pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
709 return E_PROP_ID_UNSUPPORTED
;
712 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QuerySupport(
713 IKsPropertySet
*iface
,
716 PULONG pTypeSupport
)
718 IKsPrivatePropertySetImpl
*This
= impl_from_IKsPropertySet(iface
);
719 TRACE("(%p,%s,%u,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
721 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
723 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
724 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
726 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
727 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
729 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
730 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
732 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
733 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
735 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
736 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
738 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
739 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
741 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
742 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
744 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
745 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
748 FIXME("unsupported ID: %u\n",dwPropID
);
752 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
755 return E_PROP_ID_UNSUPPORTED
;
758 static const IKsPropertySetVtbl ikspvt
= {
759 IKsPrivatePropertySetImpl_QueryInterface
,
760 IKsPrivatePropertySetImpl_AddRef
,
761 IKsPrivatePropertySetImpl_Release
,
762 IKsPrivatePropertySetImpl_Get
,
763 IKsPrivatePropertySetImpl_Set
,
764 IKsPrivatePropertySetImpl_QuerySupport
767 HRESULT
IKsPrivatePropertySetImpl_Create(
771 IKsPrivatePropertySetImpl
*iks
;
772 TRACE("(%s, %p)\n", debugstr_guid(riid
), piks
);
774 if (!IsEqualIID(riid
, &IID_IUnknown
) &&
775 !IsEqualIID(riid
, &IID_IKsPropertySet
)) {
777 return E_NOINTERFACE
;
780 iks
= HeapAlloc(GetProcessHeap(),0,sizeof(*iks
));
782 iks
->IKsPropertySet_iface
.lpVtbl
= (IKsPropertySetVtbl
*)&ikspvt
;