2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Configuration of network devices
4 * FILE: dll/directx/dsound_new/capturebuffer.c
5 * PURPOSE: IDirectSoundCaptureBuffer8 implementation
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
13 const GUID KSINTERFACESETID_Standard
= {0x1A8766A0L
, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
14 const GUID KSMEDIUMSETID_Standard
= {0x4747B320L
, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
15 const GUID KSDATAFORMAT_TYPE_AUDIO
= {0x73647561L
, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
16 const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
= {0x05589f81L
, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
17 const GUID KSPROPSETID_Connection
= {0x1D58C920L
, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
22 IDirectSoundCaptureBuffer8Vtbl
*lpVtbl
;
28 LPWAVEFORMATEX Format
;
32 }CDirectSoundCaptureBufferImpl
, *LPCDirectSoundCaptureBufferImpl
;
36 IDirectSoundCaptureBufferImpl_QueryInterface(
37 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
42 LPCDirectSoundCaptureBufferImpl This
= (LPCDirectSoundCaptureBufferImpl
)CONTAINING_RECORD(iface
, CDirectSoundCaptureBufferImpl
, lpVtbl
);
44 /* check if requested interface is supported */
45 if (IsEqualIID(riid
, &IID_IUnknown
) ||
46 IsEqualIID(riid
, &IID_IDirectSoundCaptureBuffer
) ||
47 IsEqualIID(riid
, &IID_IDirectSoundCaptureBuffer8
))
49 *ppobj
= (LPVOID
)&This
->lpVtbl
;
50 InterlockedIncrement(&This
->ref
);
54 /* interface not supported */
55 if (SUCCEEDED(StringFromIID(riid
, &pStr
)))
57 DPRINT("No Interface for class %s\n", pStr
);
65 IDirectSoundCaptureBufferImpl_AddRef(
66 LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
69 LPCDirectSoundCaptureBufferImpl This
= (LPCDirectSoundCaptureBufferImpl
)CONTAINING_RECORD(iface
, CDirectSoundCaptureBufferImpl
, lpVtbl
);
71 /* increment reference count */
72 ref
= InterlockedIncrement(&This
->ref
);
80 IDirectSoundCaptureBufferImpl_Release(
81 LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
84 LPCDirectSoundCaptureBufferImpl This
= (LPCDirectSoundCaptureBufferImpl
)CONTAINING_RECORD(iface
, CDirectSoundCaptureBufferImpl
, lpVtbl
);
86 /* release reference count */
87 ref
= InterlockedDecrement(&(This
->ref
));
91 /* free capture buffer */
92 HeapFree(GetProcessHeap(), 0, This
->Buffer
);
93 HeapFree(GetProcessHeap(), 0, This
->Format
);
94 HeapFree(GetProcessHeap(), 0, This
);
103 IDirectSoundCaptureBufferImpl_GetCaps(
104 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
105 LPDSCBCAPS lpDSCBCaps
)
108 return DSERR_INVALIDPARAM
;
113 IDirectSoundCaptureBufferImpl_GetCurrentPosition(
114 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
115 LPDWORD lpdwCapturePosition
,
116 LPDWORD lpdwReadPosition
)
119 return DSERR_INVALIDPARAM
;
125 IDirectSoundCaptureBufferImpl_GetFormat(
126 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
127 LPWAVEFORMATEX lpwfxFormat
,
128 DWORD dwSizeAllocated
,
129 LPDWORD lpdwSizeWritten
)
132 return DSERR_INVALIDPARAM
;
137 IDirectSoundCaptureBufferImpl_GetStatus(
138 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
142 return DSERR_INVALIDPARAM
;
147 IDirectSoundCaptureBufferImpl_Initialize(
148 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
149 LPDIRECTSOUNDCAPTURE lpDSC
,
150 LPCDSCBUFFERDESC lpcDSCBDesc
)
152 /* capture buffer is already initialized */
153 return DSERR_ALREADYINITIALIZED
;
158 IDirectSoundCaptureBufferImpl_Lock(
159 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
162 LPVOID
* lplpvAudioPtr1
,
163 LPDWORD lpdwAudioBytes1
,
164 LPVOID
* lplpvAudioPtr2
,
165 LPDWORD lpdwAudioBytes2
,
169 return DSERR_INVALIDPARAM
;
174 IDirectSoundCaptureBufferImpl_Start(
175 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
179 return DSERR_INVALIDPARAM
;
184 IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
187 return DSERR_INVALIDPARAM
;
192 IDirectSoundCaptureBufferImpl_Unlock(
193 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
197 DWORD dwAudioBytes2
)
200 return DSERR_INVALIDPARAM
;
205 IDirectSoundCaptureBufferImpl_GetObjectInPath(
206 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
209 REFGUID rguidInterface
,
213 return DSERR_INVALIDPARAM
;
218 IDirectSoundCaptureBufferImpl_GetFXStatus(
219 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
221 LPDWORD pdwFXStatus
)
224 return DSERR_INVALIDPARAM
;
228 static IDirectSoundCaptureBuffer8Vtbl vt_DirectSoundCaptureBuffer8
=
230 /* IUnknown methods */
231 IDirectSoundCaptureBufferImpl_QueryInterface
,
232 IDirectSoundCaptureBufferImpl_AddRef
,
233 IDirectSoundCaptureBufferImpl_Release
,
235 /* IDirectSoundCaptureBuffer methods */
236 IDirectSoundCaptureBufferImpl_GetCaps
,
237 IDirectSoundCaptureBufferImpl_GetCurrentPosition
,
238 IDirectSoundCaptureBufferImpl_GetFormat
,
239 IDirectSoundCaptureBufferImpl_GetStatus
,
240 IDirectSoundCaptureBufferImpl_Initialize
,
241 IDirectSoundCaptureBufferImpl_Lock
,
242 IDirectSoundCaptureBufferImpl_Start
,
243 IDirectSoundCaptureBufferImpl_Stop
,
244 IDirectSoundCaptureBufferImpl_Unlock
,
246 /* IDirectSoundCaptureBuffer methods */
247 IDirectSoundCaptureBufferImpl_GetObjectInPath
,
248 IDirectSoundCaptureBufferImpl_GetFXStatus
253 NewDirectSoundCaptureBuffer(
254 LPDIRECTSOUNDCAPTUREBUFFER8
*OutBuffer
,
256 LPCDSCBUFFERDESC lpcDSBufferDesc
)
259 ULONG DeviceId
= 0, PinId
;
260 DWORD Result
= ERROR_SUCCESS
;
262 LPCDirectSoundCaptureBufferImpl This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(CDirectSoundCaptureBufferImpl
));
266 /* not enough memory */
267 return DSERR_OUTOFMEMORY
;
270 /* calculate format size */
271 FormatSize
= sizeof(WAVEFORMATEX
) + lpcDSBufferDesc
->lpwfxFormat
->cbSize
;
272 /* allocate format struct */
273 This
->Format
= HeapAlloc(GetProcessHeap(), 0, FormatSize
);
276 /* not enough memory */
277 HeapFree(GetProcessHeap(), 0, This
);
278 return DSERR_OUTOFMEMORY
;
282 ASSERT(lpcDSBufferDesc
->dwBufferBytes
);
284 /* allocate capture buffer */
285 This
->Buffer
= HeapAlloc(GetProcessHeap(), 0, lpcDSBufferDesc
->dwBufferBytes
);
288 /* not enough memory */
289 HeapFree(GetProcessHeap(), 0, This
->Format
);
290 HeapFree(GetProcessHeap(), 0, This
);
291 return DSERR_OUTOFMEMORY
;
294 /* store buffer size */
295 This
->BufferSize
= lpcDSBufferDesc
->dwBufferBytes
;
296 ASSERT(lpcDSBufferDesc
->lpwfxFormat
->cbSize
== 0);
300 /* try all available recording pins on that filter */
301 PinId
= GetPinIdFromFilter(Filter
, TRUE
, DeviceId
);
302 DPRINT("PinId %u DeviceId %u\n", PinId
, DeviceId
);
304 if (PinId
== ULONG_MAX
)
307 Result
= OpenPin(Filter
->hFilter
, PinId
, lpcDSBufferDesc
->lpwfxFormat
, &This
->hPin
, TRUE
);
308 if (Result
== ERROR_SUCCESS
)
314 if (Result
!= ERROR_SUCCESS
)
316 /* failed to instantiate the capture pin */
317 HeapFree(GetProcessHeap(), 0, This
->Buffer
);
318 HeapFree(GetProcessHeap(), 0, This
->Format
);
319 HeapFree(GetProcessHeap(), 0, This
);
320 return DSERR_OUTOFMEMORY
;
323 /* initialize capture buffer */
325 This
->lpVtbl
= &vt_DirectSoundCaptureBuffer8
;
326 This
->Filter
= Filter
;
327 This
->State
= KSSTATE_STOP
;
329 *OutBuffer
= (LPDIRECTSOUNDCAPTUREBUFFER8
)&This
->lpVtbl
;