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"
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(
275 HRESULT hr = DSERR_INVALIDPARAM;
276 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd;
277 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
278 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(
338 HRESULT hr = DSERR_INVALIDPARAM;
339 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd;
340 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
341 pPropData,cbPropData,pcbReturned);
343 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA) pPropData;
346 WARN("invalid parameter: pPropData\n");
347 return DSERR_INVALIDPARAM;
350 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
353 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
354 wodn = waveOutGetNumDevs();
355 for (wod = 0; wod < wodn; wod++) {
358 res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW));
359 if (res == MMSYSERR_NOERROR) {
360 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
361 ppd->DeviceId = DSOUND_renderer_guids[wod];
363 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
364 debugstr_w(ppd->DeviceName));
369 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
372 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
373 widn = waveInGetNumDevs();
374 for (wid = 0; wid < widn; wid++) {
377 res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW));
378 if (res == MMSYSERR_NOERROR) {
379 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
380 ppd->DeviceId = DSOUND_capture_guids[wid];
382 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
383 debugstr_w(ppd->DeviceName));
391 *pcbReturned = cbPropData;
396 static HRESULT WINAPI DSPROPERTY_Description1(
403 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd;
404 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
405 pPropData,cbPropData,pcbReturned);
407 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA) pPropData;
410 WARN("invalid parameter: pPropData\n");
411 return DSERR_INVALIDPARAM;
414 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
415 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
416 /* default device of type specified by ppd->DataFlow */
417 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
418 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
419 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
420 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
422 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
424 FIXME("(pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
425 pPropData,cbPropData,pcbReturned);
426 return E_PROP_ID_UNSUPPORTED;
429 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
430 GetDeviceID(&ppd->DeviceId, &dev_guid);
432 if ( IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultPlayback) ||
433 IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultVoicePlayback) ) {
436 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
437 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
438 wodn = waveOutGetNumDevs();
439 for (wod = 0; wod < wodn; wod++) {
440 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
442 ppd->WaveDeviceId = wod;
444 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
446 PIDSDRIVER drv = NULL;
447 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
448 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
449 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
450 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
451 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
452 if (err == DS_OK && drv)
453 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
455 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
458 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
459 return E_PROP_ID_UNSUPPORTED;
463 } else if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
464 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
467 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
468 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
469 widn = waveInGetNumDevs();
470 for (wid = 0; wid < widn; wid++) {
471 if (IsEqualGUID( &dev_guid, &guid) ) {
473 ppd->WaveDeviceId = wid;
475 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
478 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
479 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
480 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
481 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
482 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
483 if (err == DS_OK && drv)
484 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
486 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
489 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
490 return E_PROP_ID_UNSUPPORTED;
498 /* given specific device so try the render devices first */
499 wodn = waveOutGetNumDevs();
500 for (wod = 0; wod < wodn; wod++) {
501 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
503 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
504 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
505 ppd->WaveDeviceId = wod;
507 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
509 PIDSDRIVER drv = NULL;
510 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
511 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
512 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
513 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
514 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
515 if (err == DS_OK && drv)
516 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
518 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
522 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
523 return E_PROP_ID_UNSUPPORTED;
528 if (found == FALSE) {
531 /* given specific device so try the capture devices next */
532 widn = waveInGetNumDevs();
533 for (wid = 0; wid < widn; wid++) {
534 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
536 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
537 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
538 ppd->WaveDeviceId = wid;
540 err = mmErr(waveInMessage((HWAVEIN)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
542 PIDSDRIVER drv = NULL;
543 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
544 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
545 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
546 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
547 err = mmErr(waveInMessage((HWAVEIN)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
548 if (err == DS_OK && drv)
549 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
551 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
555 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
556 return E_PROP_ID_UNSUPPORTED;
561 if (found == FALSE) {
562 WARN("device not found\n");
563 return E_PROP_ID_UNSUPPORTED;
569 *pcbReturned = cbPropData;
570 TRACE("*pcbReturned=%ld\n", *pcbReturned);
576 static HRESULT WINAPI DSPROPERTY_DescriptionA(
581 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA) pPropData;
584 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
585 pPropData,cbPropData,pcbReturned);
587 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
588 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
589 /* default device of type specified by ppd->DataFlow */
590 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
591 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
592 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
593 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
595 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
597 FIXME("(pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
598 pPropData,cbPropData,pcbReturned);
599 return E_PROP_ID_UNSUPPORTED;
602 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
603 GetDeviceID(&ppd->DeviceId, &dev_guid);
605 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
606 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
609 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
610 TRACE("DSDEVID_DefaultPlayback\n");
612 TRACE("DSDEVID_DefaultVoicePlayback\n");
613 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
614 wodn = waveOutGetNumDevs();
615 for (wod = 0; wod < wodn; wod++) {
616 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
618 ppd->WaveDeviceId = wod;
619 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
621 PIDSDRIVER drv = NULL;
622 /* FIXME: this is a memory leak */
623 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
624 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
625 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
627 if (szDescription && szModule && szInterface) {
628 strcpy(szDescription, desc.szDesc);
629 strcpy(szModule, desc.szDrvname);
630 strcpy(szInterface, "Interface");
632 ppd->Description = szDescription;
633 ppd->Module = szModule;
634 ppd->Interface = szInterface;
635 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
636 if (err == DS_OK && drv)
637 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
639 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
643 HeapFree(GetProcessHeap(), 0, szDescription);
644 HeapFree(GetProcessHeap(), 0, szModule);
645 HeapFree(GetProcessHeap(), 0, szInterface);
646 return E_OUTOFMEMORY;
649 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
650 return E_PROP_ID_UNSUPPORTED;
654 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
655 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
658 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) )
659 TRACE("DSDEVID_DefaultCapture\n");
661 TRACE("DSDEVID_DefaultVoiceCapture\n");
662 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
663 widn = waveInGetNumDevs();
664 for (wid = 0; wid < widn; wid++) {
665 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
667 ppd->WaveDeviceId = wid;
668 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
671 /* FIXME: this is a memory leak */
672 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
673 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
674 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
676 if (szDescription && szModule && szInterface) {
677 strcpy(szDescription, desc.szDesc);
678 strcpy(szModule, desc.szDrvname);
679 strcpy(szInterface, "Interface");
681 ppd->Description = szDescription;
682 ppd->Module = szModule;
683 ppd->Interface = szInterface;
684 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
685 if (err == DS_OK && drv)
686 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
688 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
692 HeapFree(GetProcessHeap(), 0, szDescription);
693 HeapFree(GetProcessHeap(), 0, szModule);
694 HeapFree(GetProcessHeap(), 0, szInterface);
695 return E_OUTOFMEMORY;
698 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
699 return E_PROP_ID_UNSUPPORTED;
707 /* given specific device so try the render devices first */
708 TRACE("Checking renderer devices\n");
709 wodn = waveOutGetNumDevs();
710 for (wod = 0; wod < wodn; wod++) {
711 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
713 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
714 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
715 ppd->WaveDeviceId = wod;
716 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
718 PIDSDRIVER drv = NULL;
719 /* FIXME: this is a memory leak */
720 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
721 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
722 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
724 if (szDescription && szModule && szInterface) {
725 strcpy(szDescription, desc.szDesc);
726 strcpy(szModule, desc.szDrvname);
727 strcpy(szInterface, "Interface");
729 ppd->Description = szDescription;
730 ppd->Module = szModule;
731 ppd->Interface = szInterface;
732 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
733 if (err == DS_OK && drv)
734 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
736 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
741 HeapFree(GetProcessHeap(), 0, szDescription);
742 HeapFree(GetProcessHeap(), 0, szModule);
743 HeapFree(GetProcessHeap(), 0, szInterface);
744 return E_OUTOFMEMORY;
747 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
748 return E_PROP_ID_UNSUPPORTED;
753 if (found == FALSE) {
756 TRACE("Checking capture devices\n");
757 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
758 widn = waveInGetNumDevs();
759 for (wid = 0; wid < widn; wid++) {
760 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
762 TRACE("DSOUND_capture_guids[%ld]\n", wid);
763 ppd->WaveDeviceId = wid;
764 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
767 /* FIXME: this is a memory leak */
768 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
769 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
770 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
772 if (szDescription && szModule && szInterface) {
773 strcpy(szDescription, desc.szDesc);
774 strcpy(szModule, desc.szDrvname);
775 strcpy(szInterface, "Interface");
777 ppd->Description = szDescription;
778 ppd->Module = szModule;
779 ppd->Interface = szInterface;
780 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
781 if (err == DS_OK && drv)
782 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
784 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
789 HeapFree(GetProcessHeap(), 0, szDescription);
790 HeapFree(GetProcessHeap(), 0, szModule);
791 HeapFree(GetProcessHeap(), 0, szInterface);
792 return E_OUTOFMEMORY;
795 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
796 return E_PROP_ID_UNSUPPORTED;
802 if (found == FALSE) {
803 WARN("device not found\n");
804 return E_PROP_ID_UNSUPPORTED;
809 *pcbReturned = cbPropData;
810 TRACE("*pcbReturned=%ld\n", *pcbReturned);
816 static HRESULT WINAPI DSPROPERTY_DescriptionW(
821 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA) pPropData;
824 TRACE("pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
825 pPropData,cbPropData,pcbReturned);
827 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
828 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
829 /* default device of type specified by ppd->DataFlow */
830 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
831 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
832 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
833 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
835 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
837 FIXME("(pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
838 pPropData,cbPropData,pcbReturned);
839 return E_PROP_ID_UNSUPPORTED;
842 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
843 GetDeviceID(&ppd->DeviceId, &dev_guid);
845 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
846 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
849 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
850 TRACE("DSDEVID_DefaultPlayback\n");
852 TRACE("DSDEVID_DefaultVoicePlayback\n");
853 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
854 wodn = waveOutGetNumDevs();
855 for (wod = 0; wod < wodn; wod++) {
856 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
858 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
859 ppd->WaveDeviceId = wod;
860 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
862 PIDSDRIVER drv = NULL;
863 /* FIXME: this is a memory leak */
864 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
865 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
866 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
868 if (wDescription && wModule && wInterface) {
869 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
870 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
871 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
873 ppd->Description = wDescription;
874 ppd->Module = wModule;
875 ppd->Interface = wInterface;
876 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
877 if (err == DS_OK && drv)
878 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
880 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
884 HeapFree(GetProcessHeap(), 0, wDescription);
885 HeapFree(GetProcessHeap(), 0, wModule);
886 HeapFree(GetProcessHeap(), 0, wInterface);
887 return E_OUTOFMEMORY;
890 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
891 return E_PROP_ID_UNSUPPORTED;
895 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
896 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
899 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture))
900 TRACE("DSDEVID_DefaultCapture\n");
902 TRACE("DSDEVID_DefaultVoiceCapture\n");
903 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
904 widn = waveInGetNumDevs();
905 for (wid = 0; wid < widn; wid++) {
906 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
908 ppd->WaveDeviceId = wid;
909 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
912 /* FIXME: this is a memory leak */
913 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
914 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
915 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
917 if (wDescription && wModule && wInterface) {
918 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
919 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
920 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
922 ppd->Description = wDescription;
923 ppd->Module = wModule;
924 ppd->Interface = wInterface;
925 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
926 if (err == DS_OK && drv)
927 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
929 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
933 HeapFree(GetProcessHeap(), 0, wDescription);
934 HeapFree(GetProcessHeap(), 0, wModule);
935 HeapFree(GetProcessHeap(), 0, wInterface);
936 return E_OUTOFMEMORY;
939 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
940 return E_PROP_ID_UNSUPPORTED;
948 TRACE("Checking renderer devices\n");
949 /* given specific device so try the render devices first */
950 wodn = waveOutGetNumDevs();
951 for (wod = 0; wod < wodn; wod++) {
952 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
954 TRACE("DSOUND_renderer_guids[%ld]\n", wod);
955 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
956 ppd->WaveDeviceId = wod;
957 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
959 PIDSDRIVER drv = NULL;
960 /* FIXME: this is a memory leak */
961 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
962 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
963 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
965 if (wDescription && wModule && wInterface) {
966 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
967 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
968 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
970 ppd->Description = wDescription;
971 ppd->Module = wModule;
972 ppd->Interface = wInterface;
973 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
974 if (err == DS_OK && drv)
975 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
977 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
982 HeapFree(GetProcessHeap(), 0, wDescription);
983 HeapFree(GetProcessHeap(), 0, wModule);
984 HeapFree(GetProcessHeap(), 0, wInterface);
985 return E_OUTOFMEMORY;
988 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
989 return E_PROP_ID_UNSUPPORTED;
994 if (found == FALSE) {
997 TRACE("Checking capture devices\n");
998 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
999 widn = waveInGetNumDevs();
1000 for (wid = 0; wid < widn; wid++) {
1001 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
1003 TRACE("DSOUND_capture_guids[%ld]\n", wid);
1004 ppd->WaveDeviceId = wid;
1005 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
1008 /* FIXME: this is a memory leak */
1009 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1010 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1011 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
1013 if (wDescription && wModule && wInterface) {
1014 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1015 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1016 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
1018 ppd->Description = wDescription;
1019 ppd->Module = wModule;
1020 ppd->Interface = wInterface;
1021 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
1022 if (err == DS_OK && drv)
1023 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1025 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1029 WARN("no memory\n");
1030 HeapFree(GetProcessHeap(), 0, wDescription);
1031 HeapFree(GetProcessHeap(), 0, wModule);
1032 HeapFree(GetProcessHeap(), 0, wInterface);
1033 return E_OUTOFMEMORY;
1036 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1037 return E_PROP_ID_UNSUPPORTED;
1043 if (found == FALSE) {
1044 WARN("device not found\n");
1045 return E_PROP_ID_UNSUPPORTED;
1050 *pcbReturned = cbPropData;
1051 TRACE("*pcbReturned=%ld\n", *pcbReturned);
1057 static HRESULT WINAPI DSPROPERTY_Enumerate1(
1060 PULONG pcbReturned )
1062 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA) pPropData;
1064 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1065 pPropData,cbPropData,pcbReturned);
1068 if (ppd->Callback) {
1069 unsigned devs, wod, wid;
1071 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data;
1073 devs = waveOutGetNumDevs();
1074 for (wod = 0; wod < devs; ++wod) {
1075 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1078 ZeroMemory(&data, sizeof(data));
1079 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1080 data.WaveDeviceId = wod;
1081 data.DeviceId = DSOUND_renderer_guids[wod];
1082 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1083 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1085 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1086 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1088 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1089 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1090 if (err == DS_OK && drv)
1091 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1093 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1095 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1096 (ppd->Callback)(&data, ppd->Context);
1100 devs = waveInGetNumDevs();
1101 for (wid = 0; wid < devs; ++wid) {
1102 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1105 ZeroMemory(&data, sizeof(data));
1106 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1107 data.WaveDeviceId = wid;
1108 data.DeviceId = DSOUND_capture_guids[wid];
1109 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1110 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1112 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1113 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1115 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1116 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1117 if (err == DS_OK && drv)
1118 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1120 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1122 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1123 (ppd->Callback)(&data, ppd->Context);
1133 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1136 return E_PROP_ID_UNSUPPORTED;
1139 static HRESULT WINAPI DSPROPERTY_EnumerateA(
1142 PULONG pcbReturned )
1144 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
1146 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1147 pPropData,cbPropData,pcbReturned);
1150 if (ppd->Callback) {
1151 unsigned devs, wod, wid;
1153 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
1155 devs = waveOutGetNumDevs();
1156 for (wod = 0; wod < devs; ++wod) {
1157 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1160 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1162 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1164 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1166 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1169 ZeroMemory(&data, sizeof(data));
1170 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1171 data.WaveDeviceId = wod;
1172 data.DeviceId = DSOUND_renderer_guids[wod];
1173 data.Description = desc.szDesc;
1174 data.Module = desc.szDrvname;
1175 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1176 data.Interface = szInterface;
1178 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1179 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1180 if (err == DS_OK && drv)
1181 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1183 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1185 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1186 (ppd->Callback)(&data, ppd->Context);
1188 HeapFree(GetProcessHeap(),0,szInterface);
1191 HeapFree(GetProcessHeap(),0,nameW);
1196 devs = waveInGetNumDevs();
1197 for (wid = 0; wid < devs; ++wid) {
1198 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1201 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1203 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1205 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1207 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1210 ZeroMemory(&data, sizeof(data));
1211 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1212 data.WaveDeviceId = wid;
1213 data.DeviceId = DSOUND_capture_guids[wid];
1214 data.Description = desc.szDesc;
1215 data.Module = desc.szDrvname;
1216 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1217 data.Interface = szInterface;
1219 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1220 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1221 if (err == DS_OK && drv)
1222 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1224 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1226 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1227 (ppd->Callback)(&data, ppd->Context);
1229 HeapFree(GetProcessHeap(),0,szInterface);
1232 HeapFree(GetProcessHeap(),0,nameW);
1243 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1246 return E_PROP_ID_UNSUPPORTED;
1249 static HRESULT WINAPI DSPROPERTY_EnumerateW(
1252 PULONG pcbReturned )
1254 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
1256 TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1257 pPropData,cbPropData,pcbReturned);
1260 if (ppd->Callback) {
1261 unsigned devs, wod, wid;
1263 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
1265 devs = waveOutGetNumDevs();
1266 for (wod = 0; wod < devs; ++wod) {
1267 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1269 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1270 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1271 if (wDescription && wModule) {
1273 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1275 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1277 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1280 ZeroMemory(&data, sizeof(data));
1281 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1282 data.WaveDeviceId = wod;
1283 data.DeviceId = DSOUND_renderer_guids[wod];
1285 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1286 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1288 data.Description = wDescription;
1289 data.Module = wModule;
1290 data.Interface = wInterface;
1292 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1293 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1294 if (err == DS_OK && drv)
1295 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1297 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1299 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1300 (ppd->Callback)(&data, ppd->Context);
1303 HeapFree(GetProcessHeap(),0,wInterface);
1306 HeapFree(GetProcessHeap(),0,wDescription);
1307 HeapFree(GetProcessHeap(),0,wModule);
1311 devs = waveInGetNumDevs();
1312 for (wid = 0; wid < devs; ++wid) {
1313 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1315 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1316 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1317 if (wDescription && wModule) {
1319 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1321 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1323 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1326 ZeroMemory(&data, sizeof(data));
1327 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1328 data.WaveDeviceId = wid;
1329 data.DeviceId = DSOUND_capture_guids[wid];
1331 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1332 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1334 data.Description = wDescription;
1335 data.Module = wModule;
1336 data.Interface = wInterface;
1337 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1338 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1339 if (err == DS_OK && drv)
1340 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1342 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1344 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1345 (ppd->Callback)(&data, ppd->Context);
1348 HeapFree(GetProcessHeap(),0,wInterface);
1351 HeapFree(GetProcessHeap(),0,wDescription);
1352 HeapFree(GetProcessHeap(),0,wModule);
1362 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1365 return E_PROP_ID_UNSUPPORTED;
1368 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1369 LPKSPROPERTYSET iface,
1370 REFGUID guidPropSet,
1372 LPVOID pInstanceData,
1373 ULONG cbInstanceData,
1376 PULONG pcbReturned )
1378 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1379 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1380 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1382 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1384 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1385 return DSPROPERTY_WaveDeviceMappingA(pPropData,cbPropData,pcbReturned);
1386 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1387 return DSPROPERTY_Description1(pPropData,cbPropData,pcbReturned);
1388 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1389 return DSPROPERTY_Enumerate1(pPropData,cbPropData,pcbReturned);
1390 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1391 return DSPROPERTY_WaveDeviceMappingW(pPropData,cbPropData,pcbReturned);
1392 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1393 return DSPROPERTY_DescriptionA(pPropData,cbPropData,pcbReturned);
1394 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1395 return DSPROPERTY_DescriptionW(pPropData,cbPropData,pcbReturned);
1396 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1397 return DSPROPERTY_EnumerateA(pPropData,cbPropData,pcbReturned);
1398 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1399 return DSPROPERTY_EnumerateW(pPropData,cbPropData,pcbReturned);
1401 FIXME("unsupported ID: %ld\n",dwPropID);
1405 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1410 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1413 return E_PROP_ID_UNSUPPORTED;
1416 static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
1417 LPKSPROPERTYSET iface,
1418 REFGUID guidPropSet,
1420 LPVOID pInstanceData,
1421 ULONG cbInstanceData,
1425 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1427 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1428 return E_PROP_ID_UNSUPPORTED;
1431 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1432 LPKSPROPERTYSET iface,
1433 REFGUID guidPropSet,
1435 PULONG pTypeSupport )
1437 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1438 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1440 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1442 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1443 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1445 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1446 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1448 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1449 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1451 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1452 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1454 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1455 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1457 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1458 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1460 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1461 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1463 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1464 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1467 FIXME("unsupported ID: %ld\n",dwPropID);
1471 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1474 return E_PROP_ID_UNSUPPORTED;
1477 static const IKsPropertySetVtbl ikspvt = {
1478 IKsPrivatePropertySetImpl_QueryInterface,
1479 IKsPrivatePropertySetImpl_AddRef,
1480 IKsPrivatePropertySetImpl_Release,
1481 IKsPrivatePropertySetImpl_Get,
1482 IKsPrivatePropertySetImpl_Set,
1483 IKsPrivatePropertySetImpl_QuerySupport
1486 HRESULT IKsPrivatePropertySetImpl_Create(
1488 IKsPrivatePropertySetImpl **piks)
1490 IKsPrivatePropertySetImpl *iks;
1491 TRACE("(%s, %p)\n", debugstr_guid(riid), piks);
1493 if (!IsEqualIID(riid, &IID_IUnknown) &&
1494 !IsEqualIID(riid, &IID_IKsPropertySet)) {
1496 return E_NOINTERFACE;
1499 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1501 iks->lpVtbl = &ikspvt;