3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2002 TransGaming Technologies, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
36 #include "dsound_private.h"
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 %d\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 %d\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=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,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->device;
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,%d,%p,%d,%p,%d)\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->device;
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,%d,%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 const IKsPropertySetVtbl iksbvt = {
188 IKsBufferPropertySetImpl_QueryInterface,
189 IKsBufferPropertySetImpl_AddRef,
190 IKsBufferPropertySetImpl_Release,
191 IKsBufferPropertySetImpl_Get,
192 IKsBufferPropertySetImpl_Set,
193 IKsBufferPropertySetImpl_QuerySupport
196 HRESULT 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 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 %d\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 %d\n", This, ref + 1);
263 HeapFree(GetProcessHeap(), 0, This);
264 TRACE("(%p) released\n", This);
269 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingA(
274 HRESULT hr = DSERR_INVALIDPARAM;
275 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA ppd;
276 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
277 pPropData,cbPropData,pcbReturned);
279 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA) pPropData;
282 WARN("invalid parameter: pPropData\n");
283 return DSERR_INVALIDPARAM;
286 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
289 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
290 wodn = waveOutGetNumDevs();
291 for (wod = 0; wod < wodn; wod++) {
294 res = waveOutGetDevCapsA(wod, &capsA, sizeof(capsA));
295 if (res == MMSYSERR_NOERROR) {
296 if (lstrcmpA(capsA.szPname, ppd->DeviceName) == 0) {
297 ppd->DeviceId = DSOUND_renderer_guids[wod];
299 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
305 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
308 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
309 widn = waveInGetNumDevs();
310 for (wid = 0; wid < widn; wid++) {
313 res = waveInGetDevCapsA(wid, &capsA, sizeof(capsA));
314 if (res == MMSYSERR_NOERROR) {
315 if (lstrcmpA(capsA.szPname, ppd->DeviceName) == 0) {
316 ppd->DeviceId = DSOUND_capture_guids[wid];
317 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
327 *pcbReturned = cbPropData;
332 static HRESULT WINAPI DSPROPERTY_WaveDeviceMappingW(
337 HRESULT hr = DSERR_INVALIDPARAM;
338 PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd;
339 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
340 pPropData,cbPropData,pcbReturned);
342 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA) pPropData;
345 WARN("invalid parameter: pPropData\n");
346 return DSERR_INVALIDPARAM;
349 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
352 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
353 wodn = waveOutGetNumDevs();
354 for (wod = 0; wod < wodn; wod++) {
357 res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW));
358 if (res == MMSYSERR_NOERROR) {
359 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
360 ppd->DeviceId = DSOUND_renderer_guids[wod];
362 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
363 debugstr_w(ppd->DeviceName));
368 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
371 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
372 widn = waveInGetNumDevs();
373 for (wid = 0; wid < widn; wid++) {
376 res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW));
377 if (res == MMSYSERR_NOERROR) {
378 if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
379 ppd->DeviceId = DSOUND_capture_guids[wid];
381 TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
382 debugstr_w(ppd->DeviceName));
390 *pcbReturned = cbPropData;
395 static HRESULT WINAPI DSPROPERTY_Description1(
402 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA ppd;
403 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
404 pPropData,cbPropData,pcbReturned);
406 ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA) pPropData;
409 WARN("invalid parameter: pPropData\n");
410 return DSERR_INVALIDPARAM;
413 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
414 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
415 /* default device of type specified by ppd->DataFlow */
416 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
417 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
418 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
419 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
421 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
423 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
424 pPropData,cbPropData,pcbReturned);
425 return E_PROP_ID_UNSUPPORTED;
428 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
429 GetDeviceID(&ppd->DeviceId, &dev_guid);
431 if ( IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultPlayback) ||
432 IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultVoicePlayback) ) {
435 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
436 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
437 wodn = waveOutGetNumDevs();
438 for (wod = 0; wod < wodn; wod++) {
439 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
441 ppd->WaveDeviceId = wod;
443 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
445 PIDSDRIVER drv = NULL;
446 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
447 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
448 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
449 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
450 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
451 if (err == DS_OK && drv)
452 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
454 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
457 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
458 return E_PROP_ID_UNSUPPORTED;
462 } else if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
463 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
466 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
467 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
468 widn = waveInGetNumDevs();
469 for (wid = 0; wid < widn; wid++) {
470 if (IsEqualGUID( &dev_guid, &guid) ) {
472 ppd->WaveDeviceId = wid;
474 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
477 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
478 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
479 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
480 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
481 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
482 if (err == DS_OK && drv)
483 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
485 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
488 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
489 return E_PROP_ID_UNSUPPORTED;
497 /* given specific device so try the render devices first */
498 wodn = waveOutGetNumDevs();
499 for (wod = 0; wod < wodn; wod++) {
500 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
502 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
503 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
504 ppd->WaveDeviceId = wod;
506 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
508 PIDSDRIVER drv = NULL;
509 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
510 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
511 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
512 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
513 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
514 if (err == DS_OK && drv)
515 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
517 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
521 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
522 return E_PROP_ID_UNSUPPORTED;
527 if (found == FALSE) {
530 /* given specific device so try the capture devices next */
531 widn = waveInGetNumDevs();
532 for (wid = 0; wid < widn; wid++) {
533 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
535 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
536 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
537 ppd->WaveDeviceId = wid;
539 err = mmErr(waveInMessage((HWAVEIN)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
541 PIDSDRIVER drv = NULL;
542 lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
543 lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
544 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
545 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
546 err = mmErr(waveInMessage((HWAVEIN)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
547 if (err == DS_OK && drv)
548 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
550 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
554 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
555 return E_PROP_ID_UNSUPPORTED;
560 if (found == FALSE) {
561 WARN("device not found\n");
562 return E_PROP_ID_UNSUPPORTED;
568 *pcbReturned = cbPropData;
569 TRACE("*pcbReturned=%d\n", *pcbReturned);
575 static HRESULT WINAPI DSPROPERTY_DescriptionA(
580 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA) pPropData;
583 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
584 pPropData,cbPropData,pcbReturned);
586 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
587 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
588 /* default device of type specified by ppd->DataFlow */
589 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
590 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
591 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
592 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
594 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
596 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
597 pPropData,cbPropData,pcbReturned);
598 return E_PROP_ID_UNSUPPORTED;
601 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
602 GetDeviceID(&ppd->DeviceId, &dev_guid);
604 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
605 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
608 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
609 TRACE("DSDEVID_DefaultPlayback\n");
611 TRACE("DSDEVID_DefaultVoicePlayback\n");
612 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
613 wodn = waveOutGetNumDevs();
614 for (wod = 0; wod < wodn; wod++) {
615 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
617 ppd->WaveDeviceId = wod;
618 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
620 PIDSDRIVER drv = NULL;
621 /* FIXME: this is a memory leak */
622 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
623 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
624 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
626 if (szDescription && szModule && szInterface) {
627 strcpy(szDescription, desc.szDesc);
628 strcpy(szModule, desc.szDrvname);
629 strcpy(szInterface, "Interface");
631 ppd->Description = szDescription;
632 ppd->Module = szModule;
633 ppd->Interface = szInterface;
634 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
635 if (err == DS_OK && drv)
636 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
638 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
642 HeapFree(GetProcessHeap(), 0, szDescription);
643 HeapFree(GetProcessHeap(), 0, szModule);
644 HeapFree(GetProcessHeap(), 0, szInterface);
645 return E_OUTOFMEMORY;
648 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
649 return E_PROP_ID_UNSUPPORTED;
653 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
654 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
657 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) )
658 TRACE("DSDEVID_DefaultCapture\n");
660 TRACE("DSDEVID_DefaultVoiceCapture\n");
661 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
662 widn = waveInGetNumDevs();
663 for (wid = 0; wid < widn; wid++) {
664 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
666 ppd->WaveDeviceId = wid;
667 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
670 /* FIXME: this is a memory leak */
671 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
672 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
673 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
675 if (szDescription && szModule && szInterface) {
676 strcpy(szDescription, desc.szDesc);
677 strcpy(szModule, desc.szDrvname);
678 strcpy(szInterface, "Interface");
680 ppd->Description = szDescription;
681 ppd->Module = szModule;
682 ppd->Interface = szInterface;
683 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
684 if (err == DS_OK && drv)
685 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
687 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
691 HeapFree(GetProcessHeap(), 0, szDescription);
692 HeapFree(GetProcessHeap(), 0, szModule);
693 HeapFree(GetProcessHeap(), 0, szInterface);
694 return E_OUTOFMEMORY;
697 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
698 return E_PROP_ID_UNSUPPORTED;
706 /* given specific device so try the render devices first */
707 TRACE("Checking renderer devices\n");
708 wodn = waveOutGetNumDevs();
709 for (wod = 0; wod < wodn; wod++) {
710 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
712 TRACE("DSOUND_renderer_guids[%d]\n", wod);
713 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
714 ppd->WaveDeviceId = wod;
715 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
717 PIDSDRIVER drv = NULL;
718 /* FIXME: this is a memory leak */
719 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
720 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
721 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
723 if (szDescription && szModule && szInterface) {
724 strcpy(szDescription, desc.szDesc);
725 strcpy(szModule, desc.szDrvname);
726 strcpy(szInterface, "Interface");
728 ppd->Description = szDescription;
729 ppd->Module = szModule;
730 ppd->Interface = szInterface;
731 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
732 if (err == DS_OK && drv)
733 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
735 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
740 HeapFree(GetProcessHeap(), 0, szDescription);
741 HeapFree(GetProcessHeap(), 0, szModule);
742 HeapFree(GetProcessHeap(), 0, szInterface);
743 return E_OUTOFMEMORY;
746 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
747 return E_PROP_ID_UNSUPPORTED;
752 if (found == FALSE) {
755 TRACE("Checking capture devices\n");
756 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
757 widn = waveInGetNumDevs();
758 for (wid = 0; wid < widn; wid++) {
759 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_capture_guids[wid] ) ) {
761 TRACE("DSOUND_capture_guids[%d]\n", wid);
762 ppd->WaveDeviceId = wid;
763 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
766 /* FIXME: this is a memory leak */
767 CHAR * szDescription = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDesc) + 1);
768 CHAR * szModule = HeapAlloc(GetProcessHeap(),0,strlen(desc.szDrvname) + 1);
769 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,strlen("Interface") + 1);
771 if (szDescription && szModule && szInterface) {
772 strcpy(szDescription, desc.szDesc);
773 strcpy(szModule, desc.szDrvname);
774 strcpy(szInterface, "Interface");
776 ppd->Description = szDescription;
777 ppd->Module = szModule;
778 ppd->Interface = szInterface;
779 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
780 if (err == DS_OK && drv)
781 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
783 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
788 HeapFree(GetProcessHeap(), 0, szDescription);
789 HeapFree(GetProcessHeap(), 0, szModule);
790 HeapFree(GetProcessHeap(), 0, szInterface);
791 return E_OUTOFMEMORY;
794 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
795 return E_PROP_ID_UNSUPPORTED;
801 if (found == FALSE) {
802 WARN("device not found\n");
803 return E_PROP_ID_UNSUPPORTED;
808 *pcbReturned = cbPropData;
809 TRACE("*pcbReturned=%d\n", *pcbReturned);
815 static HRESULT WINAPI DSPROPERTY_DescriptionW(
820 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA) pPropData;
823 TRACE("pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
824 pPropData,cbPropData,pcbReturned);
826 TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
827 if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
828 /* default device of type specified by ppd->DataFlow */
829 if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
830 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
831 } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
832 TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
834 TRACE("DataFlow=Unknown(%d)\n", ppd->DataFlow);
836 FIXME("(pPropData=%p,cbPropData=%d,pcbReturned=%p) GUID_NULL not implemented!\n",
837 pPropData,cbPropData,pcbReturned);
838 return E_PROP_ID_UNSUPPORTED;
841 ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
842 GetDeviceID(&ppd->DeviceId, &dev_guid);
844 if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
845 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
848 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) )
849 TRACE("DSDEVID_DefaultPlayback\n");
851 TRACE("DSDEVID_DefaultVoicePlayback\n");
852 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
853 wodn = waveOutGetNumDevs();
854 for (wod = 0; wod < wodn; wod++) {
855 if (IsEqualGUID( &dev_guid, &DSOUND_renderer_guids[wod] ) ) {
857 TRACE("DSOUND_renderer_guids[%d]\n", wod);
858 ppd->WaveDeviceId = wod;
859 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
861 PIDSDRIVER drv = NULL;
862 /* FIXME: this is a memory leak */
863 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
864 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
865 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
867 if (wDescription && wModule && wInterface) {
868 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
869 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
870 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
872 ppd->Description = wDescription;
873 ppd->Module = wModule;
874 ppd->Interface = wInterface;
875 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
876 if (err == DS_OK && drv)
877 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
879 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
883 HeapFree(GetProcessHeap(), 0, wDescription);
884 HeapFree(GetProcessHeap(), 0, wModule);
885 HeapFree(GetProcessHeap(), 0, wInterface);
886 return E_OUTOFMEMORY;
889 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
890 return E_PROP_ID_UNSUPPORTED;
894 } else if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture) ||
895 IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoiceCapture) ) {
898 if (IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultCapture))
899 TRACE("DSDEVID_DefaultCapture\n");
901 TRACE("DSDEVID_DefaultVoiceCapture\n");
902 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
903 widn = waveInGetNumDevs();
904 for (wid = 0; wid < widn; wid++) {
905 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
907 ppd->WaveDeviceId = wid;
908 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
911 /* FIXME: this is a memory leak */
912 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
913 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
914 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
916 if (wDescription && wModule && wInterface) {
917 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
918 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
919 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
921 ppd->Description = wDescription;
922 ppd->Module = wModule;
923 ppd->Interface = wInterface;
924 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
925 if (err == DS_OK && drv)
926 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
928 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
932 HeapFree(GetProcessHeap(), 0, wDescription);
933 HeapFree(GetProcessHeap(), 0, wModule);
934 HeapFree(GetProcessHeap(), 0, wInterface);
935 return E_OUTOFMEMORY;
938 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
939 return E_PROP_ID_UNSUPPORTED;
947 TRACE("Checking renderer devices\n");
948 /* given specific device so try the render devices first */
949 wodn = waveOutGetNumDevs();
950 for (wod = 0; wod < wodn; wod++) {
951 if (IsEqualGUID( &ppd->DeviceId, &DSOUND_renderer_guids[wod] ) ) {
953 TRACE("DSOUND_renderer_guids[%d]\n", wod);
954 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
955 ppd->WaveDeviceId = wod;
956 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
958 PIDSDRIVER drv = NULL;
959 /* FIXME: this is a memory leak */
960 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
961 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
962 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
964 if (wDescription && wModule && wInterface) {
965 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
966 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
967 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
969 ppd->Description = wDescription;
970 ppd->Module = wModule;
971 ppd->Interface = wInterface;
972 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
973 if (err == DS_OK && drv)
974 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
976 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
981 HeapFree(GetProcessHeap(), 0, wDescription);
982 HeapFree(GetProcessHeap(), 0, wModule);
983 HeapFree(GetProcessHeap(), 0, wInterface);
984 return E_OUTOFMEMORY;
987 WARN("waveOutMessage(DRV_QUERYDSOUNDDESC) failed\n");
988 return E_PROP_ID_UNSUPPORTED;
993 if (found == FALSE) {
996 TRACE("Checking capture devices\n");
997 ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
998 widn = waveInGetNumDevs();
999 for (wid = 0; wid < widn; wid++) {
1000 if (IsEqualGUID( &dev_guid, &DSOUND_capture_guids[wid] ) ) {
1002 TRACE("DSOUND_capture_guids[%d]\n", wid);
1003 ppd->WaveDeviceId = wid;
1004 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&(desc),0));
1007 /* FIXME: this is a memory leak */
1008 WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
1009 WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
1010 WCHAR * wInterface = HeapAlloc(GetProcessHeap(),0,0x200);
1012 if (wDescription && wModule && wInterface) {
1013 MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, wDescription, 0x100 );
1014 MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, wModule, 0x100 );
1015 MultiByteToWideChar( CP_ACP, 0, "Interface", -1, wInterface, 0x100 );
1017 ppd->Description = wDescription;
1018 ppd->Module = wModule;
1019 ppd->Interface = wInterface;
1020 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&drv,0));
1021 if (err == DS_OK && drv)
1022 ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1024 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1028 WARN("no memory\n");
1029 HeapFree(GetProcessHeap(), 0, wDescription);
1030 HeapFree(GetProcessHeap(), 0, wModule);
1031 HeapFree(GetProcessHeap(), 0, wInterface);
1032 return E_OUTOFMEMORY;
1035 WARN("waveInMessage(DRV_QUERYDSOUNDDESC) failed\n");
1036 return E_PROP_ID_UNSUPPORTED;
1042 if (found == FALSE) {
1043 WARN("device not found\n");
1044 return E_PROP_ID_UNSUPPORTED;
1049 *pcbReturned = cbPropData;
1050 TRACE("*pcbReturned=%d\n", *pcbReturned);
1056 static HRESULT WINAPI DSPROPERTY_Enumerate1(
1059 PULONG pcbReturned )
1061 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA) pPropData;
1063 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1064 pPropData,cbPropData,pcbReturned);
1067 if (ppd->Callback) {
1068 unsigned devs, wod, wid;
1070 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data;
1072 devs = waveOutGetNumDevs();
1073 for (wod = 0; wod < devs; ++wod) {
1074 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1077 ZeroMemory(&data, sizeof(data));
1078 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1079 data.WaveDeviceId = wod;
1080 data.DeviceId = DSOUND_renderer_guids[wod];
1081 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1082 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1084 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1085 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1087 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1088 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1089 if (err == DS_OK && drv)
1090 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1092 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1094 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1095 (ppd->Callback)(&data, ppd->Context);
1099 devs = waveInGetNumDevs();
1100 for (wid = 0; wid < devs; ++wid) {
1101 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1104 ZeroMemory(&data, sizeof(data));
1105 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1106 data.WaveDeviceId = wid;
1107 data.DeviceId = DSOUND_capture_guids[wid];
1108 lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
1109 lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
1111 MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) );
1112 MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) );
1114 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1115 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1116 if (err == DS_OK && drv)
1117 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1119 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1121 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1122 (ppd->Callback)(&data, ppd->Context);
1132 FIXME("*pcbReturned=%d\n", *pcbReturned);
1135 return E_PROP_ID_UNSUPPORTED;
1138 static HRESULT WINAPI DSPROPERTY_EnumerateA(
1141 PULONG pcbReturned )
1143 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA) pPropData;
1145 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1146 pPropData,cbPropData,pcbReturned);
1149 if (ppd->Callback) {
1150 unsigned devs, wod, wid;
1152 DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data;
1154 devs = waveOutGetNumDevs();
1155 for (wod = 0; wod < devs; ++wod) {
1156 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1159 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1161 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1163 err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1165 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1168 ZeroMemory(&data, sizeof(data));
1169 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
1170 data.WaveDeviceId = wod;
1171 data.DeviceId = DSOUND_renderer_guids[wod];
1172 data.Description = desc.szDesc;
1173 data.Module = desc.szDrvname;
1174 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1175 data.Interface = szInterface;
1177 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1178 err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1179 if (err == DS_OK && drv)
1180 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1182 WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1184 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1185 (ppd->Callback)(&data, ppd->Context);
1187 HeapFree(GetProcessHeap(),0,szInterface);
1190 HeapFree(GetProcessHeap(),0,nameW);
1195 devs = waveInGetNumDevs();
1196 for (wid = 0; wid < devs; ++wid) {
1197 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
1200 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACESIZE,(DWORD_PTR)&size,0));
1202 WCHAR * nameW = HeapAlloc(GetProcessHeap(),0,size);
1204 err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDEVICEINTERFACE,(DWORD_PTR)nameW,size));
1206 CHAR * szInterface = HeapAlloc(GetProcessHeap(),0,size/sizeof(WCHAR));
1209 ZeroMemory(&data, sizeof(data));
1210 data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
1211 data.WaveDeviceId = wid;
1212 data.DeviceId = DSOUND_capture_guids[wid];
1213 data.Description = desc.szDesc;
1214 data.Module = desc.szDrvname;
1215 WideCharToMultiByte( CP_ACP, 0, nameW, size/sizeof(WCHAR), szInterface, size/sizeof(WCHAR), NULL, NULL );
1216 data.Interface = szInterface;
1218 data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
1219 err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0));
1220 if (err == DS_OK && drv)
1221 data.Type = DIRECTSOUNDDEVICE_TYPE_VXD;
1223 WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n");
1225 TRACE("calling Callback(%p,%p)\n", &data, ppd->Context);
1226 (ppd->Callback)(&data, ppd->Context);
1228 HeapFree(GetProcessHeap(),0,szInterface);
1231 HeapFree(GetProcessHeap(),0,nameW);
1242 FIXME("*pcbReturned=%d\n", *pcbReturned);
1245 return E_PROP_ID_UNSUPPORTED;
1248 static HRESULT WINAPI DSPROPERTY_EnumerateW(
1251 PULONG pcbReturned )
1253 PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = (PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA) pPropData;
1255 TRACE("(pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1256 pPropData,cbPropData,pcbReturned);
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_PTR)&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_PTR)&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_PTR)&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_PTR)&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);
1361 FIXME("*pcbReturned=%d\n", *pcbReturned);
1364 return E_PROP_ID_UNSUPPORTED;
1367 static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
1368 LPKSPROPERTYSET iface,
1369 REFGUID guidPropSet,
1371 LPVOID pInstanceData,
1372 ULONG cbInstanceData,
1375 PULONG pcbReturned )
1377 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1378 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1379 This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
1381 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1383 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1384 return DSPROPERTY_WaveDeviceMappingA(pPropData,cbPropData,pcbReturned);
1385 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1386 return DSPROPERTY_Description1(pPropData,cbPropData,pcbReturned);
1387 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1388 return DSPROPERTY_Enumerate1(pPropData,cbPropData,pcbReturned);
1389 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1390 return DSPROPERTY_WaveDeviceMappingW(pPropData,cbPropData,pcbReturned);
1391 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1392 return DSPROPERTY_DescriptionA(pPropData,cbPropData,pcbReturned);
1393 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1394 return DSPROPERTY_DescriptionW(pPropData,cbPropData,pcbReturned);
1395 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1396 return DSPROPERTY_EnumerateA(pPropData,cbPropData,pcbReturned);
1397 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1398 return DSPROPERTY_EnumerateW(pPropData,cbPropData,pcbReturned);
1400 FIXME("unsupported ID: %d\n",dwPropID);
1404 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1409 FIXME("*pcbReturned=%d\n", *pcbReturned);
1412 return E_PROP_ID_UNSUPPORTED;
1415 static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
1416 LPKSPROPERTYSET iface,
1417 REFGUID guidPropSet,
1419 LPVOID pInstanceData,
1420 ULONG cbInstanceData,
1424 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1426 FIXME("(%p,%s,%d,%p,%d,%p,%d), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
1427 return E_PROP_ID_UNSUPPORTED;
1430 static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
1431 LPKSPROPERTYSET iface,
1432 REFGUID guidPropSet,
1434 PULONG pTypeSupport )
1436 IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
1437 TRACE("(%p,%s,%d,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
1439 if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
1441 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
1442 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1444 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
1445 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1447 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
1448 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1450 case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
1451 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1453 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
1454 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1456 case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
1457 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1459 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
1460 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1462 case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
1463 *pTypeSupport = KSPROPERTY_SUPPORT_GET;
1466 FIXME("unsupported ID: %d\n",dwPropID);
1470 FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
1473 return E_PROP_ID_UNSUPPORTED;
1476 static const IKsPropertySetVtbl ikspvt = {
1477 IKsPrivatePropertySetImpl_QueryInterface,
1478 IKsPrivatePropertySetImpl_AddRef,
1479 IKsPrivatePropertySetImpl_Release,
1480 IKsPrivatePropertySetImpl_Get,
1481 IKsPrivatePropertySetImpl_Set,
1482 IKsPrivatePropertySetImpl_QuerySupport
1485 HRESULT IKsPrivatePropertySetImpl_Create(
1487 IKsPrivatePropertySetImpl **piks)
1489 IKsPrivatePropertySetImpl *iks;
1490 TRACE("(%s, %p)\n", debugstr_guid(riid), piks);
1492 if (!IsEqualIID(riid, &IID_IUnknown) &&
1493 !IsEqualIID(riid, &IID_IKsPropertySet)) {
1495 return E_NOINTERFACE;
1498 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
1500 iks->lpVtbl = &ikspvt;