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 PIDSDRIVERPROPERTYSET ps
= NULL
;
201 IKsBufferPropertySetImpl
*iks
;
202 TRACE("(%p,%p)\n",dsb
,piks
);
206 return DSERR_INVALIDPARAM
;
208 IDsDriver_QueryInterface(dsb
->hwbuf
, &IID_IDsDriverPropertySet
, (void **)&ps
);
210 return DSERR_INVALIDPARAM
;
212 IUnknown_Release(ps
);
214 iks
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*iks
));
216 WARN("out of memory\n");
218 return DSERR_OUTOFMEMORY
;
224 iks
->lpVtbl
= &iksbvt
;
226 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER
)dsb
);
232 HRESULT
IKsBufferPropertySetImpl_Destroy(
233 IKsBufferPropertySetImpl
*piks
)
235 TRACE("(%p)\n",piks
);
237 while (IKsBufferPropertySetImpl_Release((LPKSPROPERTYSET
)piks
) > 0);
242 /*******************************************************************************
243 * IKsPrivatePropertySet
246 /* IUnknown methods */
247 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QueryInterface(
248 LPKSPROPERTYSET iface
,
252 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
253 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
255 if (IsEqualIID(riid
, &IID_IUnknown
) ||
256 IsEqualIID(riid
, &IID_IKsPropertySet
)) {
258 IUnknown_AddRef(iface
);
262 return E_NOINTERFACE
;
265 static ULONG WINAPI
IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface
)
267 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
268 ULONG ref
= InterlockedIncrement(&(This
->ref
));
269 TRACE("(%p) ref was %d\n", This
, ref
- 1);
273 static ULONG WINAPI
IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface
)
275 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
276 ULONG ref
= InterlockedDecrement(&(This
->ref
));
277 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
280 HeapFree(GetProcessHeap(), 0, This
);
281 TRACE("(%p) released\n", This
);
286 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingA(
291 HRESULT hr
= DSERR_INVALIDPARAM
;
292 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd
;
293 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
294 pPropData
,cbPropData
,pcbReturned
);
296 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
) pPropData
;
299 WARN("invalid parameter: pPropData\n");
300 return DSERR_INVALIDPARAM
;
303 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
306 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
307 wodn
= waveOutGetNumDevs();
308 for (wod
= 0; wod
< wodn
; wod
++) {
311 res
= waveOutGetDevCapsA(wod
, &capsA
, sizeof(capsA
));
312 if (res
== MMSYSERR_NOERROR
) {
313 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
314 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
316 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
322 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
325 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
326 widn
= waveInGetNumDevs();
327 for (wid
= 0; wid
< widn
; wid
++) {
330 res
= waveInGetDevCapsA(wid
, &capsA
, sizeof(capsA
));
331 if (res
== MMSYSERR_NOERROR
) {
332 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
333 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
334 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
344 *pcbReturned
= cbPropData
;
349 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingW(
354 HRESULT hr
= DSERR_INVALIDPARAM
;
355 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd
;
356 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
357 pPropData
,cbPropData
,pcbReturned
);
359 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
) pPropData
;
362 WARN("invalid parameter: pPropData\n");
363 return DSERR_INVALIDPARAM
;
366 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
369 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
370 wodn
= waveOutGetNumDevs();
371 for (wod
= 0; wod
< wodn
; wod
++) {
374 res
= waveOutGetDevCapsW(wod
, &capsW
, sizeof(capsW
));
375 if (res
== MMSYSERR_NOERROR
) {
376 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
377 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
379 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
380 debugstr_w(ppd
->DeviceName
));
385 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
388 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
389 widn
= waveInGetNumDevs();
390 for (wid
= 0; wid
< widn
; wid
++) {
393 res
= waveInGetDevCapsW(wid
, &capsW
, sizeof(capsW
));
394 if (res
== MMSYSERR_NOERROR
) {
395 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
396 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
398 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
399 debugstr_w(ppd
->DeviceName
));
407 *pcbReturned
= cbPropData
;
412 static HRESULT WINAPI
DSPROPERTY_Description1(
419 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd
;
420 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
421 pPropData
,cbPropData
,pcbReturned
);
423 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
) pPropData
;
426 WARN("invalid parameter: pPropData\n");
427 return DSERR_INVALIDPARAM
;
430 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
431 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
432 /* default device of type specified by ppd->DataFlow */
433 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
434 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
435 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
436 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
438 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
440 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
441 pPropData
,cbPropData
,pcbReturned
);
442 return E_PROP_ID_UNSUPPORTED
;
445 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
446 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
448 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
449 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
452 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
453 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
454 wodn
= waveOutGetNumDevs();
455 for (wod
= 0; wod
< wodn
; wod
++) {
456 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
458 ppd
->WaveDeviceId
= wod
;
460 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
462 PIDSDRIVER drv
= NULL
;
463 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
464 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
465 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
466 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
467 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
468 if (err
== DS_OK
&& drv
)
469 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
471 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
474 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
475 return E_PROP_ID_UNSUPPORTED
;
479 } else if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
480 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
483 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
484 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
485 widn
= waveInGetNumDevs();
486 for (wid
= 0; wid
< widn
; wid
++) {
487 if (IsEqualGUID( &dev_guid
, &guid
) ) {
489 ppd
->WaveDeviceId
= wid
;
491 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
494 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
495 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
496 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
497 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
498 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
499 if (err
== DS_OK
&& drv
)
500 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
502 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
505 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
506 return E_PROP_ID_UNSUPPORTED
;
514 /* given specific device so try the render devices first */
515 wodn
= waveOutGetNumDevs();
516 for (wod
= 0; wod
< wodn
; wod
++) {
517 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
519 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
520 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
521 ppd
->WaveDeviceId
= wod
;
523 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
525 PIDSDRIVER drv
= NULL
;
526 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
527 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
528 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
529 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
530 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
531 if (err
== DS_OK
&& drv
)
532 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
534 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
538 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
539 return E_PROP_ID_UNSUPPORTED
;
544 if (found
== FALSE
) {
547 /* given specific device so try the capture devices next */
548 widn
= waveInGetNumDevs();
549 for (wid
= 0; wid
< widn
; wid
++) {
550 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
552 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
553 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
554 ppd
->WaveDeviceId
= wid
;
556 err
= mmErr(waveInMessage((HWAVEIN
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
558 PIDSDRIVER drv
= NULL
;
559 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
560 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
561 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
562 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
563 err
= mmErr(waveInMessage((HWAVEIN
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
564 if (err
== DS_OK
&& drv
)
565 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
567 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
571 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
572 return E_PROP_ID_UNSUPPORTED
;
577 if (found
== FALSE
) {
578 WARN("device not found\n");
579 return E_PROP_ID_UNSUPPORTED
;
585 *pcbReturned
= cbPropData
;
586 TRACE("*pcbReturned=%d\n", *pcbReturned
);
592 static HRESULT WINAPI
DSPROPERTY_DescriptionA(
597 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
) pPropData
;
600 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
601 pPropData
,cbPropData
,pcbReturned
);
603 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
604 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
605 /* default device of type specified by ppd->DataFlow */
606 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
607 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
608 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
609 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
611 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
613 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
614 pPropData
,cbPropData
,pcbReturned
);
615 return E_PROP_ID_UNSUPPORTED
;
618 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
619 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
621 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
622 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
625 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
626 TRACE("DSDEVID_DefaultPlayback\n");
628 TRACE("DSDEVID_DefaultVoicePlayback\n");
629 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
630 wodn
= waveOutGetNumDevs();
631 for (wod
= 0; wod
< wodn
; wod
++) {
632 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
634 ppd
->WaveDeviceId
= wod
;
635 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
637 PIDSDRIVER drv
= NULL
;
638 /* FIXME: this is a memory leak */
639 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
640 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
641 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
643 if (szDescription
&& szModule
&& szInterface
) {
644 strcpy(szDescription
, desc
.szDesc
);
645 strcpy(szModule
, desc
.szDrvname
);
646 strcpy(szInterface
, "Interface");
648 ppd
->Description
= szDescription
;
649 ppd
->Module
= szModule
;
650 ppd
->Interface
= szInterface
;
651 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
652 if (err
== DS_OK
&& drv
)
653 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
655 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
659 HeapFree(GetProcessHeap(), 0, szDescription
);
660 HeapFree(GetProcessHeap(), 0, szModule
);
661 HeapFree(GetProcessHeap(), 0, szInterface
);
662 return E_OUTOFMEMORY
;
665 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
666 return E_PROP_ID_UNSUPPORTED
;
670 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
671 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
674 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) )
675 TRACE("DSDEVID_DefaultCapture\n");
677 TRACE("DSDEVID_DefaultVoiceCapture\n");
678 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
679 widn
= waveInGetNumDevs();
680 for (wid
= 0; wid
< widn
; wid
++) {
681 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
683 ppd
->WaveDeviceId
= wid
;
684 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
687 /* FIXME: this is a memory leak */
688 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
689 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
690 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
692 if (szDescription
&& szModule
&& szInterface
) {
693 strcpy(szDescription
, desc
.szDesc
);
694 strcpy(szModule
, desc
.szDrvname
);
695 strcpy(szInterface
, "Interface");
697 ppd
->Description
= szDescription
;
698 ppd
->Module
= szModule
;
699 ppd
->Interface
= szInterface
;
700 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
701 if (err
== DS_OK
&& drv
)
702 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
704 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
708 HeapFree(GetProcessHeap(), 0, szDescription
);
709 HeapFree(GetProcessHeap(), 0, szModule
);
710 HeapFree(GetProcessHeap(), 0, szInterface
);
711 return E_OUTOFMEMORY
;
714 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
715 return E_PROP_ID_UNSUPPORTED
;
723 /* given specific device so try the render devices first */
724 TRACE("Checking renderer devices\n");
725 wodn
= waveOutGetNumDevs();
726 for (wod
= 0; wod
< wodn
; wod
++) {
727 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
729 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
730 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
731 ppd
->WaveDeviceId
= wod
;
732 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
734 PIDSDRIVER drv
= NULL
;
735 /* FIXME: this is a memory leak */
736 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
737 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
738 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
740 if (szDescription
&& szModule
&& szInterface
) {
741 strcpy(szDescription
, desc
.szDesc
);
742 strcpy(szModule
, desc
.szDrvname
);
743 strcpy(szInterface
, "Interface");
745 ppd
->Description
= szDescription
;
746 ppd
->Module
= szModule
;
747 ppd
->Interface
= szInterface
;
748 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
749 if (err
== DS_OK
&& drv
)
750 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
752 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
757 HeapFree(GetProcessHeap(), 0, szDescription
);
758 HeapFree(GetProcessHeap(), 0, szModule
);
759 HeapFree(GetProcessHeap(), 0, szInterface
);
760 return E_OUTOFMEMORY
;
763 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
764 return E_PROP_ID_UNSUPPORTED
;
769 if (found
== FALSE
) {
772 TRACE("Checking capture devices\n");
773 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
774 widn
= waveInGetNumDevs();
775 for (wid
= 0; wid
< widn
; wid
++) {
776 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
778 TRACE("DSOUND_capture_guids[%d]\n", wid
);
779 ppd
->WaveDeviceId
= wid
;
780 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
783 /* FIXME: this is a memory leak */
784 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
785 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
786 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
788 if (szDescription
&& szModule
&& szInterface
) {
789 strcpy(szDescription
, desc
.szDesc
);
790 strcpy(szModule
, desc
.szDrvname
);
791 strcpy(szInterface
, "Interface");
793 ppd
->Description
= szDescription
;
794 ppd
->Module
= szModule
;
795 ppd
->Interface
= szInterface
;
796 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
797 if (err
== DS_OK
&& drv
)
798 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
800 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
805 HeapFree(GetProcessHeap(), 0, szDescription
);
806 HeapFree(GetProcessHeap(), 0, szModule
);
807 HeapFree(GetProcessHeap(), 0, szInterface
);
808 return E_OUTOFMEMORY
;
811 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
812 return E_PROP_ID_UNSUPPORTED
;
818 if (found
== FALSE
) {
819 WARN("device not found\n");
820 return E_PROP_ID_UNSUPPORTED
;
825 *pcbReturned
= cbPropData
;
826 TRACE("*pcbReturned=%d\n", *pcbReturned
);
832 static HRESULT WINAPI
DSPROPERTY_DescriptionW(
837 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
) pPropData
;
840 TRACE("pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
841 pPropData
,cbPropData
,pcbReturned
);
843 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
844 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
845 /* default device of type specified by ppd->DataFlow */
846 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
847 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
848 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
849 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
851 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
853 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
854 pPropData
,cbPropData
,pcbReturned
);
855 return E_PROP_ID_UNSUPPORTED
;
858 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
859 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
861 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
862 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
865 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
866 TRACE("DSDEVID_DefaultPlayback\n");
868 TRACE("DSDEVID_DefaultVoicePlayback\n");
869 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
870 wodn
= waveOutGetNumDevs();
871 for (wod
= 0; wod
< wodn
; wod
++) {
872 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
874 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
875 ppd
->WaveDeviceId
= wod
;
876 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
878 PIDSDRIVER drv
= NULL
;
879 /* FIXME: this is a memory leak */
880 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
881 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
882 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
884 if (wDescription
&& wModule
&& wInterface
) {
885 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
886 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
887 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
889 ppd
->Description
= wDescription
;
890 ppd
->Module
= wModule
;
891 ppd
->Interface
= wInterface
;
892 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
893 if (err
== DS_OK
&& drv
)
894 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
896 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
900 HeapFree(GetProcessHeap(), 0, wDescription
);
901 HeapFree(GetProcessHeap(), 0, wModule
);
902 HeapFree(GetProcessHeap(), 0, wInterface
);
903 return E_OUTOFMEMORY
;
906 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
907 return E_PROP_ID_UNSUPPORTED
;
911 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
912 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
915 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
))
916 TRACE("DSDEVID_DefaultCapture\n");
918 TRACE("DSDEVID_DefaultVoiceCapture\n");
919 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
920 widn
= waveInGetNumDevs();
921 for (wid
= 0; wid
< widn
; wid
++) {
922 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
924 ppd
->WaveDeviceId
= wid
;
925 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
928 /* FIXME: this is a memory leak */
929 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
930 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
931 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
933 if (wDescription
&& wModule
&& wInterface
) {
934 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
935 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
936 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
938 ppd
->Description
= wDescription
;
939 ppd
->Module
= wModule
;
940 ppd
->Interface
= wInterface
;
941 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
942 if (err
== DS_OK
&& drv
)
943 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
945 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
949 HeapFree(GetProcessHeap(), 0, wDescription
);
950 HeapFree(GetProcessHeap(), 0, wModule
);
951 HeapFree(GetProcessHeap(), 0, wInterface
);
952 return E_OUTOFMEMORY
;
955 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
956 return E_PROP_ID_UNSUPPORTED
;
964 TRACE("Checking renderer devices\n");
965 /* given specific device so try the render devices first */
966 wodn
= waveOutGetNumDevs();
967 for (wod
= 0; wod
< wodn
; wod
++) {
968 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
970 TRACE("DSOUND_renderer_guids[%d]\n", wod
);
971 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
972 ppd
->WaveDeviceId
= wod
;
973 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
975 PIDSDRIVER drv
= NULL
;
976 /* FIXME: this is a memory leak */
977 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
978 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
979 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
981 if (wDescription
&& wModule
&& wInterface
) {
982 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
983 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
984 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
986 ppd
->Description
= wDescription
;
987 ppd
->Module
= wModule
;
988 ppd
->Interface
= wInterface
;
989 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
990 if (err
== DS_OK
&& drv
)
991 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
993 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
998 HeapFree(GetProcessHeap(), 0, wDescription
);
999 HeapFree(GetProcessHeap(), 0, wModule
);
1000 HeapFree(GetProcessHeap(), 0, wInterface
);
1001 return E_OUTOFMEMORY
;
1004 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
1005 return E_PROP_ID_UNSUPPORTED
;
1010 if (found
== FALSE
) {
1013 TRACE("Checking capture devices\n");
1014 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1015 widn
= waveInGetNumDevs();
1016 for (wid
= 0; wid
< widn
; wid
++) {
1017 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
1019 TRACE("DSOUND_capture_guids[%d]\n", wid
);
1020 ppd
->WaveDeviceId
= wid
;
1021 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
1024 /* FIXME: this is a memory leak */
1025 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1026 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1027 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
1029 if (wDescription
&& wModule
&& wInterface
) {
1030 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1031 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1032 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
1034 ppd
->Description
= wDescription
;
1035 ppd
->Module
= wModule
;
1036 ppd
->Interface
= wInterface
;
1037 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
1038 if (err
== DS_OK
&& drv
)
1039 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1041 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1045 WARN("no memory\n");
1046 HeapFree(GetProcessHeap(), 0, wDescription
);
1047 HeapFree(GetProcessHeap(), 0, wModule
);
1048 HeapFree(GetProcessHeap(), 0, wInterface
);
1049 return E_OUTOFMEMORY
;
1052 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1053 return E_PROP_ID_UNSUPPORTED
;
1059 if (found
== FALSE
) {
1060 WARN("device not found\n");
1061 return E_PROP_ID_UNSUPPORTED
;
1066 *pcbReturned
= cbPropData
;
1067 TRACE("*pcbReturned=%d\n", *pcbReturned
);
1073 static HRESULT WINAPI
DSPROPERTY_Enumerate1(
1076 PULONG pcbReturned
)
1078 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
) pPropData
;
1080 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1081 pPropData
,cbPropData
,pcbReturned
);
1084 if (ppd
->Callback
) {
1085 unsigned devs
, wod
, wid
;
1087 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data
;
1089 devs
= waveOutGetNumDevs();
1090 for (wod
= 0; wod
< devs
; ++wod
) {
1091 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1094 ZeroMemory(&data
, sizeof(data
));
1095 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1096 data
.WaveDeviceId
= wod
;
1097 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1098 lstrcpynA(data
.DescriptionA
, desc
.szDesc
, sizeof(data
.DescriptionA
));
1099 lstrcpynA(data
.ModuleA
, desc
.szDrvname
, sizeof(data
.ModuleA
));
1101 MultiByteToWideChar( CP_ACP
, 0, data
.DescriptionA
, -1, data
.DescriptionW
, sizeof(data
.DescriptionW
)/sizeof(WCHAR
) );
1102 MultiByteToWideChar( CP_ACP
, 0, data
.ModuleA
, -1, data
.ModuleW
, sizeof(data
.ModuleW
)/sizeof(WCHAR
) );
1104 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1105 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1106 if (err
== DS_OK
&& drv
)
1107 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1109 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1111 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1112 (ppd
->Callback
)(&data
, ppd
->Context
);
1116 devs
= waveInGetNumDevs();
1117 for (wid
= 0; wid
< devs
; ++wid
) {
1118 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1121 ZeroMemory(&data
, sizeof(data
));
1122 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1123 data
.WaveDeviceId
= wid
;
1124 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1125 lstrcpynA(data
.DescriptionA
, desc
.szDesc
, sizeof(data
.DescriptionA
));
1126 lstrcpynA(data
.ModuleA
, desc
.szDrvname
, sizeof(data
.ModuleA
));
1128 MultiByteToWideChar( CP_ACP
, 0, data
.DescriptionA
, -1, data
.DescriptionW
, sizeof(data
.DescriptionW
)/sizeof(WCHAR
) );
1129 MultiByteToWideChar( CP_ACP
, 0, data
.ModuleA
, -1, data
.ModuleW
, sizeof(data
.ModuleW
)/sizeof(WCHAR
) );
1131 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1132 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1133 if (err
== DS_OK
&& drv
)
1134 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1136 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1138 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1139 (ppd
->Callback
)(&data
, ppd
->Context
);
1149 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1152 return E_PROP_ID_UNSUPPORTED
;
1155 static HRESULT WINAPI
DSPROPERTY_EnumerateA(
1158 PULONG pcbReturned
)
1160 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
) pPropData
;
1162 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1163 pPropData
,cbPropData
,pcbReturned
);
1166 if (ppd
->Callback
) {
1167 unsigned devs
, wod
, wid
;
1169 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data
;
1171 devs
= waveOutGetNumDevs();
1172 for (wod
= 0; wod
< devs
; ++wod
) {
1173 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1176 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1178 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1180 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1182 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1185 ZeroMemory(&data
, sizeof(data
));
1186 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1187 data
.WaveDeviceId
= wod
;
1188 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1189 data
.Description
= desc
.szDesc
;
1190 data
.Module
= desc
.szDrvname
;
1191 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1192 data
.Interface
= szInterface
;
1194 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1195 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1196 if (err
== DS_OK
&& drv
)
1197 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1199 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1201 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1202 (ppd
->Callback
)(&data
, ppd
->Context
);
1204 HeapFree(GetProcessHeap(),0,szInterface
);
1207 HeapFree(GetProcessHeap(),0,nameW
);
1212 devs
= waveInGetNumDevs();
1213 for (wid
= 0; wid
< devs
; ++wid
) {
1214 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1217 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1219 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1221 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1223 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1226 ZeroMemory(&data
, sizeof(data
));
1227 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1228 data
.WaveDeviceId
= wid
;
1229 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1230 data
.Description
= desc
.szDesc
;
1231 data
.Module
= desc
.szDrvname
;
1232 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1233 data
.Interface
= szInterface
;
1235 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1236 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1237 if (err
== DS_OK
&& drv
)
1238 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1240 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1242 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1243 (ppd
->Callback
)(&data
, ppd
->Context
);
1245 HeapFree(GetProcessHeap(),0,szInterface
);
1248 HeapFree(GetProcessHeap(),0,nameW
);
1259 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1262 return E_PROP_ID_UNSUPPORTED
;
1265 static HRESULT WINAPI
DSPROPERTY_EnumerateW(
1268 PULONG pcbReturned
)
1270 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
) pPropData
;
1272 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1273 pPropData
,cbPropData
,pcbReturned
);
1276 if (ppd
->Callback
) {
1277 unsigned devs
, wod
, wid
;
1279 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data
;
1281 devs
= waveOutGetNumDevs();
1282 for (wod
= 0; wod
< devs
; ++wod
) {
1283 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1285 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1286 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1287 if (wDescription
&& wModule
) {
1289 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACESIZE
, (DWORD_PTR
)&size
, 0));
1291 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,size
);
1293 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDEVICEINTERFACE
, (DWORD_PTR
)wInterface
, size
));
1296 ZeroMemory(&data
, sizeof(data
));
1297 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1298 data
.WaveDeviceId
= wod
;
1299 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1301 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1302 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1304 data
.Description
= wDescription
;
1305 data
.Module
= wModule
;
1306 data
.Interface
= wInterface
;
1308 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1309 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1310 if (err
== DS_OK
&& drv
)
1311 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1313 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1315 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1316 (ppd
->Callback
)(&data
, ppd
->Context
);
1319 HeapFree(GetProcessHeap(),0,wInterface
);
1322 HeapFree(GetProcessHeap(),0,wDescription
);
1323 HeapFree(GetProcessHeap(),0,wModule
);
1327 devs
= waveInGetNumDevs();
1328 for (wid
= 0; wid
< devs
; ++wid
) {
1329 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1331 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1332 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1333 if (wDescription
&& wModule
) {
1335 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACESIZE
, (DWORD_PTR
)&size
, 0));
1337 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,size
);
1339 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDEVICEINTERFACE
, (DWORD_PTR
)wInterface
, size
));
1342 ZeroMemory(&data
, sizeof(data
));
1343 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1344 data
.WaveDeviceId
= wid
;
1345 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1347 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1348 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1350 data
.Description
= wDescription
;
1351 data
.Module
= wModule
;
1352 data
.Interface
= wInterface
;
1353 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1354 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1355 if (err
== DS_OK
&& drv
)
1356 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1358 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1360 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1361 (ppd
->Callback
)(&data
, ppd
->Context
);
1364 HeapFree(GetProcessHeap(),0,wInterface
);
1367 HeapFree(GetProcessHeap(),0,wDescription
);
1368 HeapFree(GetProcessHeap(),0,wModule
);
1378 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1381 return E_PROP_ID_UNSUPPORTED
;
1384 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Get(
1385 LPKSPROPERTYSET iface
,
1386 REFGUID guidPropSet
,
1388 LPVOID pInstanceData
,
1389 ULONG cbInstanceData
,
1392 PULONG pcbReturned
)
1394 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1395 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1396 This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
,pcbReturned
);
1398 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1400 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1401 return DSPROPERTY_WaveDeviceMappingA(pPropData
,cbPropData
,pcbReturned
);
1402 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1403 return DSPROPERTY_Description1(pPropData
,cbPropData
,pcbReturned
);
1404 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1405 return DSPROPERTY_Enumerate1(pPropData
,cbPropData
,pcbReturned
);
1406 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1407 return DSPROPERTY_WaveDeviceMappingW(pPropData
,cbPropData
,pcbReturned
);
1408 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1409 return DSPROPERTY_DescriptionA(pPropData
,cbPropData
,pcbReturned
);
1410 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1411 return DSPROPERTY_DescriptionW(pPropData
,cbPropData
,pcbReturned
);
1412 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1413 return DSPROPERTY_EnumerateA(pPropData
,cbPropData
,pcbReturned
);
1414 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1415 return DSPROPERTY_EnumerateW(pPropData
,cbPropData
,pcbReturned
);
1417 FIXME("unsupported ID: %d\n",dwPropID
);
1421 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1426 FIXME("*pcbReturned=%d\n", *pcbReturned
);
1429 return E_PROP_ID_UNSUPPORTED
;
1432 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Set(
1433 LPKSPROPERTYSET iface
,
1434 REFGUID guidPropSet
,
1436 LPVOID pInstanceData
,
1437 ULONG cbInstanceData
,
1441 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1443 FIXME("(%p,%s,%d,%p,%d,%p,%d), stub!\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
1444 return E_PROP_ID_UNSUPPORTED
;
1447 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QuerySupport(
1448 LPKSPROPERTYSET iface
,
1449 REFGUID guidPropSet
,
1451 PULONG pTypeSupport
)
1453 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1454 TRACE("(%p,%s,%d,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
1456 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1458 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1459 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1461 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1462 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1464 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1465 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1467 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1468 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1470 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1471 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1473 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1474 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1476 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1477 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1479 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1480 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1483 FIXME("unsupported ID: %d\n",dwPropID
);
1487 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1490 return E_PROP_ID_UNSUPPORTED
;
1493 static const IKsPropertySetVtbl ikspvt
= {
1494 IKsPrivatePropertySetImpl_QueryInterface
,
1495 IKsPrivatePropertySetImpl_AddRef
,
1496 IKsPrivatePropertySetImpl_Release
,
1497 IKsPrivatePropertySetImpl_Get
,
1498 IKsPrivatePropertySetImpl_Set
,
1499 IKsPrivatePropertySetImpl_QuerySupport
1502 HRESULT
IKsPrivatePropertySetImpl_Create(
1504 IKsPrivatePropertySetImpl
**piks
)
1506 IKsPrivatePropertySetImpl
*iks
;
1507 TRACE("(%s, %p)\n", debugstr_guid(riid
), piks
);
1509 if (!IsEqualIID(riid
, &IID_IUnknown
) &&
1510 !IsEqualIID(riid
, &IID_IKsPropertySet
)) {
1512 return E_NOINTERFACE
;
1515 iks
= HeapAlloc(GetProcessHeap(),0,sizeof(*iks
));
1517 iks
->lpVtbl
= &ikspvt
;