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));
1066 ZeroMemory(&data, sizeof(data));
1067 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1068 data.WaveDeviceId = wod;
1069 data.DeviceId = DSOUND_renderer_guids[wod];
1070 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1071 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1073 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
1074 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
1076 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1077 (ppd->Callback)(&data, ppd->Context);
1081 devs = waveInGetNumDevs();
1082 for (wid = 0; wid < devs; ++wid) {
1083 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1085 ZeroMemory(&data, sizeof(data));
1086 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1087 data.WaveDeviceId = wod;
1088 data.DeviceId = DSOUND_renderer_guids[wod];
1089 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1090 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1092 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
1093 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
1095 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1096 (ppd->Callback)(&data, ppd->Context);
1104 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1109 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1112 return E_PROP_ID_UNSUPPORTED;
1115 static HRESULT WINAPI DSPROPERTY_EnumerateA(
1116 REFGUID guidPropSet,
1119 PULONG pcbReturned )
1121 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
1123 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1124 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1126 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1128 if (ppd->Callback) {
1129 unsigned devs, wod, wid;
1131 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
1133 devs = waveOutGetNumDevs();
1134 for (wod = 0; wod < devs; ++wod) {
1135 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1138 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1140 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1142 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1144 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1146 ZeroMemory(&data, sizeof(data));
1147 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1148 data.WaveDeviceId = wod;
1149 data.DeviceId = DSOUND_renderer_guids[wod];
1150 data.Description = desc.szDesc;
1151 data.Module = desc.szDrvname;
1152 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1153 data.Interface = szInterface;
1155 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1156 (ppd->Callback)(&data, ppd->Context);
1158 HeapFree(GetProcessHeap(),0,szInterface);
1161 HeapFree(GetProcessHeap(),0,nameW);
1166 devs = waveInGetNumDevs();
1167 for (wid = 0; wid < devs; ++wid) {
1168 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1171 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1173 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1175 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1177 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1179 ZeroMemory(&data, sizeof(data));
1180 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1181 data.WaveDeviceId = wid;
1182 data.DeviceId = DSOUND_capture_guids[wid];
1183 data.Description = desc.szDesc;
1184 data.Module = desc.szDrvname;
1185 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1186 data.Interface = szInterface;
1188 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1189 (ppd->Callback)(&data, ppd->Context);
1191 HeapFree(GetProcessHeap(),0,szInterface);
1194 HeapFree(GetProcessHeap(),0,nameW);
1203 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1208 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1211 return E_PROP_ID_UNSUPPORTED;
1214 static HRESULT WINAPI DSPROPERTY_EnumerateW(
1215 REFGUID guidPropSet,
1218 PULONG pcbReturned )
1220 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
1222 TRACE("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1223 debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
1225 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1227 if (ppd->Callback) {
1228 unsigned devs, wod, wid;
1230 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
1232 devs = waveOutGetNumDevs();
1233 for (wod = 0; wod < devs; ++wod) {
1234 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1236 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1237 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1238 if (wDescription && wModule) {
1240 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1242 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1244 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1246 ZeroMemory(&data, sizeof(data));
1247 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1248 data.WaveDeviceId = wod;
1249 data.DeviceId = DSOUND_renderer_guids[wod];
1251 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1252 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1254 data.Description = wDescription;
1255 data.Module = wModule;
1256 data.Interface = wInterface;
1258 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1259 (ppd->Callback)(&data, ppd->Context);
1262 HeapFree(GetProcessHeap(),0,wInterface);
1265 HeapFree(GetProcessHeap(),0,wDescription);
1266 HeapFree(GetProcessHeap(),0,wModule);
1270 devs = waveInGetNumDevs();
1271 for (wid = 0; wid < devs; ++wid) {
1272 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
1274 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1275 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1276 if (wDescription && wModule) {
1278 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0));
1280 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,size);
1282 err = mmErr(waveInMessage((HWAVEIN)wod, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wInterface, size));
1284 ZeroMemory(&data, sizeof(data));
1285 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1286 data.WaveDeviceId = wid;
1287 data.DeviceId = DSOUND_capture_guids[wid];
1289 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1290 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1292 data.Description = wDescription;
1293 data.Module = wModule;
1294 data.Interface = wInterface;
1295 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1296 (ppd->Callback)(&data, ppd->Context);
1299 HeapFree(GetProcessHeap(),0,wInterface);
1302 HeapFree(GetProcessHeap(),0,wDescription);
1303 HeapFree(GetProcessHeap(),0,wModule);
1311 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1316 FIXME("*pcbReturned=%ld\n", *pcbReturned);
1319 return E_PROP_ID_UNSUPPORTED;
1322 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1323 LPKSPROPERTYSET iface,
1324 REFGUID guidPropSet,
1326 LPVOID pInstanceData,
1327 ULONG cbInstanceData,
1330 PULONG pcbReturned )
1332 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1333 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
1334 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1336 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1338 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1339 return DSPROPERTY_WaveDeviceMappingA(guidPropSet,pPropData,cbPropData,pcbReturned);
1340 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1341 return DSPROPERTY_Description1(guidPropSet,pPropData,cbPropData,pcbReturned);
1342 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1343 return DSPROPERTY_Enumerate1(guidPropSet,pPropData,cbPropData,pcbReturned);
1344 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1345 return DSPROPERTY_WaveDeviceMappingW(guidPropSet,pPropData,cbPropData,pcbReturned);
1346 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1347 return DSPROPERTY_DescriptionA(guidPropSet,pPropData,cbPropData,pcbReturned);
1348 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1349 return DSPROPERTY_DescriptionW(guidPropSet,pPropData,cbPropData,pcbReturned);
1350 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1351 return DSPROPERTY_EnumerateA(guidPropSet,pPropData,cbPropData,pcbReturned);
1352 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1353 return DSPROPERTY_EnumerateW(guidPropSet,pPropData,cbPropData,pcbReturned);
1355 FIXME("unsupported ID: %ld\n",dwPropID);
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_Set(
1371 LPKSPROPERTYSET iface,
1372 REFGUID guidPropSet,
1374 LPVOID pInstanceData,
1375 ULONG cbInstanceData,
1379 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1381 FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1382 return E_PROP_ID_UNSUPPORTED;
1385 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1386 LPKSPROPERTYSET iface,
1387 REFGUID guidPropSet,
1389 PULONG pTypeSupport )
1391 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1392 TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1394 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1396 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1397 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1399 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1400 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1402 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1403 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1405 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1406 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1408 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1409 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1411 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1412 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1414 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1415 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1417 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1418 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1421 FIXME("unsupported ID: %ld\n",dwPropID);
1425 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1428 return E_PROP_ID_UNSUPPORTED;
1431 static IKsPropertySetVtbl ikspvt = {
1432 IKsPrivatePropertySetImpl_QueryInterface,
1433 IKsPrivatePropertySetImpl_AddRef,
1434 IKsPrivatePropertySetImpl_Release,
1435 IKsPrivatePropertySetImpl_Get,
1436 IKsPrivatePropertySetImpl_Set,
1437 IKsPrivatePropertySetImpl_QuerySupport
1440 HRESULT WINAPI IKsPrivatePropertySetImpl_Create(
1441 IKsPrivatePropertySetImpl **piks)
1443 IKsPrivatePropertySetImpl *iks;
1445 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1447 iks->lpVtbl = &ikspvt;