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
33 #include "wine/debug.h"
36 #include "dsound_private.h"
39 #ifdef NONAMELESSSTRUCT
45 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
48 /*******************************************************************************
49 * IKsBufferPropertySet
52 /* IUnknown methods */
53 static HRESULT WINAPI
IKsBufferPropertySetImpl_QueryInterface(
54 LPKSPROPERTYSET iface
,
58 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
59 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
61 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8
)This
->dsb
, riid
, ppobj
);
64 static ULONG WINAPI
IKsBufferPropertySetImpl_AddRef(LPKSPROPERTYSET iface
)
66 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
67 ULONG ref
= InterlockedIncrement(&(This
->ref
));
68 TRACE("(%p) ref was %d\n", This
, ref
- 1);
72 static ULONG WINAPI
IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface
)
74 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
75 ULONG ref
= InterlockedDecrement(&(This
->ref
));
76 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
80 IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER
)This
->dsb
);
81 HeapFree(GetProcessHeap(), 0, This
);
82 TRACE("(%p) released\n", This
);
87 static HRESULT WINAPI
IKsBufferPropertySetImpl_Get(
88 LPKSPROPERTYSET iface
,
97 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
98 PIDSDRIVERPROPERTYSET ps
;
99 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
100 This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
,pcbReturned
);
102 if (This
->dsb
->hwbuf
) {
103 IDsDriver_QueryInterface(This
->dsb
->hwbuf
, &IID_IDsDriverPropertySet
, (void **)&ps
);
109 S(prop
).Set
= *guidPropSet
;
110 S(prop
).Id
= dwPropID
;
111 S(prop
).Flags
= 0; /* unused */
112 S(prop
).InstanceId
= (ULONG
)This
->dsb
->device
;
114 hres
= IDsDriverPropertySet_Get(ps
, &prop
, pInstanceData
, cbInstanceData
, pPropData
, cbPropData
, pcbReturned
);
116 IDsDriverPropertySet_Release(ps
);
122 return E_PROP_ID_UNSUPPORTED
;
125 static HRESULT WINAPI
IKsBufferPropertySetImpl_Set(
126 LPKSPROPERTYSET iface
,
129 LPVOID pInstanceData
,
130 ULONG cbInstanceData
,
134 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
135 PIDSDRIVERPROPERTYSET ps
;
136 TRACE("(%p,%s,%d,%p,%d,%p,%d)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
138 if (This
->dsb
->hwbuf
) {
139 IDsDriver_QueryInterface(This
->dsb
->hwbuf
, &IID_IDsDriverPropertySet
, (void **)&ps
);
145 S(prop
).Set
= *guidPropSet
;
146 S(prop
).Id
= dwPropID
;
147 S(prop
).Flags
= 0; /* unused */
148 S(prop
).InstanceId
= (ULONG
)This
->dsb
->device
;
149 hres
= IDsDriverPropertySet_Set(ps
,&prop
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
151 IDsDriverPropertySet_Release(ps
);
157 return E_PROP_ID_UNSUPPORTED
;
160 static HRESULT WINAPI
IKsBufferPropertySetImpl_QuerySupport(
161 LPKSPROPERTYSET iface
,
164 PULONG pTypeSupport
)
166 IKsBufferPropertySetImpl
*This
= (IKsBufferPropertySetImpl
*)iface
;
167 PIDSDRIVERPROPERTYSET ps
;
168 TRACE("(%p,%s,%d,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
170 if (This
->dsb
->hwbuf
) {
171 IDsDriver_QueryInterface(This
->dsb
->hwbuf
, &IID_IDsDriverPropertySet
, (void **)&ps
);
176 hres
= IDsDriverPropertySet_QuerySupport(ps
,guidPropSet
, dwPropID
,pTypeSupport
);
178 IDsDriverPropertySet_Release(ps
);
184 return E_PROP_ID_UNSUPPORTED
;
187 static const IKsPropertySetVtbl iksbvt
= {
188 IKsBufferPropertySetImpl_QueryInterface
,
189 IKsBufferPropertySetImpl_AddRef
,
190 IKsBufferPropertySetImpl_Release
,
191 IKsBufferPropertySetImpl_Get
,
192 IKsBufferPropertySetImpl_Set
,
193 IKsBufferPropertySetImpl_QuerySupport
196 HRESULT
IKsBufferPropertySetImpl_Create(
197 IDirectSoundBufferImpl
*dsb
,
198 IKsBufferPropertySetImpl
**piks
)
200 IKsBufferPropertySetImpl
*iks
;
201 TRACE("(%p,%p)\n",dsb
,piks
);
204 iks
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*iks
));
206 WARN("out of memory\n");
208 return DSERR_OUTOFMEMORY
;
214 iks
->lpVtbl
= &iksbvt
;
216 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER
)dsb
);
222 HRESULT
IKsBufferPropertySetImpl_Destroy(
223 IKsBufferPropertySetImpl
*piks
)
225 TRACE("(%p)\n",piks
);
227 while (IKsBufferPropertySetImpl_Release((LPKSPROPERTYSET
)piks
) > 0);
232 /*******************************************************************************
233 * IKsPrivatePropertySet
236 /* IUnknown methods */
237 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QueryInterface(
238 LPKSPROPERTYSET iface
,
242 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
243 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
245 if (IsEqualIID(riid
, &IID_IUnknown
) ||
246 IsEqualIID(riid
, &IID_IKsPropertySet
)) {
248 IUnknown_AddRef(iface
);
252 return E_NOINTERFACE
;
255 static ULONG WINAPI
IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface
)
257 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
258 ULONG ref
= InterlockedIncrement(&(This
->ref
));
259 TRACE("(%p) ref was %d\n", This
, ref
- 1);
263 static ULONG WINAPI
IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface
)
265 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
266 ULONG ref
= InterlockedDecrement(&(This
->ref
));
267 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
270 HeapFree(GetProcessHeap(), 0, This
);
271 TRACE("(%p) released\n", This
);
276 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingA(
281 HRESULT hr
= DSERR_INVALIDPARAM
;
282 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd
;
283 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
284 pPropData
,cbPropData
,pcbReturned
);
286 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
) pPropData
;
289 WARN("invalid parameter: pPropData\n");
290 return DSERR_INVALIDPARAM
;
293 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
296 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
297 wodn
= waveOutGetNumDevs();
298 for (wod
= 0; wod
< wodn
; wod
++) {
301 res
= waveOutGetDevCapsA(wod
, &capsA
, sizeof(capsA
));
302 if (res
== MMSYSERR_NOERROR
) {
303 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
304 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
306 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
312 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
315 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
316 widn
= waveInGetNumDevs();
317 for (wid
= 0; wid
< widn
; wid
++) {
320 res
= waveInGetDevCapsA(wid
, &capsA
, sizeof(capsA
));
321 if (res
== MMSYSERR_NOERROR
) {
322 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
323 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
324 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
334 *pcbReturned
= cbPropData
;
339 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingW(
344 HRESULT hr
= DSERR_INVALIDPARAM
;
345 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd
;
346 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
347 pPropData
,cbPropData
,pcbReturned
);
349 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
) pPropData
;
352 WARN("invalid parameter: pPropData\n");
353 return DSERR_INVALIDPARAM
;
356 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
359 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
360 wodn
= waveOutGetNumDevs();
361 for (wod
= 0; wod
< wodn
; wod
++) {
364 res
= waveOutGetDevCapsW(wod
, &capsW
, sizeof(capsW
));
365 if (res
== MMSYSERR_NOERROR
) {
366 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
367 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
369 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
370 debugstr_w(ppd
->DeviceName
));
375 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
378 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
379 widn
= waveInGetNumDevs();
380 for (wid
= 0; wid
< widn
; wid
++) {
383 res
= waveInGetDevCapsW(wid
, &capsW
, sizeof(capsW
));
384 if (res
== MMSYSERR_NOERROR
) {
385 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
386 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
388 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
389 debugstr_w(ppd
->DeviceName
));
397 *pcbReturned
= cbPropData
;
402 static HRESULT WINAPI
DSPROPERTY_Description1(
409 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd
;
410 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
411 pPropData
,cbPropData
,pcbReturned
);
413 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
) pPropData
;
416 WARN("invalid parameter: pPropData\n");
417 return DSERR_INVALIDPARAM
;
420 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
421 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
422 /* default device of type specified by ppd->DataFlow */
423 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
424 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
425 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
426 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
428 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
430 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
431 pPropData
,cbPropData
,pcbReturned
);
432 return E_PROP_ID_UNSUPPORTED
;
435 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
436 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
438 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
439 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
442 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
443 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
444 wodn
= waveOutGetNumDevs();
445 for (wod
= 0; wod
< wodn
; wod
++) {
446 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
448 ppd
->WaveDeviceId
= wod
;
450 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
452 PIDSDRIVER drv
= NULL
;
453 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
454 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
455 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
456 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
457 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
458 if (err
== DS_OK
&& drv
)
459 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
461 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
464 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
465 return E_PROP_ID_UNSUPPORTED
;
469 } else if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
470 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
473 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
474 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
475 widn
= waveInGetNumDevs();
476 for (wid
= 0; wid
< widn
; wid
++) {
477 if (IsEqualGUID( &dev_guid
, &guid
) ) {
479 ppd
->WaveDeviceId
= wid
;
481 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
484 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
485 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
486 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
487 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
488 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
489 if (err
== DS_OK
&& drv
)
490 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
492 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
495 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
496 return E_PROP_ID_UNSUPPORTED
;
504 /* given specific device so try the render devices first */
505 wodn
= waveOutGetNumDevs();
506 for (wod
= 0; wod
< wodn
; wod
++) {
507 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
509 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
510 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
511 ppd
->WaveDeviceId
= wod
;
513 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
515 PIDSDRIVER drv
= NULL
;
516 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
517 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
518 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
519 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
520 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
521 if (err
== DS_OK
&& drv
)
522 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
524 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
528 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
529 return E_PROP_ID_UNSUPPORTED
;
534 if (found
== FALSE
) {
537 /* given specific device so try the capture devices next */
538 widn
= waveInGetNumDevs();
539 for (wid
= 0; wid
< widn
; wid
++) {
540 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
542 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
543 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
544 ppd
->WaveDeviceId
= wid
;
546 err
= mmErr(waveInMessage((HWAVEIN
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
548 PIDSDRIVER drv
= NULL
;
549 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
550 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
551 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
552 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
553 err
= mmErr(waveInMessage((HWAVEIN
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
554 if (err
== DS_OK
&& drv
)
555 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
557 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
561 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
562 return E_PROP_ID_UNSUPPORTED
;
567 if (found
== FALSE
) {
568 WARN("device not found\n");
569 return E_PROP_ID_UNSUPPORTED
;
575 *pcbReturned
= cbPropData
;
576 TRACE("*pcbReturned=%d\n", *pcbReturned
);
582 static HRESULT WINAPI
DSPROPERTY_DescriptionA(
587 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
) pPropData
;
590 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
591 pPropData
,cbPropData
,pcbReturned
);
593 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
594 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
595 /* default device of type specified by ppd->DataFlow */
596 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
597 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
598 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
599 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
601 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
603 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
604 pPropData
,cbPropData
,pcbReturned
);
605 return E_PROP_ID_UNSUPPORTED
;
608 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
609 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
611 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
612 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
615 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
616 TRACE("DSDEVID_DefaultPlayback\n");
618 TRACE("DSDEVID_DefaultVoicePlayback\n");
619 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
620 wodn
= waveOutGetNumDevs();
621 for (wod
= 0; wod
< wodn
; wod
++) {
622 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
624 ppd
->WaveDeviceId
= wod
;
625 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
627 PIDSDRIVER drv
= NULL
;
628 /* FIXME: this is a memory leak */
629 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
630 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
631 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
633 if (szDescription
&& szModule
&& szInterface
) {
634 strcpy(szDescription
, desc
.szDesc
);
635 strcpy(szModule
, desc
.szDrvname
);
636 strcpy(szInterface
, "Interface");
638 ppd
->Description
= szDescription
;
639 ppd
->Module
= szModule
;
640 ppd
->Interface
= szInterface
;
641 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
642 if (err
== DS_OK
&& drv
)
643 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
645 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
649 HeapFree(GetProcessHeap(), 0, szDescription
);
650 HeapFree(GetProcessHeap(), 0, szModule
);
651 HeapFree(GetProcessHeap(), 0, szInterface
);
652 return E_OUTOFMEMORY
;
655 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
656 return E_PROP_ID_UNSUPPORTED
;
660 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
661 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
664 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) )
665 TRACE("DSDEVID_DefaultCapture\n");
667 TRACE("DSDEVID_DefaultVoiceCapture\n");
668 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
669 widn
= waveInGetNumDevs();
670 for (wid
= 0; wid
< widn
; wid
++) {
671 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
673 ppd
->WaveDeviceId
= wid
;
674 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
677 /* FIXME: this is a memory leak */
678 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
679 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
680 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
682 if (szDescription
&& szModule
&& szInterface
) {
683 strcpy(szDescription
, desc
.szDesc
);
684 strcpy(szModule
, desc
.szDrvname
);
685 strcpy(szInterface
, "Interface");
687 ppd
->Description
= szDescription
;
688 ppd
->Module
= szModule
;
689 ppd
->Interface
= szInterface
;
690 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
691 if (err
== DS_OK
&& drv
)
692 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
694 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
698 HeapFree(GetProcessHeap(), 0, szDescription
);
699 HeapFree(GetProcessHeap(), 0, szModule
);
700 HeapFree(GetProcessHeap(), 0, szInterface
);
701 return E_OUTOFMEMORY
;
704 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
705 return E_PROP_ID_UNSUPPORTED
;
713 /* given specific device so try the render devices first */
714 TRACE("Checking renderer devices\n");
715 wodn
= waveOutGetNumDevs();
716 for (wod
= 0; wod
< wodn
; wod
++) {
717 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
719 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
720 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
721 ppd
->WaveDeviceId
= wod
;
722 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
724 PIDSDRIVER drv
= NULL
;
725 /* FIXME: this is a memory leak */
726 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
727 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
728 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
730 if (szDescription
&& szModule
&& szInterface
) {
731 strcpy(szDescription
, desc
.szDesc
);
732 strcpy(szModule
, desc
.szDrvname
);
733 strcpy(szInterface
, "Interface");
735 ppd
->Description
= szDescription
;
736 ppd
->Module
= szModule
;
737 ppd
->Interface
= szInterface
;
738 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
739 if (err
== DS_OK
&& drv
)
740 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
742 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
747 HeapFree(GetProcessHeap(), 0, szDescription
);
748 HeapFree(GetProcessHeap(), 0, szModule
);
749 HeapFree(GetProcessHeap(), 0, szInterface
);
750 return E_OUTOFMEMORY
;
753 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
754 return E_PROP_ID_UNSUPPORTED
;
759 if (found
== FALSE
) {
762 TRACE("Checking capture devices\n");
763 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
764 widn
= waveInGetNumDevs();
765 for (wid
= 0; wid
< widn
; wid
++) {
766 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
768 TRACE("DSOUND_capture_guids[%d]\n", wid
);
769 ppd
->WaveDeviceId
= wid
;
770 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
773 /* FIXME: this is a memory leak */
774 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
775 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
776 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
778 if (szDescription
&& szModule
&& szInterface
) {
779 strcpy(szDescription
, desc
.szDesc
);
780 strcpy(szModule
, desc
.szDrvname
);
781 strcpy(szInterface
, "Interface");
783 ppd
->Description
= szDescription
;
784 ppd
->Module
= szModule
;
785 ppd
->Interface
= szInterface
;
786 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
787 if (err
== DS_OK
&& drv
)
788 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
790 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
795 HeapFree(GetProcessHeap(), 0, szDescription
);
796 HeapFree(GetProcessHeap(), 0, szModule
);
797 HeapFree(GetProcessHeap(), 0, szInterface
);
798 return E_OUTOFMEMORY
;
801 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
802 return E_PROP_ID_UNSUPPORTED
;
808 if (found
== FALSE
) {
809 WARN("device not found\n");
810 return E_PROP_ID_UNSUPPORTED
;
815 *pcbReturned
= cbPropData
;
816 TRACE("*pcbReturned=%d\n", *pcbReturned
);
822 static HRESULT WINAPI
DSPROPERTY_DescriptionW(
827 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
) pPropData
;
830 TRACE("pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
831 pPropData
,cbPropData
,pcbReturned
);
833 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
834 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
835 /* default device of type specified by ppd->DataFlow */
836 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
837 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
838 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
839 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
841 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
843 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
844 pPropData
,cbPropData
,pcbReturned
);
845 return E_PROP_ID_UNSUPPORTED
;
848 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
849 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
851 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
852 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
855 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
856 TRACE("DSDEVID_DefaultPlayback\n");
858 TRACE("DSDEVID_DefaultVoicePlayback\n");
859 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
860 wodn
= waveOutGetNumDevs();
861 for (wod
= 0; wod
< wodn
; wod
++) {
862 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
864 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
865 ppd
->WaveDeviceId
= wod
;
866 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
868 PIDSDRIVER drv
= NULL
;
869 /* FIXME: this is a memory leak */
870 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
871 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
872 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
874 if (wDescription
&& wModule
&& wInterface
) {
875 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
876 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
877 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
879 ppd
->Description
= wDescription
;
880 ppd
->Module
= wModule
;
881 ppd
->Interface
= wInterface
;
882 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
883 if (err
== DS_OK
&& drv
)
884 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
886 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
890 HeapFree(GetProcessHeap(), 0, wDescription
);
891 HeapFree(GetProcessHeap(), 0, wModule
);
892 HeapFree(GetProcessHeap(), 0, wInterface
);
893 return E_OUTOFMEMORY
;
896 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
897 return E_PROP_ID_UNSUPPORTED
;
901 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
902 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
905 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
))
906 TRACE("DSDEVID_DefaultCapture\n");
908 TRACE("DSDEVID_DefaultVoiceCapture\n");
909 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
910 widn
= waveInGetNumDevs();
911 for (wid
= 0; wid
< widn
; wid
++) {
912 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
914 ppd
->WaveDeviceId
= wid
;
915 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
918 /* FIXME: this is a memory leak */
919 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
920 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
921 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
923 if (wDescription
&& wModule
&& wInterface
) {
924 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
925 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
926 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
928 ppd
->Description
= wDescription
;
929 ppd
->Module
= wModule
;
930 ppd
->Interface
= wInterface
;
931 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
932 if (err
== DS_OK
&& drv
)
933 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
935 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
939 HeapFree(GetProcessHeap(), 0, wDescription
);
940 HeapFree(GetProcessHeap(), 0, wModule
);
941 HeapFree(GetProcessHeap(), 0, wInterface
);
942 return E_OUTOFMEMORY
;
945 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
946 return E_PROP_ID_UNSUPPORTED
;
954 TRACE("Checking renderer devices\n");
955 /* given specific device so try the render devices first */
956 wodn
= waveOutGetNumDevs();
957 for (wod
= 0; wod
< wodn
; wod
++) {
958 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
960 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
961 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
962 ppd
->WaveDeviceId
= wod
;
963 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
965 PIDSDRIVER drv
= NULL
;
966 /* FIXME: this is a memory leak */
967 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
968 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
969 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
971 if (wDescription
&& wModule
&& wInterface
) {
972 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
973 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
974 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
976 ppd
->Description
= wDescription
;
977 ppd
->Module
= wModule
;
978 ppd
->Interface
= wInterface
;
979 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
980 if (err
== DS_OK
&& drv
)
981 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
983 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
988 HeapFree(GetProcessHeap(), 0, wDescription
);
989 HeapFree(GetProcessHeap(), 0, wModule
);
990 HeapFree(GetProcessHeap(), 0, wInterface
);
991 return E_OUTOFMEMORY
;
994 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
995 return E_PROP_ID_UNSUPPORTED
;
1000 if (found
== FALSE
) {
1003 TRACE("Checking capture devices\n");
1004 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1005 widn
= waveInGetNumDevs();
1006 for (wid
= 0; wid
< widn
; wid
++) {
1007 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
1009 TRACE("DSOUND_capture_guids[%d]\n", wid
);
1010 ppd
->WaveDeviceId
= wid
;
1011 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
1014 /* FIXME: this is a memory leak */
1015 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1016 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1017 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
1019 if (wDescription
&& wModule
&& wInterface
) {
1020 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1021 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1022 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
1024 ppd
->Description
= wDescription
;
1025 ppd
->Module
= wModule
;
1026 ppd
->Interface
= wInterface
;
1027 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
1028 if (err
== DS_OK
&& drv
)
1029 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1031 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1035 WARN("no memory\n");
1036 HeapFree(GetProcessHeap(), 0, wDescription
);
1037 HeapFree(GetProcessHeap(), 0, wModule
);
1038 HeapFree(GetProcessHeap(), 0, wInterface
);
1039 return E_OUTOFMEMORY
;
1042 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1043 return E_PROP_ID_UNSUPPORTED
;
1049 if (found
== FALSE
) {
1050 WARN("device not found\n");
1051 return E_PROP_ID_UNSUPPORTED
;
1056 *pcbReturned
= cbPropData
;
1057 TRACE("*pcbReturned=%d\n", *pcbReturned
);
1063 static HRESULT WINAPI
DSPROPERTY_Enumerate1(
1066 PULONG pcbReturned
)
1068 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
) pPropData
;
1070 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1071 pPropData
,cbPropData
,pcbReturned
);
1074 if (ppd
->Callback
) {
1075 unsigned devs
, wod
, wid
;
1077 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data
;
1079 devs
= waveOutGetNumDevs();
1080 for (wod
= 0; wod
< devs
; ++wod
) {
1081 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1084 ZeroMemory(&data
, sizeof(data
));
1085 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1086 data
.WaveDeviceId
= wod
;
1087 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1088 lstrcpynA(data
.DescriptionA
, desc
.szDesc
, sizeof(data
.DescriptionA
));
1089 lstrcpynA(data
.ModuleA
, desc
.szDrvname
, sizeof(data
.ModuleA
));
1091 MultiByteToWideChar( CP_ACP
, 0, data
.DescriptionA
, -1, data
.DescriptionW
, sizeof(data
.DescriptionW
)/sizeof(WCHAR
) );
1092 MultiByteToWideChar( CP_ACP
, 0, data
.ModuleA
, -1, data
.ModuleW
, sizeof(data
.ModuleW
)/sizeof(WCHAR
) );
1094 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1095 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1096 if (err
== DS_OK
&& drv
)
1097 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1099 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1101 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1102 (ppd
->Callback
)(&data
, ppd
->Context
);
1106 devs
= waveInGetNumDevs();
1107 for (wid
= 0; wid
< devs
; ++wid
) {
1108 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1111 ZeroMemory(&data
, sizeof(data
));
1112 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1113 data
.WaveDeviceId
= wid
;
1114 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1115 lstrcpynA(data
.DescriptionA
, desc
.szDesc
, sizeof(data
.DescriptionA
));
1116 lstrcpynA(data
.ModuleA
, desc
.szDrvname
, sizeof(data
.ModuleA
));
1118 MultiByteToWideChar( CP_ACP
, 0, data
.DescriptionA
, -1, data
.DescriptionW
, sizeof(data
.DescriptionW
)/sizeof(WCHAR
) );
1119 MultiByteToWideChar( CP_ACP
, 0, data
.ModuleA
, -1, data
.ModuleW
, sizeof(data
.ModuleW
)/sizeof(WCHAR
) );
1121 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1122 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1123 if (err
== DS_OK
&& drv
)
1124 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1126 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1128 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1129 (ppd
->Callback
)(&data
, ppd
->Context
);
1139 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1142 return E_PROP_ID_UNSUPPORTED
;
1145 static HRESULT WINAPI
DSPROPERTY_EnumerateA(
1148 PULONG pcbReturned
)
1150 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
) pPropData
;
1152 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1153 pPropData
,cbPropData
,pcbReturned
);
1156 if (ppd
->Callback
) {
1157 unsigned devs
, wod
, wid
;
1159 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data
;
1161 devs
= waveOutGetNumDevs();
1162 for (wod
= 0; wod
< devs
; ++wod
) {
1163 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1166 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1168 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1170 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1172 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1175 ZeroMemory(&data
, sizeof(data
));
1176 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1177 data
.WaveDeviceId
= wod
;
1178 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1179 data
.Description
= desc
.szDesc
;
1180 data
.Module
= desc
.szDrvname
;
1181 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1182 data
.Interface
= szInterface
;
1184 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1185 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1186 if (err
== DS_OK
&& drv
)
1187 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1189 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1191 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1192 (ppd
->Callback
)(&data
, ppd
->Context
);
1194 HeapFree(GetProcessHeap(),0,szInterface
);
1197 HeapFree(GetProcessHeap(),0,nameW
);
1202 devs
= waveInGetNumDevs();
1203 for (wid
= 0; wid
< devs
; ++wid
) {
1204 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1207 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1209 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1211 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1213 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1216 ZeroMemory(&data
, sizeof(data
));
1217 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1218 data
.WaveDeviceId
= wid
;
1219 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1220 data
.Description
= desc
.szDesc
;
1221 data
.Module
= desc
.szDrvname
;
1222 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1223 data
.Interface
= szInterface
;
1225 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1226 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1227 if (err
== DS_OK
&& drv
)
1228 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1230 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1232 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1233 (ppd
->Callback
)(&data
, ppd
->Context
);
1235 HeapFree(GetProcessHeap(),0,szInterface
);
1238 HeapFree(GetProcessHeap(),0,nameW
);
1249 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1252 return E_PROP_ID_UNSUPPORTED
;
1255 static HRESULT WINAPI
DSPROPERTY_EnumerateW(
1258 PULONG pcbReturned
)
1260 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
) pPropData
;
1262 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1263 pPropData
,cbPropData
,pcbReturned
);
1266 if (ppd
->Callback
) {
1267 unsigned devs
, wod
, wid
;
1269 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data
;
1271 devs
= waveOutGetNumDevs();
1272 for (wod
= 0; wod
< devs
; ++wod
) {
1273 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1275 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1276 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1277 if (wDescription
&& wModule
) {
1279 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACESIZE
, (DWORD_PTR
)&size
, 0));
1281 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,size
);
1283 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDEVICEINTERFACE
, (DWORD_PTR
)wInterface
, size
));
1286 ZeroMemory(&data
, sizeof(data
));
1287 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1288 data
.WaveDeviceId
= wod
;
1289 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1291 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1292 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1294 data
.Description
= wDescription
;
1295 data
.Module
= wModule
;
1296 data
.Interface
= wInterface
;
1298 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1299 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1300 if (err
== DS_OK
&& drv
)
1301 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1303 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1305 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1306 (ppd
->Callback
)(&data
, ppd
->Context
);
1309 HeapFree(GetProcessHeap(),0,wInterface
);
1312 HeapFree(GetProcessHeap(),0,wDescription
);
1313 HeapFree(GetProcessHeap(),0,wModule
);
1317 devs
= waveInGetNumDevs();
1318 for (wid
= 0; wid
< devs
; ++wid
) {
1319 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1321 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1322 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1323 if (wDescription
&& wModule
) {
1325 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACESIZE
, (DWORD_PTR
)&size
, 0));
1327 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,size
);
1329 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDEVICEINTERFACE
, (DWORD_PTR
)wInterface
, size
));
1332 ZeroMemory(&data
, sizeof(data
));
1333 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1334 data
.WaveDeviceId
= wid
;
1335 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1337 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1338 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1340 data
.Description
= wDescription
;
1341 data
.Module
= wModule
;
1342 data
.Interface
= wInterface
;
1343 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1344 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1345 if (err
== DS_OK
&& drv
)
1346 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1348 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1350 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1351 (ppd
->Callback
)(&data
, ppd
->Context
);
1354 HeapFree(GetProcessHeap(),0,wInterface
);
1357 HeapFree(GetProcessHeap(),0,wDescription
);
1358 HeapFree(GetProcessHeap(),0,wModule
);
1368 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1371 return E_PROP_ID_UNSUPPORTED
;
1374 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Get(
1375 LPKSPROPERTYSET iface
,
1376 REFGUID guidPropSet
,
1378 LPVOID pInstanceData
,
1379 ULONG cbInstanceData
,
1382 PULONG pcbReturned
)
1384 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1385 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1386 This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
,pcbReturned
);
1388 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1390 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1391 return DSPROPERTY_WaveDeviceMappingA(pPropData
,cbPropData
,pcbReturned
);
1392 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1393 return DSPROPERTY_Description1(pPropData
,cbPropData
,pcbReturned
);
1394 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1395 return DSPROPERTY_Enumerate1(pPropData
,cbPropData
,pcbReturned
);
1396 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1397 return DSPROPERTY_WaveDeviceMappingW(pPropData
,cbPropData
,pcbReturned
);
1398 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1399 return DSPROPERTY_DescriptionA(pPropData
,cbPropData
,pcbReturned
);
1400 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1401 return DSPROPERTY_DescriptionW(pPropData
,cbPropData
,pcbReturned
);
1402 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1403 return DSPROPERTY_EnumerateA(pPropData
,cbPropData
,pcbReturned
);
1404 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1405 return DSPROPERTY_EnumerateW(pPropData
,cbPropData
,pcbReturned
);
1407 FIXME("unsupported ID: %d\n",dwPropID
);
1411 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1416 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1419 return E_PROP_ID_UNSUPPORTED
;
1422 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Set(
1423 LPKSPROPERTYSET iface
,
1424 REFGUID guidPropSet
,
1426 LPVOID pInstanceData
,
1427 ULONG cbInstanceData
,
1431 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1433 FIXME("(%p,%s,%d,%p,%d,%p,%d), stub!\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
1434 return E_PROP_ID_UNSUPPORTED
;
1437 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QuerySupport(
1438 LPKSPROPERTYSET iface
,
1439 REFGUID guidPropSet
,
1441 PULONG pTypeSupport
)
1443 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1444 TRACE("(%p,%s,%d,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
1446 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1448 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1449 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1451 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1452 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1454 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1455 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1457 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1458 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1460 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1461 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1463 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1464 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1466 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1467 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1469 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1470 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1473 FIXME("unsupported ID: %d\n",dwPropID
);
1477 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1480 return E_PROP_ID_UNSUPPORTED
;
1483 static const IKsPropertySetVtbl ikspvt
= {
1484 IKsPrivatePropertySetImpl_QueryInterface
,
1485 IKsPrivatePropertySetImpl_AddRef
,
1486 IKsPrivatePropertySetImpl_Release
,
1487 IKsPrivatePropertySetImpl_Get
,
1488 IKsPrivatePropertySetImpl_Set
,
1489 IKsPrivatePropertySetImpl_QuerySupport
1492 HRESULT
IKsPrivatePropertySetImpl_Create(
1494 IKsPrivatePropertySetImpl
**piks
)
1496 IKsPrivatePropertySetImpl
*iks
;
1497 TRACE("(%s, %p)\n", debugstr_guid(riid
), piks
);
1499 if (!IsEqualIID(riid
, &IID_IUnknown
) &&
1500 !IsEqualIID(riid
, &IID_IKsPropertySet
)) {
1502 return E_NOINTERFACE
;
1505 iks
= HeapAlloc(GetProcessHeap(),0,sizeof(*iks
));
1507 iks
->lpVtbl
= &ikspvt
;