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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
35 #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 %ld\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 %ld\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=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,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
->dsound
;
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,%ld,%p,%ld,%p,%ld)\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
->dsound
;
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,%ld,%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 WINAPI
IKsBufferPropertySetImpl_Create(
197 IDirectSoundBufferImpl
*dsb
,
198 IKsBufferPropertySetImpl
**piks
)
200 IKsBufferPropertySetImpl
*iks
;
201 TRACE("(%p,%p)\n",dsb
,piks
);
203 iks
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*iks
));
205 WARN("out of memory\n");
207 return DSERR_OUTOFMEMORY
;
213 iks
->lpVtbl
= &iksbvt
;
215 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER
)dsb
);
221 HRESULT WINAPI
IKsBufferPropertySetImpl_Destroy(
222 IKsBufferPropertySetImpl
*piks
)
224 TRACE("(%p)\n",piks
);
226 while (IKsBufferPropertySetImpl_Release((LPKSPROPERTYSET
)piks
) > 0);
231 /*******************************************************************************
232 * IKsPrivatePropertySet
235 /* IUnknown methods */
236 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QueryInterface(
237 LPKSPROPERTYSET iface
,
241 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
242 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
245 return DSERR_INVALIDPARAM
;
248 static ULONG WINAPI
IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface
)
250 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
251 ULONG ref
= InterlockedIncrement(&(This
->ref
));
252 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
256 static ULONG WINAPI
IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface
)
258 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
259 ULONG ref
= InterlockedDecrement(&(This
->ref
));
260 TRACE("(%p) ref was %ld\n", This
, ref
+ 1);
263 HeapFree(GetProcessHeap(), 0, This
);
264 TRACE("(%p) released\n", This
);
269 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingA(
275 HRESULT hr
= DSERR_INVALIDPARAM
;
276 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd
;
277 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) not implemented!\n",
278 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
280 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA
) pPropData
;
283 WARN("invalid parameter: pPropData\n");
284 return DSERR_INVALIDPARAM
;
287 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
290 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
291 wodn
= waveOutGetNumDevs();
292 for (wod
= 0; wod
< wodn
; wod
++) {
295 res
= waveOutGetDevCapsA(wod
, &capsA
, sizeof(capsA
));
296 if (res
== MMSYSERR_NOERROR
) {
297 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
298 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
300 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
306 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
309 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
310 widn
= waveInGetNumDevs();
311 for (wid
= 0; wid
< widn
; wid
++) {
314 res
= waveInGetDevCapsA(wid
, &capsA
, sizeof(capsA
));
315 if (res
== MMSYSERR_NOERROR
) {
316 if (lstrcmpA(capsA
.szPname
, ppd
->DeviceName
) == 0) {
317 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
318 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
328 *pcbReturned
= cbPropData
;
333 static HRESULT WINAPI
DSPROPERTY_WaveDeviceMappingW(
339 HRESULT hr
= DSERR_INVALIDPARAM
;
340 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd
;
341 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
342 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
344 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA
) pPropData
;
347 WARN("invalid parameter: pPropData\n");
348 return DSERR_INVALIDPARAM
;
351 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
354 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
355 wodn
= waveOutGetNumDevs();
356 for (wod
= 0; wod
< wodn
; wod
++) {
359 res
= waveOutGetDevCapsW(wod
, &capsW
, sizeof(capsW
));
360 if (res
== MMSYSERR_NOERROR
) {
361 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
362 ppd
->DeviceId
= DSOUND_renderer_guids
[wod
];
364 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
365 debugstr_w(ppd
->DeviceName
));
370 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
373 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
374 widn
= waveInGetNumDevs();
375 for (wid
= 0; wid
< widn
; wid
++) {
378 res
= waveInGetDevCapsW(wid
, &capsW
, sizeof(capsW
));
379 if (res
== MMSYSERR_NOERROR
) {
380 if (lstrcmpW(capsW
.szPname
, ppd
->DeviceName
) == 0) {
381 ppd
->DeviceId
= DSOUND_capture_guids
[wid
];
383 TRACE("found %s for %s\n", debugstr_guid(&ppd
->DeviceId
),
384 debugstr_w(ppd
->DeviceName
));
392 *pcbReturned
= cbPropData
;
397 static HRESULT WINAPI
DSPROPERTY_Description1(
405 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd
;
406 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
407 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
409 ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
) pPropData
;
412 WARN("invalid parameter: pPropData\n");
413 return DSERR_INVALIDPARAM
;
416 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
417 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
418 /* default device of type specified by ppd->DataFlow */
419 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
420 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
421 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
422 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
424 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
426 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
427 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
428 return E_PROP_ID_UNSUPPORTED
;
431 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
432 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
434 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
435 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
438 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
439 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
440 wodn
= waveOutGetNumDevs();
441 for (wod
= 0; wod
< wodn
; wod
++) {
442 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
444 ppd
->WaveDeviceId
= wod
;
446 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
448 PIDSDRIVER drv
= NULL
;
449 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
450 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
451 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
452 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
453 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
454 if (err
== DS_OK
&& drv
)
455 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
457 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
460 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
461 return E_PROP_ID_UNSUPPORTED
;
465 } else if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
466 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
469 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
470 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
471 widn
= waveInGetNumDevs();
472 for (wid
= 0; wid
< widn
; wid
++) {
473 if (IsEqualGUID( &dev_guid
, &guid
) ) {
475 ppd
->WaveDeviceId
= wid
;
477 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
480 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
481 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
482 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
483 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
484 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
485 if (err
== DS_OK
&& drv
)
486 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
488 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
491 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
492 return E_PROP_ID_UNSUPPORTED
;
500 /* given specific device so try the render devices first */
501 wodn
= waveOutGetNumDevs();
502 for (wod
= 0; wod
< wodn
; wod
++) {
503 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
505 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
506 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
507 ppd
->WaveDeviceId
= wod
;
509 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
511 PIDSDRIVER drv
= NULL
;
512 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
513 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
514 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
515 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
516 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
517 if (err
== DS_OK
&& drv
)
518 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
520 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
524 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
525 return E_PROP_ID_UNSUPPORTED
;
530 if (found
== FALSE
) {
533 /* given specific device so try the capture devices next */
534 widn
= waveInGetNumDevs();
535 for (wid
= 0; wid
< widn
; wid
++) {
536 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
538 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
539 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
540 ppd
->WaveDeviceId
= wid
;
542 err
= mmErr(waveInMessage((HWAVEIN
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
544 PIDSDRIVER drv
= NULL
;
545 lstrcpynA(ppd
->DescriptionA
, desc
.szDesc
, sizeof(ppd
->DescriptionA
));
546 lstrcpynA(ppd
->ModuleA
, desc
.szDrvname
, sizeof(ppd
->ModuleA
));
547 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, ppd
->DescriptionW
, sizeof(ppd
->DescriptionW
)/sizeof(WCHAR
) );
548 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, ppd
->ModuleW
, sizeof(ppd
->ModuleW
)/sizeof(WCHAR
) );
549 err
= mmErr(waveInMessage((HWAVEIN
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
550 if (err
== DS_OK
&& drv
)
551 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
553 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
557 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
558 return E_PROP_ID_UNSUPPORTED
;
563 if (found
== FALSE
) {
564 WARN("device not found\n");
565 return E_PROP_ID_UNSUPPORTED
;
571 *pcbReturned
= cbPropData
;
572 TRACE("*pcbReturned=%ld\n", *pcbReturned
);
578 static HRESULT WINAPI
DSPROPERTY_DescriptionA(
584 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA
) pPropData
;
587 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
588 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
590 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
591 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
592 /* default device of type specified by ppd->DataFlow */
593 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
594 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
595 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
596 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
598 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
600 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
601 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
602 return E_PROP_ID_UNSUPPORTED
;
605 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
606 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
608 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
609 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
612 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
613 TRACE("DSDEVID_DefaultPlayback\n");
615 TRACE("DSDEVID_DefaultVoicePlayback\n");
616 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
617 wodn
= waveOutGetNumDevs();
618 for (wod
= 0; wod
< wodn
; wod
++) {
619 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
621 ppd
->WaveDeviceId
= wod
;
622 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
624 PIDSDRIVER drv
= NULL
;
625 /* FIXME: this is a memory leak */
626 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
627 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
628 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
630 if (szDescription
&& szModule
&& szInterface
) {
631 strcpy(szDescription
, desc
.szDesc
);
632 strcpy(szModule
, desc
.szDrvname
);
633 strcpy(szInterface
, "Interface");
635 ppd
->Description
= szDescription
;
636 ppd
->Module
= szModule
;
637 ppd
->Interface
= szInterface
;
638 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
639 if (err
== DS_OK
&& drv
)
640 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
642 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
646 HeapFree(GetProcessHeap(), 0, szDescription
);
647 HeapFree(GetProcessHeap(), 0, szModule
);
648 HeapFree(GetProcessHeap(), 0, szInterface
);
649 return E_OUTOFMEMORY
;
652 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
653 return E_PROP_ID_UNSUPPORTED
;
657 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
658 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
661 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) )
662 TRACE("DSDEVID_DefaultCapture\n");
664 TRACE("DSDEVID_DefaultVoiceCapture\n");
665 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
666 widn
= waveInGetNumDevs();
667 for (wid
= 0; wid
< widn
; wid
++) {
668 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
670 ppd
->WaveDeviceId
= wid
;
671 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
674 /* FIXME: this is a memory leak */
675 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
676 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
677 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
679 if (szDescription
&& szModule
&& szInterface
) {
680 strcpy(szDescription
, desc
.szDesc
);
681 strcpy(szModule
, desc
.szDrvname
);
682 strcpy(szInterface
, "Interface");
684 ppd
->Description
= szDescription
;
685 ppd
->Module
= szModule
;
686 ppd
->Interface
= szInterface
;
687 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
688 if (err
== DS_OK
&& drv
)
689 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
691 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
695 HeapFree(GetProcessHeap(), 0, szDescription
);
696 HeapFree(GetProcessHeap(), 0, szModule
);
697 HeapFree(GetProcessHeap(), 0, szInterface
);
698 return E_OUTOFMEMORY
;
701 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
702 return E_PROP_ID_UNSUPPORTED
;
710 /* given specific device so try the render devices first */
711 TRACE("Checking renderer devices\n");
712 wodn
= waveOutGetNumDevs();
713 for (wod
= 0; wod
< wodn
; wod
++) {
714 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
716 TRACE("DSOUND_renderer_guids[%ld]\n", wod
);
717 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
718 ppd
->WaveDeviceId
= wod
;
719 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
721 PIDSDRIVER drv
= NULL
;
722 /* FIXME: this is a memory leak */
723 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
724 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
725 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
727 if (szDescription
&& szModule
&& szInterface
) {
728 strcpy(szDescription
, desc
.szDesc
);
729 strcpy(szModule
, desc
.szDrvname
);
730 strcpy(szInterface
, "Interface");
732 ppd
->Description
= szDescription
;
733 ppd
->Module
= szModule
;
734 ppd
->Interface
= szInterface
;
735 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
736 if (err
== DS_OK
&& drv
)
737 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
739 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
744 HeapFree(GetProcessHeap(), 0, szDescription
);
745 HeapFree(GetProcessHeap(), 0, szModule
);
746 HeapFree(GetProcessHeap(), 0, szInterface
);
747 return E_OUTOFMEMORY
;
750 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
751 return E_PROP_ID_UNSUPPORTED
;
756 if (found
== FALSE
) {
759 TRACE("Checking capture devices\n");
760 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
761 widn
= waveInGetNumDevs();
762 for (wid
= 0; wid
< widn
; wid
++) {
763 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_capture_guids
[wid
] ) ) {
765 TRACE("DSOUND_capture_guids[%ld]\n", wid
);
766 ppd
->WaveDeviceId
= wid
;
767 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
770 /* FIXME: this is a memory leak */
771 CHAR
* szDescription
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDesc
) + 1);
772 CHAR
* szModule
= HeapAlloc(GetProcessHeap(),0,strlen(desc
.szDrvname
) + 1);
773 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
775 if (szDescription
&& szModule
&& szInterface
) {
776 strcpy(szDescription
, desc
.szDesc
);
777 strcpy(szModule
, desc
.szDrvname
);
778 strcpy(szInterface
, "Interface");
780 ppd
->Description
= szDescription
;
781 ppd
->Module
= szModule
;
782 ppd
->Interface
= szInterface
;
783 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
784 if (err
== DS_OK
&& drv
)
785 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
787 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
792 HeapFree(GetProcessHeap(), 0, szDescription
);
793 HeapFree(GetProcessHeap(), 0, szModule
);
794 HeapFree(GetProcessHeap(), 0, szInterface
);
795 return E_OUTOFMEMORY
;
798 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
799 return E_PROP_ID_UNSUPPORTED
;
805 if (found
== FALSE
) {
806 WARN("device not found\n");
807 return E_PROP_ID_UNSUPPORTED
;
812 *pcbReturned
= cbPropData
;
813 TRACE("*pcbReturned=%ld\n", *pcbReturned
);
819 static HRESULT WINAPI
DSPROPERTY_DescriptionW(
825 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA
) pPropData
;
828 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
829 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
831 TRACE("DeviceId=%s\n",debugstr_guid(&ppd
->DeviceId
));
832 if ( IsEqualGUID( &ppd
->DeviceId
, &GUID_NULL
) ) {
833 /* default device of type specified by ppd->DataFlow */
834 if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
) {
835 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
836 } else if (ppd
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_RENDER
) {
837 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
839 TRACE("DataFlow=Unknown(%d)\n", ppd
->DataFlow
);
841 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
842 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
843 return E_PROP_ID_UNSUPPORTED
;
846 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
847 GetDeviceID(&ppd
->DeviceId
, &dev_guid
);
849 if ( IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) ||
850 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoicePlayback
) ) {
853 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultPlayback
) )
854 TRACE("DSDEVID_DefaultPlayback\n");
856 TRACE("DSDEVID_DefaultVoicePlayback\n");
857 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
858 wodn
= waveOutGetNumDevs();
859 for (wod
= 0; wod
< wodn
; wod
++) {
860 if (IsEqualGUID( &dev_guid
, &DSOUND_renderer_guids
[wod
] ) ) {
862 TRACE("DSOUND_renderer_guids[%ld]\n", wod
);
863 ppd
->WaveDeviceId
= wod
;
864 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
866 PIDSDRIVER drv
= NULL
;
867 /* FIXME: this is a memory leak */
868 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
869 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
870 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
872 if (wDescription
&& wModule
&& wInterface
) {
873 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
874 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
875 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
877 ppd
->Description
= wDescription
;
878 ppd
->Module
= wModule
;
879 ppd
->Interface
= wInterface
;
880 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
881 if (err
== DS_OK
&& drv
)
882 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
884 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
888 HeapFree(GetProcessHeap(), 0, wDescription
);
889 HeapFree(GetProcessHeap(), 0, wModule
);
890 HeapFree(GetProcessHeap(), 0, wInterface
);
891 return E_OUTOFMEMORY
;
894 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
895 return E_PROP_ID_UNSUPPORTED
;
899 } else if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
) ||
900 IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultVoiceCapture
) ) {
903 if (IsEqualGUID( &ppd
->DeviceId
, &DSDEVID_DefaultCapture
))
904 TRACE("DSDEVID_DefaultCapture\n");
906 TRACE("DSDEVID_DefaultVoiceCapture\n");
907 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
908 widn
= waveInGetNumDevs();
909 for (wid
= 0; wid
< widn
; wid
++) {
910 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
912 ppd
->WaveDeviceId
= wid
;
913 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
916 /* FIXME: this is a memory leak */
917 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
918 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
919 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
921 if (wDescription
&& wModule
&& wInterface
) {
922 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
923 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
924 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
926 ppd
->Description
= wDescription
;
927 ppd
->Module
= wModule
;
928 ppd
->Interface
= wInterface
;
929 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
930 if (err
== DS_OK
&& drv
)
931 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
933 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
937 HeapFree(GetProcessHeap(), 0, wDescription
);
938 HeapFree(GetProcessHeap(), 0, wModule
);
939 HeapFree(GetProcessHeap(), 0, wInterface
);
940 return E_OUTOFMEMORY
;
943 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
944 return E_PROP_ID_UNSUPPORTED
;
952 TRACE("Checking renderer devices\n");
953 /* given specific device so try the render devices first */
954 wodn
= waveOutGetNumDevs();
955 for (wod
= 0; wod
< wodn
; wod
++) {
956 if (IsEqualGUID( &ppd
->DeviceId
, &DSOUND_renderer_guids
[wod
] ) ) {
958 TRACE("DSOUND_renderer_guids[%ld]\n", wod
);
959 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
960 ppd
->WaveDeviceId
= wod
;
961 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
963 PIDSDRIVER drv
= NULL
;
964 /* FIXME: this is a memory leak */
965 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
966 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
967 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
969 if (wDescription
&& wModule
&& wInterface
) {
970 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
971 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
972 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
974 ppd
->Description
= wDescription
;
975 ppd
->Module
= wModule
;
976 ppd
->Interface
= wInterface
;
977 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
978 if (err
== DS_OK
&& drv
)
979 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
981 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
986 HeapFree(GetProcessHeap(), 0, wDescription
);
987 HeapFree(GetProcessHeap(), 0, wModule
);
988 HeapFree(GetProcessHeap(), 0, wInterface
);
989 return E_OUTOFMEMORY
;
992 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
993 return E_PROP_ID_UNSUPPORTED
;
998 if (found
== FALSE
) {
1001 TRACE("Checking capture devices\n");
1002 ppd
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1003 widn
= waveInGetNumDevs();
1004 for (wid
= 0; wid
< widn
; wid
++) {
1005 if (IsEqualGUID( &dev_guid
, &DSOUND_capture_guids
[wid
] ) ) {
1007 TRACE("DSOUND_capture_guids[%ld]\n", wid
);
1008 ppd
->WaveDeviceId
= wid
;
1009 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&(desc
),0));
1012 /* FIXME: this is a memory leak */
1013 WCHAR
* wDescription
= HeapAlloc(GetProcessHeap(),0,0x200);
1014 WCHAR
* wModule
= HeapAlloc(GetProcessHeap(),0,0x200);
1015 WCHAR
* wInterface
= HeapAlloc(GetProcessHeap(),0,0x200);
1017 if (wDescription
&& wModule
&& wInterface
) {
1018 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1, wDescription
, 0x100 );
1019 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1, wModule
, 0x100 );
1020 MultiByteToWideChar( CP_ACP
, 0, "Interface", -1, wInterface
, 0x100 );
1022 ppd
->Description
= wDescription
;
1023 ppd
->Module
= wModule
;
1024 ppd
->Interface
= wInterface
;
1025 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD_PTR
)&drv
,0));
1026 if (err
== DS_OK
&& drv
)
1027 ppd
->Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1029 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1033 WARN("no memory\n");
1034 HeapFree(GetProcessHeap(), 0, wDescription
);
1035 HeapFree(GetProcessHeap(), 0, wModule
);
1036 HeapFree(GetProcessHeap(), 0, wInterface
);
1037 return E_OUTOFMEMORY
;
1040 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1041 return E_PROP_ID_UNSUPPORTED
;
1047 if (found
== FALSE
) {
1048 WARN("device not found\n");
1049 return E_PROP_ID_UNSUPPORTED
;
1054 *pcbReturned
= cbPropData
;
1055 TRACE("*pcbReturned=%ld\n", *pcbReturned
);
1061 static HRESULT WINAPI
DSPROPERTY_Enumerate1(
1062 REFGUID guidPropSet
,
1065 PULONG pcbReturned
)
1067 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA
) pPropData
;
1069 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1070 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
1072 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
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
);
1137 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1142 FIXME("*pcbReturned=%ld\n", *pcbReturned
);
1145 return E_PROP_ID_UNSUPPORTED
;
1148 static HRESULT WINAPI
DSPROPERTY_EnumerateA(
1149 REFGUID guidPropSet
,
1152 PULONG pcbReturned
)
1154 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA
) pPropData
;
1156 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1157 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
1159 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1161 if (ppd
->Callback
) {
1162 unsigned devs
, wod
, wid
;
1164 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data
;
1166 devs
= waveOutGetNumDevs();
1167 for (wod
= 0; wod
< devs
; ++wod
) {
1168 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1171 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1173 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1175 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1177 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1180 ZeroMemory(&data
, sizeof(data
));
1181 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
1182 data
.WaveDeviceId
= wod
;
1183 data
.DeviceId
= DSOUND_renderer_guids
[wod
];
1184 data
.Description
= desc
.szDesc
;
1185 data
.Module
= desc
.szDrvname
;
1186 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1187 data
.Interface
= szInterface
;
1189 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1190 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1191 if (err
== DS_OK
&& drv
)
1192 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1194 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1196 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1197 (ppd
->Callback
)(&data
, ppd
->Context
);
1199 HeapFree(GetProcessHeap(),0,szInterface
);
1202 HeapFree(GetProcessHeap(),0,nameW
);
1207 devs
= waveInGetNumDevs();
1208 for (wid
= 0; wid
< devs
; ++wid
) {
1209 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
1212 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACESIZE
,(DWORD_PTR
)&size
,0));
1214 WCHAR
* nameW
= HeapAlloc(GetProcessHeap(),0,size
);
1216 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDEVICEINTERFACE
,(DWORD_PTR
)nameW
,size
));
1218 CHAR
* szInterface
= HeapAlloc(GetProcessHeap(),0,size
/sizeof(WCHAR
));
1221 ZeroMemory(&data
, sizeof(data
));
1222 data
.DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
1223 data
.WaveDeviceId
= wid
;
1224 data
.DeviceId
= DSOUND_capture_guids
[wid
];
1225 data
.Description
= desc
.szDesc
;
1226 data
.Module
= desc
.szDrvname
;
1227 WideCharToMultiByte( CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), szInterface
, size
/sizeof(WCHAR
), NULL
, NULL
);
1228 data
.Interface
= szInterface
;
1230 data
.Type
= DIRECTSOUNDDEVICE_TYPE_EMULATED
;
1231 err
= mmErr(waveInMessage((HWAVEIN
)wid
, DRV_QUERYDSOUNDIFACE
, (DWORD_PTR
)&drv
, 0));
1232 if (err
== DS_OK
&& drv
)
1233 data
.Type
= DIRECTSOUNDDEVICE_TYPE_VXD
;
1235 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1237 TRACE("calling Callback(%p,%p)\n", &data
, ppd
->Context
);
1238 (ppd
->Callback
)(&data
, ppd
->Context
);
1240 HeapFree(GetProcessHeap(),0,szInterface
);
1243 HeapFree(GetProcessHeap(),0,nameW
);
1252 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1257 FIXME("*pcbReturned=%ld\n", *pcbReturned
);
1260 return E_PROP_ID_UNSUPPORTED
;
1263 static HRESULT WINAPI
DSPROPERTY_EnumerateW(
1264 REFGUID guidPropSet
,
1267 PULONG pcbReturned
)
1269 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd
= (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA
) pPropData
;
1271 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1272 debugstr_guid(guidPropSet
),pPropData
,cbPropData
,pcbReturned
);
1274 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
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
);
1376 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1381 FIXME("*pcbReturned=%ld\n", *pcbReturned
);
1384 return E_PROP_ID_UNSUPPORTED
;
1387 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Get(
1388 LPKSPROPERTYSET iface
,
1389 REFGUID guidPropSet
,
1391 LPVOID pInstanceData
,
1392 ULONG cbInstanceData
,
1395 PULONG pcbReturned
)
1397 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1398 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1399 This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
,pcbReturned
);
1401 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1403 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1404 return DSPROPERTY_WaveDeviceMappingA(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1405 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1406 return DSPROPERTY_Description1(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1407 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1408 return DSPROPERTY_Enumerate1(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1409 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1410 return DSPROPERTY_WaveDeviceMappingW(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1411 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1412 return DSPROPERTY_DescriptionA(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1413 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1414 return DSPROPERTY_DescriptionW(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1415 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1416 return DSPROPERTY_EnumerateA(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1417 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1418 return DSPROPERTY_EnumerateW(guidPropSet
,pPropData
,cbPropData
,pcbReturned
);
1420 FIXME("unsupported ID: %ld\n",dwPropID
);
1424 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1429 FIXME("*pcbReturned=%ld\n", *pcbReturned
);
1432 return E_PROP_ID_UNSUPPORTED
;
1435 static HRESULT WINAPI
IKsPrivatePropertySetImpl_Set(
1436 LPKSPROPERTYSET iface
,
1437 REFGUID guidPropSet
,
1439 LPVOID pInstanceData
,
1440 ULONG cbInstanceData
,
1444 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1446 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
1447 return E_PROP_ID_UNSUPPORTED
;
1450 static HRESULT WINAPI
IKsPrivatePropertySetImpl_QuerySupport(
1451 LPKSPROPERTYSET iface
,
1452 REFGUID guidPropSet
,
1454 PULONG pTypeSupport
)
1456 IKsPrivatePropertySetImpl
*This
= (IKsPrivatePropertySetImpl
*)iface
;
1457 TRACE("(%p,%s,%ld,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
1459 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice
, guidPropSet
) ) {
1461 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A
:
1462 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1464 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
:
1465 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1467 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1
:
1468 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1470 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W
:
1471 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1473 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
:
1474 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1476 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
:
1477 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1479 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A
:
1480 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1482 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W
:
1483 *pTypeSupport
= KSPROPERTY_SUPPORT_GET
;
1486 FIXME("unsupported ID: %ld\n",dwPropID
);
1490 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet
));
1493 return E_PROP_ID_UNSUPPORTED
;
1496 static const IKsPropertySetVtbl ikspvt
= {
1497 IKsPrivatePropertySetImpl_QueryInterface
,
1498 IKsPrivatePropertySetImpl_AddRef
,
1499 IKsPrivatePropertySetImpl_Release
,
1500 IKsPrivatePropertySetImpl_Get
,
1501 IKsPrivatePropertySetImpl_Set
,
1502 IKsPrivatePropertySetImpl_QuerySupport
1505 HRESULT WINAPI
IKsPrivatePropertySetImpl_Create(
1506 IKsPrivatePropertySetImpl
**piks
)
1508 IKsPrivatePropertySetImpl
*iks
;
1510 iks
= HeapAlloc(GetProcessHeap(),0,sizeof(*iks
));
1512 iks
->lpVtbl
= &ikspvt
;