2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Configuration of network devices
4 * FILE: dll/directx/dsound_new/secondary.c
5 * PURPOSE: Secondary IDirectSoundBuffer8 implementation
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
15 IKsPropertySetVtbl
*lpVtbl
;
18 }CKsPropertySetImpl
, *LPCKsPropertySetImpl
;
22 KSPropertySetImpl_fnQueryInterface(
23 LPKSPROPERTYSET iface
,
28 LPCKsPropertySetImpl This
= (LPCKsPropertySetImpl
)CONTAINING_RECORD(iface
, CKsPropertySetImpl
, lpVtbl
);
31 if (IsEqualIID(riid
, &IID_IUnknown
) ||
32 IsEqualIID(riid
, &IID_IKsPropertySet
))
34 *ppobj
= (LPVOID
)&This
->lpVtbl
;
35 InterlockedIncrement(&This
->ref
);
39 if (SUCCEEDED(StringFromIID(riid
, &pStr
)))
41 DPRINT("No Interface for riid %s\n", pStr
);
49 KSPropertySetImpl_fnAddRef(
50 LPKSPROPERTYSET iface
)
53 LPCKsPropertySetImpl This
= (LPCKsPropertySetImpl
)CONTAINING_RECORD(iface
, CKsPropertySetImpl
, lpVtbl
);
55 ref
= InterlockedIncrement(&This
->ref
);
62 KSPropertySetImpl_fnRelease(
63 LPKSPROPERTYSET iface
)
66 LPCKsPropertySetImpl This
= (LPCKsPropertySetImpl
)CONTAINING_RECORD(iface
, CKsPropertySetImpl
, lpVtbl
);
68 ref
= InterlockedDecrement(&(This
->ref
));
72 HeapFree(GetProcessHeap(), 0, This
);
81 KSPropertySetImpl_Get(
82 LPKSPROPERTYSET iface
,
98 LPFILTERINFO Filter
= NULL
;
99 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA Desc
;
101 StringFromIID(guidPropSet
, &pStr
);
103 //DPRINT("Requested Property %ws dwPropID %u pInstanceData %p cbInstanceData %u pPropData %p cbPropData %u pcbReturned %p\n",
104 // pStr, dwPropID, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
107 if (!IsEqualGUID(guidPropSet
, &DSPROPSETID_DirectSoundDevice
))
109 /* unsupported property set */
110 return E_PROP_ID_UNSUPPORTED
;
113 if (dwPropID
== DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1
)
115 if (cbPropData
< sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
))
117 /* invalid parameter */
118 return DSERR_INVALIDPARAM
;
121 Desc
= (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
)pPropData
;
123 if (IsEqualGUID(&Desc
->DeviceId
, &GUID_NULL
))
125 if (Desc
->DataFlow
== DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
)
127 DPRINT("Using default capture guid\n");
128 CopyMemory(&DeviceGuid
, &DSDEVID_DefaultCapture
, sizeof(GUID
));
132 DPRINT("Using default capture guid\n");
133 CopyMemory(&DeviceGuid
, &DSDEVID_DefaultPlayback
, sizeof(GUID
));
138 /* use provided guid */
139 CopyMemory(&DeviceGuid
, &Desc
->DeviceId
, sizeof(GUID
));
142 if (GetDeviceID(&DeviceGuid
, &Desc
->DeviceId
) != DS_OK
)
144 DPRINT("Unknown device guid\n");
145 return DSERR_INVALIDPARAM
;
149 ASSERT(FindDeviceByGuid(&Desc
->DeviceId
, &Filter
));
150 ASSERT(Filter
!= NULL
);
152 /* fill in description */
153 if (IsEqualGUID(&Desc
->DeviceId
, &Filter
->DeviceGuid
[0]))
156 Desc
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
;
157 Desc
->WaveDeviceId
= Filter
->MappedId
[0];
159 Result
= waveInGetDevCapsW(Filter
->MappedId
[0], &CapsIn
, sizeof(WAVEINCAPSW
));
160 if (Result
!= MMSYSERR_NOERROR
)
162 CapsIn
.szPname
[0] = 0;
163 DPRINT("waveInGetDevCaps Device %u failed with %x\n", Filter
->MappedId
[0], Result
);
166 CapsIn
.szPname
[MAXPNAMELEN
-1] = 0;
167 wcscpy(Desc
->DescriptionW
, CapsIn
.szPname
);
168 WideCharToMultiByte(CP_ACP
, 0, CapsIn
.szPname
, -1, Desc
->DescriptionA
, sizeof(Desc
->DescriptionA
), NULL
, NULL
);
174 Desc
->DataFlow
= DIRECTSOUNDDEVICE_DATAFLOW_RENDER
;
175 Desc
->WaveDeviceId
= Filter
->MappedId
[1];
177 Result
= waveOutGetDevCapsW(Filter
->MappedId
[1], &CapsOut
, sizeof(WAVEOUTCAPSW
));
178 if (Result
!= MMSYSERR_NOERROR
)
180 CapsOut
.szPname
[0] = 0;
181 DPRINT("waveOutGetDevCaps Device %u failed with %x\n", Filter
->MappedId
[1], Result
);
184 CapsOut
.szPname
[MAXPNAMELEN
-1] = 0;
185 wcscpy(Desc
->DescriptionW
, CapsOut
.szPname
);
186 WideCharToMultiByte(CP_ACP
, 0, CapsOut
.szPname
, -1, Desc
->DescriptionA
, sizeof(Desc
->DescriptionA
), NULL
, NULL
);
189 /* ReactOS doesnt support vxd or emulated */
190 Desc
->Type
= DIRECTSOUNDDEVICE_TYPE_WDM
;
191 Desc
->ModuleA
[0] = 0;
192 Desc
->ModuleW
[0] = 0;
194 *pcbReturned
= sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA
);
200 return E_PROP_ID_UNSUPPORTED
;
205 KSPropertySetImpl_Set(
206 LPKSPROPERTYSET iface
,
209 LPVOID pInstanceData
,
210 ULONG cbInstanceData
,
215 return E_PROP_ID_UNSUPPORTED
;
220 KSPropertySetImpl_QuerySupport(
221 LPKSPROPERTYSET iface
,
224 PULONG pTypeSupport
)
227 return E_PROP_ID_UNSUPPORTED
;
230 static IKsPropertySetVtbl vt_KsPropertySet
=
232 /* IUnknown methods */
233 KSPropertySetImpl_fnQueryInterface
,
234 KSPropertySetImpl_fnAddRef
,
235 KSPropertySetImpl_fnRelease
,
236 /* IKsPropertySet methods */
237 KSPropertySetImpl_Get
,
238 KSPropertySetImpl_Set
,
239 KSPropertySetImpl_QuerySupport
250 LPCKsPropertySetImpl This
;
252 /* check requested interface */
253 if (!IsEqualIID(riid
, &IID_IUnknown
) && !IsEqualIID(riid
, &IID_IKsPropertySet
))
256 StringFromIID(riid
, &pStr
);
257 DPRINT("KsPropertySet does not support Interface %ws\n", pStr
);
259 return E_NOINTERFACE
;
262 /* allocate object */
263 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(CKsPropertySetImpl
));
265 return E_OUTOFMEMORY
;
267 /* initialize object */
269 This
->lpVtbl
= &vt_KsPropertySet
;
270 *ppvObject
= (LPVOID
)&This
->lpVtbl
;