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 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)&(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)&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)&(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)&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)&(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)&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)&(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)&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 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\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)&(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)&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 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
659 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
660 widn = waveInGetNumDevs();
661 for (wid = 0; wid < widn; wid++) {
662 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
664 ppd->WaveDeviceId = wid;
665 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
668 /* FIXME: this is a memory leak */
669 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
670 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
671 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
673 if (szDescription && szModule && szInterface) {
674 strcpy(szDescription, desc.szDesc);
675 strcpy(szModule, desc.szDrvname);
676 strcpy(szInterface, "Interface");
678 ppd->Description = szDescription;
679 ppd->Module = szModule;
680 ppd->Interface = szInterface;
681 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
682 if (err == DS_OK && drv)
683 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
685 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
689 HeapFree(GetProcessHeap(), 0, szDescription);
690 HeapFree(GetProcessHeap(), 0, szModule);
691 HeapFree(GetProcessHeap(), 0, szInterface);
692 return E_OUTOFMEMORY;
695 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
696 return E_PROP_ID_UNSUPPORTED;
704 /* given specific device so try the render devices first */
705 wodn = waveOutGetNumDevs();
706 for (wod = 0; wod < wodn; wod++) {
707 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
709 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
710 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
711 ppd->WaveDeviceId = wod;
712 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
714 PIDSDRIVER drv = NULL;
715 /* FIXME: this is a memory leak */
716 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
717 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
718 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
720 if (szDescription && szModule && szInterface) {
721 strcpy(szDescription, desc.szDesc);
722 strcpy(szModule, desc.szDrvname);
723 strcpy(szInterface, "Interface");
725 ppd->Description = szDescription;
726 ppd->Module = szModule;
727 ppd->Interface = szInterface;
728 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
729 if (err == DS_OK && drv)
730 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
732 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
737 HeapFree(GetProcessHeap(), 0, szDescription);
738 HeapFree(GetProcessHeap(), 0, szModule);
739 HeapFree(GetProcessHeap(), 0, szInterface);
740 return E_OUTOFMEMORY;
743 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
744 return E_PROP_ID_UNSUPPORTED;
749 if (found == FALSE) {
752 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
753 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
754 widn = waveInGetNumDevs();
755 for (wid = 0; wid < widn; wid++) {
756 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wod] ) ) {
758 ppd->WaveDeviceId = wid;
759 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
762 /* FIXME: this is a memory leak */
763 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
764 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
765 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
767 if (szDescription && szModule && szInterface) {
768 strcpy(szDescription, desc.szDesc);
769 strcpy(szModule, desc.szDrvname);
770 strcpy(szInterface, "Interface");
772 ppd->Description = szDescription;
773 ppd->Module = szModule;
774 ppd->Interface = szInterface;
775 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
776 if (err == DS_OK && drv)
777 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
779 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
784 HeapFree(GetProcessHeap(), 0, szDescription);
785 HeapFree(GetProcessHeap(), 0, szModule);
786 HeapFree(GetProcessHeap(), 0, szInterface);
787 return E_OUTOFMEMORY;
790 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
791 return E_PROP_ID_UNSUPPORTED;
797 if (found == FALSE) {
798 WARN("device not found\n");
799 return E_PROP_ID_UNSUPPORTED;
804 *pcbReturned = cbPropData;
805 TRACE("*pcbReturned=%ld\n", *pcbReturned);
811 static HRESULT WINAPI DSPROPERTY_DescriptionW(
817 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA) pPropData;
820 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
821 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
823 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
824 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
825 /* default device of type specified by ppd->DataFlow */
826 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
827 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
828 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
829 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
831 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
833 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
834 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
835 return E_PROP_ID_UNSUPPORTED;
838 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
839 GetDeviceID(&ppd->DeviceId, &dev_guid);
841 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
842 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
845 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
846 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
847 wodn = waveOutGetNumDevs();
848 for (wod = 0; wod < wodn; wod++) {
849 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
851 ppd->WaveDeviceId = wod;
852 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
854 PIDSDRIVER drv = NULL;
855 /* FIXME: this is a memory leak */
856 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
857 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
858 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
860 if (wDescription && wModule && wInterface) {
861 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
862 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
863 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
865 ppd->Description = wDescription;
866 ppd->Module = wModule;
867 ppd->Interface = wInterface;
868 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
869 if (err == DS_OK && drv)
870 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
872 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
876 HeapFree(GetProcessHeap(), 0, wDescription);
877 HeapFree(GetProcessHeap(), 0, wModule);
878 HeapFree(GetProcessHeap(), 0, wInterface);
879 return E_OUTOFMEMORY;
882 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
883 return E_PROP_ID_UNSUPPORTED;
887 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
888 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
891 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
892 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
893 widn = waveInGetNumDevs();
894 for (wid = 0; wid < widn; wid++) {
895 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
897 ppd->WaveDeviceId = wid;
898 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
901 /* FIXME: this is a memory leak */
902 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
903 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
904 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
906 if (wDescription && wModule && wInterface) {
907 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
908 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
909 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
911 ppd->Description = wDescription;
912 ppd->Module = wModule;
913 ppd->Interface = wInterface;
914 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
915 if (err == DS_OK && drv)
916 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
918 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
922 HeapFree(GetProcessHeap(), 0, wDescription);
923 HeapFree(GetProcessHeap(), 0, wModule);
924 HeapFree(GetProcessHeap(), 0, wInterface);
925 return E_OUTOFMEMORY;
928 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
929 return E_PROP_ID_UNSUPPORTED;
937 /* given specific device so try the render devices first */
938 wodn = waveOutGetNumDevs();
939 for (wod = 0; wod < wodn; wod++) {
940 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
942 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
943 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
944 ppd->WaveDeviceId = wod;
945 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
947 PIDSDRIVER drv = NULL;
948 /* FIXME: this is a memory leak */
949 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
950 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
951 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
953 if (wDescription && wModule && wInterface) {
954 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
955 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
956 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
958 ppd->Description = wDescription;
959 ppd->Module = wModule;
960 ppd->Interface = wInterface;
961 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
962 if (err == DS_OK && drv)
963 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
965 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
970 HeapFree(GetProcessHeap(), 0, wDescription);
971 HeapFree(GetProcessHeap(), 0, wModule);
972 HeapFree(GetProcessHeap(), 0, wInterface);
973 return E_OUTOFMEMORY;
976 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
977 return E_PROP_ID_UNSUPPORTED;
982 if (found == FALSE) {
985 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
986 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
987 widn = waveInGetNumDevs();
988 for (wid = 0; wid < widn; wid++) {
989 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
991 ppd->WaveDeviceId = wid;
992 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
995 /* FIXME: this is a memory leak */
996 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
997 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
998 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
1000 if (wDescription && wModule && wInterface) {
1001 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1002 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1003 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
1005 ppd->Description = wDescription;
1006 ppd->Module = wModule;
1007 ppd->Interface = wInterface;
1008 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
1009 if (err == DS_OK && drv)
1010 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1012 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1016 WARN("no memory\n");
1017 HeapFree(GetProcessHeap(), 0, wDescription);
1018 HeapFree(GetProcessHeap(), 0, wModule);
1019 HeapFree(GetProcessHeap(), 0, wInterface);
1020 return E_OUTOFMEMORY;
1023 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1024 return E_PROP_ID_UNSUPPORTED;
1030 if (found == FALSE) {
1031 WARN("device not found\n");
1032 return E_PROP_ID_UNSUPPORTED;
1037 *pcbReturned = cbPropData;
1038 TRACE("*pcbReturned=%ld\n", *pcbReturned);
1044 static HRESULT WINAPI DSPROPERTY_Enumerate1(
1045 REFGUID guidPropSet,
1048 PULONG pcbReturned )
1050 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA) pPropData;
1052 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1053 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1055 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1057 if (ppd->Callback) {
1058 unsigned devs, wod, wid;
1060 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data;
1062 devs = waveOutGetNumDevs();
1063 for (wod = 0; wod < devs; ++wod) {
1064 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1067 ZeroMemory(&data, sizeof(data));
1068 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1069 data.WaveDeviceId = wod;
1070 data.DeviceId = DSOUND_renderer_guids[wod];
1071 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1072 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1074 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
1075 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
1077 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1078 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1079 if (err == DS_OK && drv)
1080 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1082 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1084 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1085 (ppd->Callback)(&data, ppd->Context);
1089 devs = waveInGetNumDevs();
1090 for (wid = 0; wid < devs; ++wid) {
1091 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1094 ZeroMemory(&data, sizeof(data));
1095 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1096 data.WaveDeviceId = wid;
1097 data.DeviceId = DSOUND_capture_guids[wid];
1098 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1099 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1101 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
1102 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
1104 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1105 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1106 if (err == DS_OK && drv)
1107 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1109 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1111 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1112 (ppd->Callback)(&data, ppd->Context);
1120 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1125 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1128 return E_PROP_ID_UNSUPPORTED;
1131 static HRESULT WINAPI DSPROPERTY_EnumerateA(
1132 REFGUID guidPropSet,
1135 PULONG pcbReturned )
1137 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
1139 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1140 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1142 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1144 if (ppd->Callback) {
1145 unsigned devs, wod, wid;
1147 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
1149 devs = waveOutGetNumDevs();
1150 for (wod = 0; wod < devs; ++wod) {
1151 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1154 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1156 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1158 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1160 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1163 ZeroMemory(&data, sizeof(data));
1164 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1165 data.WaveDeviceId = wod;
1166 data.DeviceId = DSOUND_renderer_guids[wod];
1167 data.Description = desc.szDesc;
1168 data.Module = desc.szDrvname;
1169 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1170 data.Interface = szInterface;
1172 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1173 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1174 if (err == DS_OK && drv)
1175 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1177 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1179 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1180 (ppd->Callback)(&data, ppd->Context);
1182 HeapFree(GetProcessHeap(),0,szInterface);
1185 HeapFree(GetProcessHeap(),0,nameW);
1190 devs = waveInGetNumDevs();
1191 for (wid = 0; wid < devs; ++wid) {
1192 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1195 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1197 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1199 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1201 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1204 ZeroMemory(&data, sizeof(data));
1205 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1206 data.WaveDeviceId = wid;
1207 data.DeviceId = DSOUND_capture_guids[wid];
1208 data.Description = desc.szDesc;
1209 data.Module = desc.szDrvname;
1210 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1211 data.Interface = szInterface;
1213 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1214 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1215 if (err == DS_OK && drv)
1216 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1218 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1220 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1221 (ppd->Callback)(&data, ppd->Context);
1223 HeapFree(GetProcessHeap(),0,szInterface);
1226 HeapFree(GetProcessHeap(),0,nameW);
1235 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1240 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1243 return E_PROP_ID_UNSUPPORTED;
1246 static HRESULT WINAPI DSPROPERTY_EnumerateW(
1247 REFGUID guidPropSet,
1250 PULONG pcbReturned )
1252 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
1254 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1255 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1257 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1259 if (ppd->Callback) {
1260 unsigned devs, wod, wid;
1262 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
1264 devs = waveOutGetNumDevs();
1265 for (wod = 0; wod < devs; ++wod) {
1266 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1268 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1269 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1270 if (wDescription && wModule) {
1272 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1274 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1276 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1279 ZeroMemory(&data, sizeof(data));
1280 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1281 data.WaveDeviceId = wod;
1282 data.DeviceId = DSOUND_renderer_guids[wod];
1284 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1285 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1287 data.Description = wDescription;
1288 data.Module = wModule;
1289 data.Interface = wInterface;
1291 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1292 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1293 if (err == DS_OK && drv)
1294 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1296 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1298 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1299 (ppd->Callback)(&data, ppd->Context);
1302 HeapFree(GetProcessHeap(),0,wInterface);
1305 HeapFree(GetProcessHeap(),0,wDescription);
1306 HeapFree(GetProcessHeap(),0,wModule);
1310 devs = waveInGetNumDevs();
1311 for (wid = 0; wid < devs; ++wid) {
1312 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1314 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1315 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1316 if (wDescription && wModule) {
1318 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1320 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1322 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1325 ZeroMemory(&data, sizeof(data));
1326 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1327 data.WaveDeviceId = wid;
1328 data.DeviceId = DSOUND_capture_guids[wid];
1330 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1331 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1333 data.Description = wDescription;
1334 data.Module = wModule;
1335 data.Interface = wInterface;
1336 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1337 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
1338 if (err == DS_OK && drv)
1339 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1341 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1343 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1344 (ppd->Callback)(&data, ppd->Context);
1347 HeapFree(GetProcessHeap(),0,wInterface);
1350 HeapFree(GetProcessHeap(),0,wDescription);
1351 HeapFree(GetProcessHeap(),0,wModule);
1359 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1364 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1367 return E_PROP_ID_UNSUPPORTED;
1370 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1371 LPKSPROPERTYSET iface,
1372 REFGUID guidPropSet,
1374 LPVOID pInstanceData,
1375 ULONG cbInstanceData,
1378 PULONG pcbReturned )
1380 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1381 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1382 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1384 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1386 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1387 return DSPROPERTY_WaveDeviceMappingA(guidPropSet,pPropData,cbPropData,pcbReturned);
1388 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1389 return DSPROPERTY_Description1(guidPropSet,pPropData,cbPropData,pcbReturned);
1390 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1391 return DSPROPERTY_Enumerate1(guidPropSet,pPropData,cbPropData,pcbReturned);
1392 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1393 return DSPROPERTY_WaveDeviceMappingW(guidPropSet,pPropData,cbPropData,pcbReturned);
1394 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1395 return DSPROPERTY_DescriptionA(guidPropSet,pPropData,cbPropData,pcbReturned);
1396 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1397 return DSPROPERTY_DescriptionW(guidPropSet,pPropData,cbPropData,pcbReturned);
1398 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1399 return DSPROPERTY_EnumerateA(guidPropSet,pPropData,cbPropData,pcbReturned);
1400 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1401 return DSPROPERTY_EnumerateW(guidPropSet,pPropData,cbPropData,pcbReturned);
1403 FIXME("unsupported ID: %ld\n",dwPropID);
1407 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1412 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1415 return E_PROP_ID_UNSUPPORTED;
1418 static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
1419 LPKSPROPERTYSET iface,
1420 REFGUID guidPropSet,
1422 LPVOID pInstanceData,
1423 ULONG cbInstanceData,
1427 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1429 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1430 return E_PROP_ID_UNSUPPORTED;
1433 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1434 LPKSPROPERTYSET iface,
1435 REFGUID guidPropSet,
1437 PULONG pTypeSupport )
1439 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1440 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1442 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1444 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1445 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1447 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1448 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1450 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1451 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1453 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1454 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1456 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1457 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1459 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1460 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1462 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1463 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1465 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1466 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1469 FIXME("unsupported ID: %ld\n",dwPropID);
1473 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1476 return E_PROP_ID_UNSUPPORTED;
1479 static IKsPropertySetVtbl ikspvt = {
1480 IKsPrivatePropertySetImpl_QueryInterface,
1481 IKsPrivatePropertySetImpl_AddRef,
1482 IKsPrivatePropertySetImpl_Release,
1483 IKsPrivatePropertySetImpl_Get,
1484 IKsPrivatePropertySetImpl_Set,
1485 IKsPrivatePropertySetImpl_QuerySupport
1488 HRESULT WINAPI IKsPrivatePropertySetImpl_Create(
1489 IKsPrivatePropertySetImpl **piks)
1491 IKsPrivatePropertySetImpl *iks;
1493 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1495 iks->lpVtbl = &ikspvt;