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
33 #include "wine/debug.h"
36 #include "dsound_private.h"
40 #ifdef NONAMELESSSTRUCT
46 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
49 /*******************************************************************************
50 * IKsBufferPropertySet
53 /* IUnknown methods */
54 static HRESULT WINAPI IKsBufferPropertySetImpl_QueryInterface(
55 LPKSPROPERTYSET iface,
59 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
60 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
62 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb, riid, ppobj);
65 static ULONG WINAPI IKsBufferPropertySetImpl_AddRef(LPKSPROPERTYSET iface)
67 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
68 ULONG ref = InterlockedIncrement(&(This->ref));
69 TRACE("(%p) ref was %ld\n", This, ref - 1);
73 static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
75 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
76 ULONG ref = InterlockedDecrement(&(This->ref));
77 TRACE("(%p) ref was %ld\n", This, ref + 1);
81 IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER)This->dsb);
82 HeapFree(GetProcessHeap(), 0, This);
83 TRACE("(%p) released\n", This);
88 static HRESULT WINAPI IKsBufferPropertySetImpl_Get(
89 LPKSPROPERTYSET iface,
98 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
99 PIDSDRIVERPROPERTYSET ps;
100 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
101 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
103 if (This->dsb->hwbuf) {
104 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
110 S(prop).Set = *guidPropSet;
111 S(prop).Id = dwPropID;
112 S(prop).Flags = 0; /* unused */
113 S(prop).InstanceId = (ULONG)This->dsb->device;
115 hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
117 IDsDriverPropertySet_Release(ps);
123 return E_PROP_ID_UNSUPPORTED;
126 static HRESULT WINAPI IKsBufferPropertySetImpl_Set(
127 LPKSPROPERTYSET iface,
130 LPVOID pInstanceData,
131 ULONG cbInstanceData,
135 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
136 PIDSDRIVERPROPERTYSET ps;
137 TRACE("(%p,%s,%ld,%p,%ld,%p,%ld)\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
139 if (This->dsb->hwbuf) {
140 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
146 S(prop).Set = *guidPropSet;
147 S(prop).Id = dwPropID;
148 S(prop).Flags = 0; /* unused */
149 S(prop).InstanceId = (ULONG)This->dsb->device;
150 hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData);
152 IDsDriverPropertySet_Release(ps);
158 return E_PROP_ID_UNSUPPORTED;
161 static HRESULT WINAPI IKsBufferPropertySetImpl_QuerySupport(
162 LPKSPROPERTYSET iface,
165 PULONG pTypeSupport )
167 IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
168 PIDSDRIVERPROPERTYSET ps;
169 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
171 if (This->dsb->hwbuf) {
172 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
177 hres = IDsDriverPropertySet_QuerySupport(ps,guidPropSet, dwPropID,pTypeSupport);
179 IDsDriverPropertySet_Release(ps);
185 return E_PROP_ID_UNSUPPORTED;
188 static const IKsPropertySetVtbl iksbvt = {
189 IKsBufferPropertySetImpl_QueryInterface,
190 IKsBufferPropertySetImpl_AddRef,
191 IKsBufferPropertySetImpl_Release,
192 IKsBufferPropertySetImpl_Get,
193 IKsBufferPropertySetImpl_Set,
194 IKsBufferPropertySetImpl_QuerySupport
197 HRESULT IKsBufferPropertySetImpl_Create(
198 IDirectSoundBufferImpl *dsb,
199 IKsBufferPropertySetImpl **piks)
201 IKsBufferPropertySetImpl *iks;
202 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);
246 return DSERR_INVALIDPARAM;
249 static ULONG WINAPI IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface)
251 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
252 ULONG ref = InterlockedIncrement(&(This->ref));
253 TRACE("(%p) ref was %ld\n", This, ref - 1);
257 static ULONG WINAPI IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface)
259 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
260 ULONG ref = InterlockedDecrement(&(This->ref));
261 TRACE("(%p) ref was %ld\n", This, ref + 1);
264 HeapFree(GetProcessHeap(), 0, This);
265 TRACE("(%p) released\n", This);
270 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingA(
276 HRESULT hr = DSERR_INVALIDPARAM;
277 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd;
278 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) not implemented!\n",
279 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
281 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA) pPropData;
284 WARN("invalid parameter: pPropData\n");
285 return DSERR_INVALIDPARAM;
288 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
291 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
292 wodn = waveOutGetNumDevs();
293 for (wod = 0; wod < wodn; wod++) {
296 res = waveOutGetDevCapsA(wod, &capsA, sizeof(capsA));
297 if (res == MMSYSERR_NOERROR) {
298 if (lstrcmpA(capsA.szPname, ppd->DeviceName) == 0) {
299 ppd->DeviceId = DSOUND_renderer_guids[wod];
301 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
307 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
310 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
311 widn = waveInGetNumDevs();
312 for (wid = 0; wid < widn; wid++) {
315 res = waveInGetDevCapsA(wid, &capsA, sizeof(capsA));
316 if (res == MMSYSERR_NOERROR) {
317 if (lstrcmpA(capsA.szPname, ppd->DeviceName) == 0) {
318 ppd->DeviceId = DSOUND_capture_guids[wid];
319 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
329 *pcbReturned = cbPropData;
334 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingW(
340 HRESULT hr = DSERR_INVALIDPARAM;
341 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd;
342 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
343 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
345 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA) pPropData;
348 WARN("invalid parameter: pPropData\n");
349 return DSERR_INVALIDPARAM;
352 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
355 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
356 wodn = waveOutGetNumDevs();
357 for (wod = 0; wod < wodn; wod++) {
360 res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW));
361 if (res == MMSYSERR_NOERROR) {
362 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
363 ppd->DeviceId = DSOUND_renderer_guids[wod];
365 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
366 debugstr_w(ppd->DeviceName));
371 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
374 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
375 widn = waveInGetNumDevs();
376 for (wid = 0; wid < widn; wid++) {
379 res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW));
380 if (res == MMSYSERR_NOERROR) {
381 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
382 ppd->DeviceId = DSOUND_capture_guids[wid];
384 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
385 debugstr_w(ppd->DeviceName));
393 *pcbReturned = cbPropData;
398 static HRESULT WINAPI DSPROPERTY_Description1(
406 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd;
407 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
408 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
410 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA) pPropData;
413 WARN("invalid parameter: pPropData\n");
414 return DSERR_INVALIDPARAM;
417 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
418 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
419 /* default device of type specified by ppd->DataFlow */
420 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
421 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
422 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
423 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
425 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
427 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
428 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
429 return E_PROP_ID_UNSUPPORTED;
432 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
433 GetDeviceID(&ppd->DeviceId, &dev_guid);
435 if ( IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultPlayback) ||
436 IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultVoicePlayback) ) {
439 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
440 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
441 wodn = waveOutGetNumDevs();
442 for (wod = 0; wod < wodn; wod++) {
443 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
445 ppd->WaveDeviceId = wod;
447 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
449 PIDSDRIVER drv = NULL;
450 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
451 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
452 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
453 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
454 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
455 if (err == DS_OK && drv)
456 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
458 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
461 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
462 return E_PROP_ID_UNSUPPORTED;
466 } else if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
467 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
470 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
471 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
472 widn = waveInGetNumDevs();
473 for (wid = 0; wid < widn; wid++) {
474 if (IsEqualGUID( &dev_guid, &guid) ) {
476 ppd->WaveDeviceId = wid;
478 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
481 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
482 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
483 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
484 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
485 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
486 if (err == DS_OK && drv)
487 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
489 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
492 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
493 return E_PROP_ID_UNSUPPORTED;
501 /* given specific device so try the render devices first */
502 wodn = waveOutGetNumDevs();
503 for (wod = 0; wod < wodn; wod++) {
504 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
506 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
507 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
508 ppd->WaveDeviceId = wod;
510 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
512 PIDSDRIVER drv = NULL;
513 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
514 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
515 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
516 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
517 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
518 if (err == DS_OK && drv)
519 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
521 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
525 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
526 return E_PROP_ID_UNSUPPORTED;
531 if (found == FALSE) {
534 /* given specific device so try the capture devices next */
535 widn = waveInGetNumDevs();
536 for (wid = 0; wid < widn; wid++) {
537 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
539 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
540 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
541 ppd->WaveDeviceId = wid;
543 err = mmErr(waveInMessage((HWAVEIN)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
545 PIDSDRIVER drv = NULL;
546 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
547 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
548 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
549 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
550 err = mmErr(waveInMessage((HWAVEIN)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
551 if (err == DS_OK && drv)
552 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
554 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
558 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
559 return E_PROP_ID_UNSUPPORTED;
564 if (found == FALSE) {
565 WARN("device not found\n");
566 return E_PROP_ID_UNSUPPORTED;
572 *pcbReturned = cbPropData;
573 TRACE("*pcbReturned=%ld\n", *pcbReturned);
579 static HRESULT WINAPI DSPROPERTY_DescriptionA(
585 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA) pPropData;
588 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
589 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
591 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
592 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
593 /* default device of type specified by ppd->DataFlow */
594 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
595 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
596 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
597 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
599 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
601 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
602 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
603 return E_PROP_ID_UNSUPPORTED;
606 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
607 GetDeviceID(&ppd->DeviceId, &dev_guid);
609 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
610 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
613 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
614 TRACE("DSDEVID_DefaultPlayback\n");
616 TRACE("DSDEVID_DefaultVoicePlayback\n");
617 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
618 wodn = waveOutGetNumDevs();
619 for (wod = 0; wod < wodn; wod++) {
620 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
622 ppd->WaveDeviceId = wod;
623 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
625 PIDSDRIVER drv = NULL;
626 /* FIXME: this is a memory leak */
627 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
628 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
629 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
631 if (szDescription && szModule && szInterface) {
632 strcpy(szDescription, desc.szDesc);
633 strcpy(szModule, desc.szDrvname);
634 strcpy(szInterface, "Interface");
636 ppd->Description = szDescription;
637 ppd->Module = szModule;
638 ppd->Interface = szInterface;
639 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
640 if (err == DS_OK && drv)
641 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
643 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
647 HeapFree(GetProcessHeap(), 0, szDescription);
648 HeapFree(GetProcessHeap(), 0, szModule);
649 HeapFree(GetProcessHeap(), 0, szInterface);
650 return E_OUTOFMEMORY;
653 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
654 return E_PROP_ID_UNSUPPORTED;
658 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
659 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
662 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) )
663 TRACE("DSDEVID_DefaultCapture\n");
665 TRACE("DSDEVID_DefaultVoiceCapture\n");
666 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
667 widn = waveInGetNumDevs();
668 for (wid = 0; wid < widn; wid++) {
669 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
671 ppd->WaveDeviceId = wid;
672 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
675 /* FIXME: this is a memory leak */
676 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
677 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
678 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
680 if (szDescription && szModule && szInterface) {
681 strcpy(szDescription, desc.szDesc);
682 strcpy(szModule, desc.szDrvname);
683 strcpy(szInterface, "Interface");
685 ppd->Description = szDescription;
686 ppd->Module = szModule;
687 ppd->Interface = szInterface;
688 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
689 if (err == DS_OK && drv)
690 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
692 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
696 HeapFree(GetProcessHeap(), 0, szDescription);
697 HeapFree(GetProcessHeap(), 0, szModule);
698 HeapFree(GetProcessHeap(), 0, szInterface);
699 return E_OUTOFMEMORY;
702 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
703 return E_PROP_ID_UNSUPPORTED;
711 /* given specific device so try the render devices first */
712 TRACE("Checking renderer devices\n");
713 wodn = waveOutGetNumDevs();
714 for (wod = 0; wod < wodn; wod++) {
715 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
717 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
718 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
719 ppd->WaveDeviceId = wod;
720 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
722 PIDSDRIVER drv = NULL;
723 /* FIXME: this is a memory leak */
724 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
725 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
726 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
728 if (szDescription && szModule && szInterface) {
729 strcpy(szDescription, desc.szDesc);
730 strcpy(szModule, desc.szDrvname);
731 strcpy(szInterface, "Interface");
733 ppd->Description = szDescription;
734 ppd->Module = szModule;
735 ppd->Interface = szInterface;
736 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
737 if (err == DS_OK && drv)
738 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
740 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
745 HeapFree(GetProcessHeap(), 0, szDescription);
746 HeapFree(GetProcessHeap(), 0, szModule);
747 HeapFree(GetProcessHeap(), 0, szInterface);
748 return E_OUTOFMEMORY;
751 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
752 return E_PROP_ID_UNSUPPORTED;
757 if (found == FALSE) {
760 TRACE("Checking capture devices\n");
761 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
762 widn = waveInGetNumDevs();
763 for (wid = 0; wid < widn; wid++) {
764 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
766 TRACE("DSOUND_capture_guids[%ld]\n", wid);
767 ppd->WaveDeviceId = wid;
768 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
771 /* FIXME: this is a memory leak */
772 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
773 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
774 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
776 if (szDescription && szModule && szInterface) {
777 strcpy(szDescription, desc.szDesc);
778 strcpy(szModule, desc.szDrvname);
779 strcpy(szInterface, "Interface");
781 ppd->Description = szDescription;
782 ppd->Module = szModule;
783 ppd->Interface = szInterface;
784 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
785 if (err == DS_OK && drv)
786 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
788 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
793 HeapFree(GetProcessHeap(), 0, szDescription);
794 HeapFree(GetProcessHeap(), 0, szModule);
795 HeapFree(GetProcessHeap(), 0, szInterface);
796 return E_OUTOFMEMORY;
799 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
800 return E_PROP_ID_UNSUPPORTED;
806 if (found == FALSE) {
807 WARN("device not found\n");
808 return E_PROP_ID_UNSUPPORTED;
813 *pcbReturned = cbPropData;
814 TRACE("*pcbReturned=%ld\n", *pcbReturned);
820 static HRESULT WINAPI DSPROPERTY_DescriptionW(
826 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA) pPropData;
829 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
830 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
832 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
833 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
834 /* default device of type specified by ppd->DataFlow */
835 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
836 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
837 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
838 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
840 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
842 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
843 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
844 return E_PROP_ID_UNSUPPORTED;
847 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
848 GetDeviceID(&ppd->DeviceId, &dev_guid);
850 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
851 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
854 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
855 TRACE("DSDEVID_DefaultPlayback\n");
857 TRACE("DSDEVID_DefaultVoicePlayback\n");
858 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
859 wodn = waveOutGetNumDevs();
860 for (wod = 0; wod < wodn; wod++) {
861 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
863 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
864 ppd->WaveDeviceId = wod;
865 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
867 PIDSDRIVER drv = NULL;
868 /* FIXME: this is a memory leak */
869 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
870 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
871 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
873 if (wDescription && wModule && wInterface) {
874 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
875 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
876 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
878 ppd->Description = wDescription;
879 ppd->Module = wModule;
880 ppd->Interface = wInterface;
881 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
882 if (err == DS_OK && drv)
883 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
885 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
889 HeapFree(GetProcessHeap(), 0, wDescription);
890 HeapFree(GetProcessHeap(), 0, wModule);
891 HeapFree(GetProcessHeap(), 0, wInterface);
892 return E_OUTOFMEMORY;
895 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
896 return E_PROP_ID_UNSUPPORTED;
900 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
901 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
904 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture))
905 TRACE("DSDEVID_DefaultCapture\n");
907 TRACE("DSDEVID_DefaultVoiceCapture\n");
908 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
909 widn = waveInGetNumDevs();
910 for (wid = 0; wid < widn; wid++) {
911 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
913 ppd->WaveDeviceId = wid;
914 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
917 /* FIXME: this is a memory leak */
918 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
919 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
920 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
922 if (wDescription && wModule && wInterface) {
923 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
924 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
925 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
927 ppd->Description = wDescription;
928 ppd->Module = wModule;
929 ppd->Interface = wInterface;
930 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
931 if (err == DS_OK && drv)
932 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
934 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
938 HeapFree(GetProcessHeap(), 0, wDescription);
939 HeapFree(GetProcessHeap(), 0, wModule);
940 HeapFree(GetProcessHeap(), 0, wInterface);
941 return E_OUTOFMEMORY;
944 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
945 return E_PROP_ID_UNSUPPORTED;
953 TRACE("Checking renderer devices\n");
954 /* given specific device so try the render devices first */
955 wodn = waveOutGetNumDevs();
956 for (wod = 0; wod < wodn; wod++) {
957 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
959 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
960 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
961 ppd->WaveDeviceId = wod;
962 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
964 PIDSDRIVER drv = NULL;
965 /* FIXME: this is a memory leak */
966 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
967 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
968 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
970 if (wDescription && wModule && wInterface) {
971 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
972 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
973 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
975 ppd->Description = wDescription;
976 ppd->Module = wModule;
977 ppd->Interface = wInterface;
978 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
979 if (err == DS_OK && drv)
980 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
982 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
987 HeapFree(GetProcessHeap(), 0, wDescription);
988 HeapFree(GetProcessHeap(), 0, wModule);
989 HeapFree(GetProcessHeap(), 0, wInterface);
990 return E_OUTOFMEMORY;
993 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
994 return E_PROP_ID_UNSUPPORTED;
999 if (found == FALSE) {
1002 TRACE("Checking capture devices\n");
1003 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1004 widn = waveInGetNumDevs();
1005 for (wid = 0; wid < widn; wid++) {
1006 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
1008 TRACE("DSOUND_capture_guids[%ld]\n", wid);
1009 ppd->WaveDeviceId = wid;
1010 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
1013 /* FIXME: this is a memory leak */
1014 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1015 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1016 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
1018 if (wDescription && wModule && wInterface) {
1019 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1020 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1021 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
1023 ppd->Description = wDescription;
1024 ppd->Module = wModule;
1025 ppd->Interface = wInterface;
1026 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
1027 if (err == DS_OK && drv)
1028 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1030 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1034 WARN("no memory\n");
1035 HeapFree(GetProcessHeap(), 0, wDescription);
1036 HeapFree(GetProcessHeap(), 0, wModule);
1037 HeapFree(GetProcessHeap(), 0, wInterface);
1038 return E_OUTOFMEMORY;
1041 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1042 return E_PROP_ID_UNSUPPORTED;
1048 if (found == FALSE) {
1049 WARN("device not found\n");
1050 return E_PROP_ID_UNSUPPORTED;
1055 *pcbReturned = cbPropData;
1056 TRACE("*pcbReturned=%ld\n", *pcbReturned);
1062 static HRESULT WINAPI DSPROPERTY_Enumerate1(
1063 REFGUID guidPropSet,
1066 PULONG pcbReturned )
1068 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA) pPropData;
1070 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1071 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1073 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1075 if (ppd->Callback) {
1076 unsigned devs, wod, wid;
1078 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data;
1080 devs = waveOutGetNumDevs();
1081 for (wod = 0; wod < devs; ++wod) {
1082 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1085 ZeroMemory(&data, sizeof(data));
1086 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1087 data.WaveDeviceId = wod;
1088 data.DeviceId = DSOUND_renderer_guids[wod];
1089 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1090 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1092 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1093 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1095 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1096 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1097 if (err == DS_OK && drv)
1098 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1100 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1102 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1103 (ppd->Callback)(&data, ppd->Context);
1107 devs = waveInGetNumDevs();
1108 for (wid = 0; wid < devs; ++wid) {
1109 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1112 ZeroMemory(&data, sizeof(data));
1113 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1114 data.WaveDeviceId = wid;
1115 data.DeviceId = DSOUND_capture_guids[wid];
1116 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1117 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1119 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1120 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1122 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1123 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1124 if (err == DS_OK && drv)
1125 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1127 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1129 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1130 (ppd->Callback)(&data, ppd->Context);
1138 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1143 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1146 return E_PROP_ID_UNSUPPORTED;
1149 static HRESULT WINAPI DSPROPERTY_EnumerateA(
1150 REFGUID guidPropSet,
1153 PULONG pcbReturned )
1155 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
1157 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1158 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1160 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1162 if (ppd->Callback) {
1163 unsigned devs, wod, wid;
1165 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
1167 devs = waveOutGetNumDevs();
1168 for (wod = 0; wod < devs; ++wod) {
1169 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1172 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1174 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1176 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1178 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1181 ZeroMemory(&data, sizeof(data));
1182 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1183 data.WaveDeviceId = wod;
1184 data.DeviceId = DSOUND_renderer_guids[wod];
1185 data.Description = desc.szDesc;
1186 data.Module = desc.szDrvname;
1187 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1188 data.Interface = szInterface;
1190 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1191 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1192 if (err == DS_OK && drv)
1193 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1195 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1197 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1198 (ppd->Callback)(&data, ppd->Context);
1200 HeapFree(GetProcessHeap(),0,szInterface);
1203 HeapFree(GetProcessHeap(),0,nameW);
1208 devs = waveInGetNumDevs();
1209 for (wid = 0; wid < devs; ++wid) {
1210 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1213 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1215 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1217 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1219 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1222 ZeroMemory(&data, sizeof(data));
1223 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1224 data.WaveDeviceId = wid;
1225 data.DeviceId = DSOUND_capture_guids[wid];
1226 data.Description = desc.szDesc;
1227 data.Module = desc.szDrvname;
1228 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1229 data.Interface = szInterface;
1231 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1232 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1233 if (err == DS_OK && drv)
1234 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1236 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1238 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1239 (ppd->Callback)(&data, ppd->Context);
1241 HeapFree(GetProcessHeap(),0,szInterface);
1244 HeapFree(GetProcessHeap(),0,nameW);
1253 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1258 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1261 return E_PROP_ID_UNSUPPORTED;
1264 static HRESULT WINAPI DSPROPERTY_EnumerateW(
1265 REFGUID guidPropSet,
1268 PULONG pcbReturned )
1270 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
1272 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1273 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1275 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1277 if (ppd->Callback) {
1278 unsigned devs, wod, wid;
1280 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
1282 devs = waveOutGetNumDevs();
1283 for (wod = 0; wod < devs; ++wod) {
1284 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1286 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1287 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1288 if (wDescription && wModule) {
1290 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1292 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1294 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1297 ZeroMemory(&data, sizeof(data));
1298 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1299 data.WaveDeviceId = wod;
1300 data.DeviceId = DSOUND_renderer_guids[wod];
1302 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1303 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1305 data.Description = wDescription;
1306 data.Module = wModule;
1307 data.Interface = wInterface;
1309 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1310 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1311 if (err == DS_OK && drv)
1312 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1314 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1316 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1317 (ppd->Callback)(&data, ppd->Context);
1320 HeapFree(GetProcessHeap(),0,wInterface);
1323 HeapFree(GetProcessHeap(),0,wDescription);
1324 HeapFree(GetProcessHeap(),0,wModule);
1328 devs = waveInGetNumDevs();
1329 for (wid = 0; wid < devs; ++wid) {
1330 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1332 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1333 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1334 if (wDescription && wModule) {
1336 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1338 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1340 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1343 ZeroMemory(&data, sizeof(data));
1344 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1345 data.WaveDeviceId = wid;
1346 data.DeviceId = DSOUND_capture_guids[wid];
1348 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1349 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1351 data.Description = wDescription;
1352 data.Module = wModule;
1353 data.Interface = wInterface;
1354 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1355 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1356 if (err == DS_OK && drv)
1357 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1359 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1361 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1362 (ppd->Callback)(&data, ppd->Context);
1365 HeapFree(GetProcessHeap(),0,wInterface);
1368 HeapFree(GetProcessHeap(),0,wDescription);
1369 HeapFree(GetProcessHeap(),0,wModule);
1377 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1382 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1385 return E_PROP_ID_UNSUPPORTED;
1388 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1389 LPKSPROPERTYSET iface,
1390 REFGUID guidPropSet,
1392 LPVOID pInstanceData,
1393 ULONG cbInstanceData,
1396 PULONG pcbReturned )
1398 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1399 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1400 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1402 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1404 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1405 return DSPROPERTY_WaveDeviceMappingA(guidPropSet,pPropData,cbPropData,pcbReturned);
1406 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1407 return DSPROPERTY_Description1(guidPropSet,pPropData,cbPropData,pcbReturned);
1408 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1409 return DSPROPERTY_Enumerate1(guidPropSet,pPropData,cbPropData,pcbReturned);
1410 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1411 return DSPROPERTY_WaveDeviceMappingW(guidPropSet,pPropData,cbPropData,pcbReturned);
1412 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1413 return DSPROPERTY_DescriptionA(guidPropSet,pPropData,cbPropData,pcbReturned);
1414 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1415 return DSPROPERTY_DescriptionW(guidPropSet,pPropData,cbPropData,pcbReturned);
1416 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1417 return DSPROPERTY_EnumerateA(guidPropSet,pPropData,cbPropData,pcbReturned);
1418 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1419 return DSPROPERTY_EnumerateW(guidPropSet,pPropData,cbPropData,pcbReturned);
1421 FIXME("unsupported ID: %ld\n",dwPropID);
1425 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1430 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1433 return E_PROP_ID_UNSUPPORTED;
1436 static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
1437 LPKSPROPERTYSET iface,
1438 REFGUID guidPropSet,
1440 LPVOID pInstanceData,
1441 ULONG cbInstanceData,
1445 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1447 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1448 return E_PROP_ID_UNSUPPORTED;
1451 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1452 LPKSPROPERTYSET iface,
1453 REFGUID guidPropSet,
1455 PULONG pTypeSupport )
1457 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1458 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1460 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1462 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1463 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1465 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1466 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1468 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1469 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1471 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1472 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1474 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1475 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1477 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1478 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1480 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1481 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1483 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1484 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1487 FIXME("unsupported ID: %ld\n",dwPropID);
1491 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1494 return E_PROP_ID_UNSUPPORTED;
1497 static const IKsPropertySetVtbl ikspvt = {
1498 IKsPrivatePropertySetImpl_QueryInterface,
1499 IKsPrivatePropertySetImpl_AddRef,
1500 IKsPrivatePropertySetImpl_Release,
1501 IKsPrivatePropertySetImpl_Get,
1502 IKsPrivatePropertySetImpl_Set,
1503 IKsPrivatePropertySetImpl_QuerySupport
1506 HRESULT IKsPrivatePropertySetImpl_Create(
1507 IKsPrivatePropertySetImpl **piks)
1509 IKsPrivatePropertySetImpl *iks;
1511 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1513 iks->lpVtbl = &ikspvt;