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
26 #include <sys/types.h>
27 #include <sys/fcntl.h>
33 #include <math.h> /* Insomnia - pow() function */
35 #define NONAMELESSUNION
36 #define NONAMELESSSTRUCT
47 #include "wine/windef16.h"
48 #include "wine/debug.h"
52 #include "dsound_private.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
57 /*******************************************************************************
58 * IKsBufferPropertySet
61 /* IUnknown methods */
62 static HRESULT WINAPI IKsBufferPropertySetImpl_QueryInterface(
63 LPKSPROPERTYSET iface,
67 ICOM_THIS(IKsBufferPropertySetImpl,iface);
68 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
70 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb, riid, ppobj);
73 static ULONG WINAPI IKsBufferPropertySetImpl_AddRef(LPKSPROPERTYSET iface)
75 ICOM_THIS(IKsBufferPropertySetImpl,iface);
78 TRACE("(%p) ref was %ld\n", This, This->ref);
79 ulReturn = InterlockedIncrement(&(This->ref));
83 static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
85 ICOM_THIS(IKsBufferPropertySetImpl,iface);
88 TRACE("(%p) ref was %ld\n", This, This->ref);
89 ulReturn = InterlockedDecrement(&This->ref);
92 IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER)This->dsb);
93 HeapFree(GetProcessHeap(),0,This);
94 TRACE("(%p) released\n",This);
99 static HRESULT WINAPI IKsBufferPropertySetImpl_Get(
100 LPKSPROPERTYSET iface,
103 LPVOID pInstanceData,
104 ULONG cbInstanceData,
109 ICOM_THIS(IKsBufferPropertySetImpl,iface);
110 PIDSDRIVERPROPERTYSET ps;
111 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
112 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
114 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
120 prop.s.Set = *guidPropSet;
121 prop.s.Id = dwPropID;
122 prop.s.Flags = 0; /* unused */
123 prop.s.InstanceId = (ULONG)This->dsb->dsound;
125 hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
127 IDsDriverPropertySet_Release(ps);
132 return E_PROP_ID_UNSUPPORTED;
135 static HRESULT WINAPI IKsBufferPropertySetImpl_Set(
136 LPKSPROPERTYSET iface,
139 LPVOID pInstanceData,
140 ULONG cbInstanceData,
144 ICOM_THIS(IKsBufferPropertySetImpl,iface);
145 PIDSDRIVERPROPERTYSET ps;
146 TRACE("(%p,%s,%ld,%p,%ld,%p,%ld)\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
148 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
154 prop.s.Set = *guidPropSet;
155 prop.s.Id = dwPropID;
156 prop.s.Flags = 0; /* unused */
157 prop.s.InstanceId = (ULONG)This->dsb->dsound;
158 hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData);
160 IDsDriverPropertySet_Release(ps);
165 return E_PROP_ID_UNSUPPORTED;
168 static HRESULT WINAPI IKsBufferPropertySetImpl_QuerySupport(
169 LPKSPROPERTYSET iface,
172 PULONG pTypeSupport )
174 ICOM_THIS(IKsBufferPropertySetImpl,iface);
175 PIDSDRIVERPROPERTYSET ps;
176 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
178 IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
183 hres = IDsDriverPropertySet_QuerySupport(ps,guidPropSet, dwPropID,pTypeSupport);
185 IDsDriverPropertySet_Release(ps);
190 return E_PROP_ID_UNSUPPORTED;
193 static ICOM_VTABLE(IKsPropertySet) iksbvt = {
194 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
195 IKsBufferPropertySetImpl_QueryInterface,
196 IKsBufferPropertySetImpl_AddRef,
197 IKsBufferPropertySetImpl_Release,
198 IKsBufferPropertySetImpl_Get,
199 IKsBufferPropertySetImpl_Set,
200 IKsBufferPropertySetImpl_QuerySupport
203 HRESULT WINAPI IKsBufferPropertySetImpl_Create(
204 IDirectSoundBufferImpl *dsb,
205 IKsBufferPropertySetImpl **piks)
207 IKsBufferPropertySetImpl *iks;
208 TRACE("(%p,%p)\n",dsb,piks);
210 iks = (IKsBufferPropertySetImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*iks));
214 iks->lpVtbl = &iksbvt;
216 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)dsb);
222 /*******************************************************************************
223 * IKsPrivatePropertySet
226 /* IUnknown methods */
227 static HRESULT WINAPI IKsPrivatePropertySetImpl_QueryInterface(
228 LPKSPROPERTYSET iface,
232 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
233 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
236 return DSERR_INVALIDPARAM;
239 static ULONG WINAPI IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface)
241 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
244 TRACE("(%p) ref was %ld\n", This, This->ref);
245 ulReturn = InterlockedIncrement(&This->ref);
249 static ULONG WINAPI IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface)
251 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
254 TRACE("(%p) ref was %ld\n", This, This->ref);
255 ulReturn = InterlockedDecrement(&This->ref);
259 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingA(
265 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd;
266 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) not implemented!\n",
267 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
269 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA) pPropData;
272 WARN("invalid parameter: pPropData\n");
273 return DSERR_INVALIDPARAM;
276 FIXME("DeviceName=%s\n",ppd->DeviceName);
277 FIXME("DataFlow=%s\n",
278 ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "DIRECTSOUNDDEVICE_DATAFLOW_RENDER" :
279 ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ? "DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE" : "UNKNOWN");
281 /* FIXME: match the name to a wave device somehow. */
282 ppd->DeviceId = GUID_NULL;
285 *pcbReturned = cbPropData;
286 FIXME("*pcbReturned=%ld\n", *pcbReturned);
292 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingW(
298 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd;
299 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) not implemented!\n",
300 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
302 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA) pPropData;
305 WARN("invalid parameter: pPropData\n");
306 return DSERR_INVALIDPARAM;
309 FIXME("DeviceName=%s\n",debugstr_w(ppd->DeviceName));
310 FIXME("DataFlow=%s\n",
311 ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "DIRECTSOUNDDEVICE_DATAFLOW_RENDER" :
312 ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ? "DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE" : "UNKNOWN");
314 /* FIXME: match the name to a wave device somehow. */
315 ppd->DeviceId = GUID_NULL;
318 *pcbReturned = cbPropData;
319 FIXME("*pcbReturned=%ld\n", *pcbReturned);
325 static HRESULT WINAPI DSPROPERTY_Description1(
333 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd;
334 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
335 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
337 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA) pPropData;
340 WARN("invalid parameter: pPropData\n");
341 return DSERR_INVALIDPARAM;
344 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
345 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
346 /* default device of type specified by ppd->DataFlow */
347 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
348 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
349 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
350 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
352 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
354 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
355 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
356 return E_PROP_ID_UNSUPPORTED;
359 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
360 GetDeviceID(&ppd->DeviceId, &dev_guid);
362 if ( IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultPlayback) ||
363 IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultVoicePlayback) ) {
366 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
367 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
368 wodn = waveOutGetNumDevs();
369 for (wod = 0; wod < wodn; wod++) {
370 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
372 if (IsEqualGUID( &dev_guid, &guid) ) {
374 ppd->WaveDeviceId = wod;
376 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
378 PIDSDRIVER drv = NULL;
379 strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
380 strncpy(ppd->ModuleA, desc.szDrvName, sizeof(ppd->ModuleA) - 1);
381 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
382 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
383 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
384 if (err == DS_OK && drv)
385 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
388 WARN("waveOutMessage failed\n");
389 return E_PROP_ID_UNSUPPORTED;
393 WARN("waveOutMessage failed\n");
394 return E_PROP_ID_UNSUPPORTED;
397 } else if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
398 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
401 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
402 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
403 widn = waveInGetNumDevs();
404 for (wid = 0; wid < widn; wid++) {
405 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
407 if (IsEqualGUID( &dev_guid, &guid) ) {
409 ppd->WaveDeviceId = wid;
411 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
414 strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
415 strncpy(ppd->ModuleA, desc.szDrvName, sizeof(ppd->ModuleA) - 1);
416 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
417 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
418 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
419 if (err == DS_OK && drv)
420 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
423 WARN("waveInMessage failed\n");
424 return E_PROP_ID_UNSUPPORTED;
429 WARN("waveInMessage failed\n");
430 return E_PROP_ID_UNSUPPORTED;
437 /* given specific device so try the render devices first */
438 wodn = waveOutGetNumDevs();
439 for (wod = 0; wod < wodn; wod++) {
440 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
442 if (IsEqualGUID( &ppd->DeviceId, &guid) ) {
444 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
445 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
446 ppd->WaveDeviceId = wod;
448 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
450 PIDSDRIVER drv = NULL;
451 strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
452 strncpy(ppd->ModuleA, desc.szDrvName, sizeof(ppd->ModuleA) - 1);
453 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
454 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
455 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
456 if (err == DS_OK && drv)
457 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
461 WARN("waveOutMessage failed\n");
462 return E_PROP_ID_UNSUPPORTED;
466 WARN("waveOutMessage failed\n");
467 return E_PROP_ID_UNSUPPORTED;
471 if (found == FALSE) {
472 WARN("device not found\n");
473 return E_PROP_ID_UNSUPPORTED;
478 *pcbReturned = cbPropData;
479 TRACE("*pcbReturned=%ld\n", *pcbReturned);
485 static HRESULT WINAPI DSPROPERTY_DescriptionA(
491 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA) pPropData;
494 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
495 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
497 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
498 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
499 /* default device of type specified by ppd->DataFlow */
500 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
501 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
502 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
503 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
505 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
507 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
508 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
509 return E_PROP_ID_UNSUPPORTED;
512 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
513 GetDeviceID(&ppd->DeviceId, &dev_guid);
515 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
516 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
519 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
520 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
521 wodn = waveOutGetNumDevs();
522 for (wod = 0; wod < wodn; wod++) {
523 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
525 if (IsEqualGUID( &dev_guid, &guid) ) {
527 ppd->WaveDeviceId = wod;
528 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
530 PIDSDRIVER drv = NULL;
531 /* FIXME: this is a memory leak */
532 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
533 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvName) + 1);
534 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
536 strcpy(szDescription, desc.szDesc);
537 strcpy(szModule, desc.szDrvName);
538 strcpy(szInterface, "Interface");
540 ppd->Description = szDescription;
541 ppd->Module = szModule;
542 ppd->Interface = szInterface;
543 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
544 if (err == DS_OK && drv)
545 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
548 WARN("waveOutMessage failed\n");
549 return E_PROP_ID_UNSUPPORTED;
553 WARN("waveOutMessage failed\n");
554 return E_PROP_ID_UNSUPPORTED;
557 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
558 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
561 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
562 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
563 widn = waveInGetNumDevs();
564 for (wid = 0; wid < widn; wid++) {
565 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
567 if (IsEqualGUID( &dev_guid, &guid) ) {
569 ppd->WaveDeviceId = wid;
570 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
573 /* FIXME: this is a memory leak */
574 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
575 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvName) + 1);
576 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
578 strcpy(szDescription, desc.szDesc);
579 strcpy(szModule, desc.szDrvName);
580 strcpy(szInterface, "Interface");
582 ppd->Description = szDescription;
583 ppd->Module = szModule;
584 ppd->Interface = szInterface;
585 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
586 if (err == DS_OK && drv)
587 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
590 WARN("waveInMessage failed\n");
591 return E_PROP_ID_UNSUPPORTED;
596 WARN("waveOutMessage failed\n");
597 return E_PROP_ID_UNSUPPORTED;
604 /* given specific device so try the render devices first */
605 wodn = waveOutGetNumDevs();
606 for (wod = 0; wod < wodn; wod++) {
607 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
609 if (IsEqualGUID( &ppd->DeviceId, &guid) ) {
611 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
612 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
613 ppd->WaveDeviceId = wod;
614 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
616 PIDSDRIVER drv = NULL;
617 /* FIXME: this is a memory leak */
618 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
619 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvName) + 1);
620 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
622 strcpy(szDescription, desc.szDesc);
623 strcpy(szModule, desc.szDrvName);
624 strcpy(szInterface, "Interface");
626 ppd->Description = szDescription;
627 ppd->Module = szModule;
628 ppd->Interface = szInterface;
629 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
630 if (err == DS_OK && drv)
631 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
635 WARN("waveOutMessage failed\n");
636 return E_PROP_ID_UNSUPPORTED;
640 WARN("waveOutMessage failed\n");
641 return E_PROP_ID_UNSUPPORTED;
645 if (found == FALSE) {
646 WARN("device not found\n");
647 return E_PROP_ID_UNSUPPORTED;
652 *pcbReturned = cbPropData;
653 TRACE("*pcbReturned=%ld\n", *pcbReturned);
659 static HRESULT WINAPI DSPROPERTY_DescriptionW(
665 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA) pPropData;
668 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
669 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
671 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
672 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
673 /* default device of type specified by ppd->DataFlow */
674 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
675 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
676 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
677 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
679 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
681 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
682 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
683 return E_PROP_ID_UNSUPPORTED;
686 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
687 GetDeviceID(&ppd->DeviceId, &dev_guid);
689 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
690 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
693 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
694 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
695 wodn = waveOutGetNumDevs();
696 for (wod = 0; wod < wodn; wod++) {
697 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
699 if (IsEqualGUID( &dev_guid, &guid) ) {
701 ppd->WaveDeviceId = wod;
702 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
704 PIDSDRIVER drv = NULL;
705 /* FIXME: this is a memory leak */
706 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
707 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
708 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
710 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
711 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, wModule, 0x100 );
712 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
714 ppd->Description = wDescription;
715 ppd->Module = wModule;
716 ppd->Interface = wInterface;
717 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
718 if (err == DS_OK && drv)
719 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
722 WARN("waveOutMessage failed\n");
723 return E_PROP_ID_UNSUPPORTED;
727 WARN("waveOutMessage failed\n");
728 return E_PROP_ID_UNSUPPORTED;
731 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
732 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
735 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
736 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
737 widn = waveInGetNumDevs();
738 for (wid = 0; wid < widn; wid++) {
739 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
741 if (IsEqualGUID( &dev_guid, &guid) ) {
743 ppd->WaveDeviceId = wid;
744 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
747 /* FIXME: this is a memory leak */
748 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
749 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
750 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
752 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
753 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, wModule, 0x100 );
754 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
756 ppd->Description = wDescription;
757 ppd->Module = wModule;
758 ppd->Interface = wInterface;
759 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
760 if (err == DS_OK && drv)
761 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
764 WARN("waveInMessage failed\n");
765 return E_PROP_ID_UNSUPPORTED;
770 WARN("waveInMessage failed\n");
771 return E_PROP_ID_UNSUPPORTED;
778 /* given specific device so try the render devices first */
779 wodn = waveOutGetNumDevs();
780 for (wod = 0; wod < wodn; wod++) {
781 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
783 if (IsEqualGUID( &ppd->DeviceId, &guid) ) {
785 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
786 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
787 ppd->WaveDeviceId = wod;
788 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
790 PIDSDRIVER drv = NULL;
791 /* FIXME: this is a memory leak */
792 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
793 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
794 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
796 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
797 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, wModule, 0x100 );
798 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
800 ppd->Description = wDescription;
801 ppd->Module = wModule;
802 ppd->Interface = wInterface;
803 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
804 if (err == DS_OK && drv)
805 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
809 WARN("waveOutMessage failed\n");
810 return E_PROP_ID_UNSUPPORTED;
814 WARN("waveOutMessage failed\n");
815 return E_PROP_ID_UNSUPPORTED;
819 if (found == FALSE) {
820 WARN("device not found\n");
821 return E_PROP_ID_UNSUPPORTED;
826 *pcbReturned = cbPropData;
827 TRACE("*pcbReturned=%ld\n", *pcbReturned);
833 static HRESULT WINAPI DSPROPERTY_Enumerate1(
839 FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
840 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
841 return E_PROP_ID_UNSUPPORTED;
844 static HRESULT WINAPI DSPROPERTY_EnumerateA(
850 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
852 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
853 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
855 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
858 unsigned devs, wod, wid;
861 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
863 devs = waveOutGetNumDevs();
864 for (wod = 0; wod < devs; ++wod) {
865 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
867 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
869 memset(&data, 0, sizeof(data));
870 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
871 data.WaveDeviceId = wod;
872 data.DeviceId = guid;
873 data.Description = desc.szDesc;
874 data.Module = desc.szDrvName;
875 data.Interface = "Interface";
876 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
877 (ppd->Callback)(&data, ppd->Context);
882 devs = waveInGetNumDevs();
883 for (wid = 0; wid < devs; ++wid) {
884 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
886 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
888 memset(&data, 0, sizeof(data));
889 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
890 data.WaveDeviceId = wid;
891 data.DeviceId = guid;
892 data.Description = desc.szDesc;
893 data.Module = desc.szDrvName;
894 data.Interface = "Interface";
895 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
896 (ppd->Callback)(&data, ppd->Context);
905 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
910 FIXME("*pcbReturned=%ld\n", *pcbReturned);
913 return E_PROP_ID_UNSUPPORTED;
916 static HRESULT WINAPI DSPROPERTY_EnumerateW(
922 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
924 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
925 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
927 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
930 unsigned devs, wod, wid;
933 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
935 devs = waveOutGetNumDevs();
936 for (wod = 0; wod < devs; ++wod) {
937 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
939 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
941 /* FIXME: this is a memory leak */
942 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
943 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
944 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
946 memset(&data, 0, sizeof(data));
947 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
948 data.WaveDeviceId = wod;
949 data.DeviceId = guid;
951 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
952 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, wModule, 0x100 );
953 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
955 data.Description = wDescription;
956 data.Module = wModule;
957 data.Interface = wInterface;
958 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
959 (ppd->Callback)(&data, ppd->Context);
964 devs = waveInGetNumDevs();
965 for (wid = 0; wid < devs; ++wid) {
966 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
968 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
970 /* FIXME: this is a memory leak */
971 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
972 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
973 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
975 memset(&data, 0, sizeof(data));
976 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
977 data.WaveDeviceId = wid;
978 data.DeviceId = guid;
980 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
981 MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, wModule, 0x100 );
982 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
984 data.Description = wDescription;
985 data.Module = wModule;
986 data.Interface = wInterface;
987 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
988 (ppd->Callback)(&data, ppd->Context);
997 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1002 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1005 return E_PROP_ID_UNSUPPORTED;
1008 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1009 LPKSPROPERTYSET iface,
1010 REFGUID guidPropSet,
1012 LPVOID pInstanceData,
1013 ULONG cbInstanceData,
1018 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
1019 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1020 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1022 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1024 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1025 return DSPROPERTY_WaveDeviceMappingA(guidPropSet,pPropData,cbPropData,pcbReturned);
1026 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1027 return DSPROPERTY_Description1(guidPropSet,pPropData,cbPropData,pcbReturned);
1028 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1029 return DSPROPERTY_Enumerate1(guidPropSet,pPropData,cbPropData,pcbReturned);
1030 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1031 return DSPROPERTY_WaveDeviceMappingW(guidPropSet,pPropData,cbPropData,pcbReturned);
1032 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1033 return DSPROPERTY_DescriptionA(guidPropSet,pPropData,cbPropData,pcbReturned);
1034 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1035 return DSPROPERTY_DescriptionW(guidPropSet,pPropData,cbPropData,pcbReturned);
1036 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1037 return DSPROPERTY_EnumerateA(guidPropSet,pPropData,cbPropData,pcbReturned);
1038 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1039 return DSPROPERTY_EnumerateW(guidPropSet,pPropData,cbPropData,pcbReturned);
1041 FIXME("unsupported ID: %ld\n",dwPropID);
1045 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1050 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1053 return E_PROP_ID_UNSUPPORTED;
1056 static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
1057 LPKSPROPERTYSET iface,
1058 REFGUID guidPropSet,
1060 LPVOID pInstanceData,
1061 ULONG cbInstanceData,
1065 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
1067 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1068 return E_PROP_ID_UNSUPPORTED;
1071 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1072 LPKSPROPERTYSET iface,
1073 REFGUID guidPropSet,
1075 PULONG pTypeSupport )
1077 ICOM_THIS(IKsPrivatePropertySetImpl,iface);
1078 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1080 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1082 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1083 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1085 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1086 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1088 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1089 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1091 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1092 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1094 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1095 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1097 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1098 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1100 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1101 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1103 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1104 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1107 FIXME("unsupported ID: %ld\n",dwPropID);
1111 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1114 return E_PROP_ID_UNSUPPORTED;
1117 static ICOM_VTABLE(IKsPropertySet) ikspvt = {
1118 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1119 IKsPrivatePropertySetImpl_QueryInterface,
1120 IKsPrivatePropertySetImpl_AddRef,
1121 IKsPrivatePropertySetImpl_Release,
1122 IKsPrivatePropertySetImpl_Get,
1123 IKsPrivatePropertySetImpl_Set,
1124 IKsPrivatePropertySetImpl_QuerySupport
1127 HRESULT WINAPI IKsPrivatePropertySetImpl_Create(
1128 IKsPrivatePropertySetImpl **piks)
1130 IKsPrivatePropertySetImpl *iks;
1132 iks = (IKsPrivatePropertySetImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1134 iks->lpVtbl = &ikspvt;