ReactOS 0.4.15-dev-7897-g78dc504
capture.c File Reference
#include "precomp.h"
Include dependency graph for capture.c:

Go to the source code of this file.

Classes

struct  CDirectSoundCaptureImpl
 

Typedefs

typedef struct CDirectSoundCaptureImplLPCDirectSoundCaptureImpl
 

Functions

HRESULT WINAPI CDirectSoundCapture_fnQueryInterface (LPDIRECTSOUNDCAPTURE8 iface, REFIID riid, LPVOID *ppobj)
 
ULONG WINAPI CDirectSoundCapture_fnAddRef (LPDIRECTSOUNDCAPTURE8 iface)
 
ULONG WINAPI CDirectSoundCapture_fnRelease (LPDIRECTSOUNDCAPTURE8 iface)
 
HRESULT WINAPI CDirectSoundCapture_fnCreateCaptureBuffer (LPDIRECTSOUNDCAPTURE8 iface, LPCDSCBUFFERDESC lpcDSBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI CDirectSoundCapture_fnGetCaps (LPDIRECTSOUNDCAPTURE8 iface, LPDSCCAPS pDSCCaps)
 
HRESULT WINAPI CDirectSoundCapture_fnInitialize (LPDIRECTSOUNDCAPTURE8 iface, LPCGUID pcGuidDevice)
 
HRESULT InternalDirectSoundCaptureCreate (LPCGUID lpcGUID, LPDIRECTSOUNDCAPTURE8 *ppDS, IUnknown *pUnkOuter)
 
HRESULT CALLBACK NewDirectSoundCapture (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 
HRESULT WINAPI DirectSoundCaptureCreate (LPCGUID lpcGUID, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI DirectSoundCaptureCreate8 (LPCGUID lpcGUID, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter)
 

Variables

static IDirectSoundCaptureVtbl vt_DirectSoundCapture
 

Typedef Documentation

◆ LPCDirectSoundCaptureImpl

Function Documentation

◆ CDirectSoundCapture_fnAddRef()

ULONG WINAPI CDirectSoundCapture_fnAddRef ( LPDIRECTSOUNDCAPTURE8  iface)

Definition at line 51 of file capture.c.

53{
54 ULONG ref;
56
57 /* increment reference count */
59
60 return ref;
61}
#define InterlockedIncrement
Definition: armddk.h:53
struct CDirectSoundCaptureImpl * LPCDirectSoundCaptureImpl
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

◆ CDirectSoundCapture_fnCreateCaptureBuffer()

HRESULT WINAPI CDirectSoundCapture_fnCreateCaptureBuffer ( LPDIRECTSOUNDCAPTURE8  iface,
LPCDSCBUFFERDESC  lpcDSBufferDesc,
LPDIRECTSOUNDCAPTUREBUFFER ppDSCBuffer,
LPUNKNOWN  pUnkOuter 
)

Definition at line 85 of file capture.c.

90{
91 HRESULT hResult;
93
94 if (!This->bInitialized)
95 {
96 /* object not yet initialized */
98 }
99
100 if (!lpcDSBufferDesc || !ppDSCBuffer || pUnkOuter != NULL)
101 {
102 /* invalid param */
103 return DSERR_INVALIDPARAM;
104 }
105
106 /* check buffer description */
107 if ((lpcDSBufferDesc->dwSize != sizeof(DSCBUFFERDESC) && lpcDSBufferDesc->dwSize != sizeof(DSCBUFFERDESC1)) ||
108 lpcDSBufferDesc->dwReserved != 0 || lpcDSBufferDesc->dwBufferBytes == 0 || lpcDSBufferDesc->lpwfxFormat == NULL)
109 {
110 /* invalid buffer description */
111 return DSERR_INVALIDPARAM;
112 }
113
114 DPRINT("This %p wFormatTag %x nChannels %u nSamplesPerSec %u nAvgBytesPerSec %u NBlockAlign %u wBitsPerSample %u cbSize %u\n",
115 This, lpcDSBufferDesc->lpwfxFormat->wFormatTag, lpcDSBufferDesc->lpwfxFormat->nChannels, lpcDSBufferDesc->lpwfxFormat->nSamplesPerSec, lpcDSBufferDesc->lpwfxFormat->nAvgBytesPerSec, lpcDSBufferDesc->lpwfxFormat->nBlockAlign, lpcDSBufferDesc->lpwfxFormat->wBitsPerSample, lpcDSBufferDesc->lpwfxFormat->cbSize);
116
117 hResult = NewDirectSoundCaptureBuffer((LPDIRECTSOUNDCAPTUREBUFFER8*)ppDSCBuffer, This->Filter, lpcDSBufferDesc);
118 return hResult;
119}
HRESULT NewDirectSoundCaptureBuffer(LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer, LPFILTERINFO Filter, LPCDSCBUFFERDESC lpcDSBufferDesc)
#define NULL
Definition: types.h:112
#define DSERR_UNINITIALIZED
Definition: dsound.h:133
struct IDirectSoundCaptureBuffer8 * LPDIRECTSOUNDCAPTUREBUFFER8
Definition: dsound.h:100
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
#define DPRINT
Definition: sndvol32.h:71
DWORD dwBufferBytes
Definition: dsound.h:359
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
DWORD dwReserved
Definition: dsound.h:360
DWORD dwSize
Definition: dsound.h:357
WORD nBlockAlign
Definition: mmreg.h:82
WORD cbSize
Definition: mmreg.h:84
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nChannels
Definition: mmreg.h:79
WORD wFormatTag
Definition: mmreg.h:78
WORD wBitsPerSample
Definition: mmreg.h:83

◆ CDirectSoundCapture_fnGetCaps()

HRESULT WINAPI CDirectSoundCapture_fnGetCaps ( LPDIRECTSOUNDCAPTURE8  iface,
LPDSCCAPS  pDSCCaps 
)

Definition at line 124 of file capture.c.

127{
128 WAVEINCAPSW Caps;
131
132 if (!This->bInitialized)
133 {
134 /* object not yet initialized */
135 return DSERR_UNINITIALIZED;
136 }
137
138 if (!pDSCCaps)
139 {
140 /* invalid param */
141 return DSERR_INVALIDPARAM;
142 }
143
144 if (pDSCCaps->dwSize != sizeof(DSCCAPS))
145 {
146 /* invalid param */
147 return DSERR_INVALIDPARAM;
148 }
149
150
151 /* We are certified ;) */
152 pDSCCaps->dwFlags = DSCCAPS_CERTIFIED;
153
154 ASSERT(This->Filter);
155
156 Result = waveInGetDevCapsW(This->Filter->MappedId[0], &Caps, sizeof(WAVEINCAPSW));
158 {
159 /* failed */
160 DPRINT("waveInGetDevCapsW for device %u failed with %x\n", This->Filter->MappedId[0], Result);
161 return DSERR_UNSUPPORTED;
162 }
163
164 pDSCCaps->dwFormats = Caps.dwFormats;
165 pDSCCaps->dwChannels = Caps.wChannels;
166
167 return DS_OK;
168}
#define DSERR_UNSUPPORTED
Definition: dsound.h:127
#define DS_OK
Definition: dsound.h:116
#define DSCCAPS_CERTIFIED
Definition: dsound.h:386
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define ASSERT(a)
Definition: mode.c:44
DWORD dwChannels
Definition: dsound.h:372
DWORD dwSize
Definition: dsound.h:369
DWORD dwFormats
Definition: dsound.h:371
DWORD dwFlags
Definition: dsound.h:370
DWORD dwFormats
Definition: mmsystem.h:1061
UINT WINAPI waveInGetDevCapsW(UINT_PTR uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
Definition: winmm.c:2573
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ CDirectSoundCapture_fnInitialize()

HRESULT WINAPI CDirectSoundCapture_fnInitialize ( LPDIRECTSOUNDCAPTURE8  iface,
LPCGUID  pcGuidDevice 
)

Definition at line 173 of file capture.c.

176{
177 GUID DeviceGuid;
178 LPOLESTR pGuidStr;
180
181 /* sanity check */
183
184 if (This->bInitialized)
185 {
186 /* object has already been initialized */
188 }
189
190 /* fixme mutual exclusion */
191
192 if (pcGuidDevice == NULL || IsEqualGUID(pcGuidDevice, &GUID_NULL))
193 {
194 /* use default playback device id */
195 pcGuidDevice = &DSDEVID_DefaultCapture;
196 }
197
198 if (IsEqualIID(pcGuidDevice, &DSDEVID_DefaultVoicePlayback) || IsEqualIID(pcGuidDevice, &DSDEVID_DefaultPlayback))
199 {
200 /* this has to be a winetest */
201 return DSERR_NODRIVER;
202 }
203
204 /* now verify the guid */
205 if (GetDeviceID(pcGuidDevice, &DeviceGuid) != DS_OK)
206 {
207 if (SUCCEEDED(StringFromIID(pcGuidDevice, &pGuidStr)))
208 {
209 DPRINT("IDirectSound8_fnInitialize: Unknown GUID %ws\n", pGuidStr);
210 CoTaskMemFree(pGuidStr);
211 }
212 return DSERR_INVALIDPARAM;
213 }
214
215 if (FindDeviceByGuid(&DeviceGuid, &This->Filter))
216 {
217 This->bInitialized = TRUE;
218 return DS_OK;
219 }
220
221 DPRINT("Failed to find device\n");
222 return DSERR_INVALIDPARAM;
223}
#define TRUE
Definition: types.h:120
BOOL FindDeviceByGuid(LPCGUID pGuidSrc, LPFILTERINFO *Filter)
Definition: devicelist.c:470
LPFILTERINFO RootInfo
Definition: dsound.c:13
HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
Definition: dsound.c:53
#define DSERR_ALREADYINITIALIZED
Definition: dsound.h:129
#define DSERR_NODRIVER
Definition: dsound.h:128
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define GUID_NULL
Definition: ks.h:106
static LPOLESTR
Definition: stg_prop.c:27
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ CDirectSoundCapture_fnQueryInterface()

HRESULT WINAPI CDirectSoundCapture_fnQueryInterface ( LPDIRECTSOUNDCAPTURE8  iface,
REFIID  riid,
LPVOID ppobj 
)

Definition at line 23 of file capture.c.

27{
28 LPOLESTR pStr;
30
31 /* check if the interface is supported */
33 IsEqualIID(riid, &IID_IDirectSoundCapture))
34 {
35 *ppobj = (LPVOID)&This->lpVtbl;
37 return S_OK;
38 }
39
40 /* unsupported interface */
41 if (SUCCEEDED(StringFromIID(riid, &pStr)))
42 {
43 DPRINT("No Interface for class %s\n", pStr);
44 CoTaskMemFree(pStr);
45 }
46 return E_NOINTERFACE;
47}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define LPVOID
Definition: nt_native.h:45
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ CDirectSoundCapture_fnRelease()

ULONG WINAPI CDirectSoundCapture_fnRelease ( LPDIRECTSOUNDCAPTURE8  iface)

Definition at line 65 of file capture.c.

67{
68 ULONG ref;
70
71 /* release reference count */
72 ref = InterlockedDecrement(&(This->ref));
73
74 if (!ref)
75 {
77 }
78
79 return ref;
80}
#define InterlockedDecrement
Definition: armddk.h:52
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ DirectSoundCaptureCreate()

HRESULT WINAPI DirectSoundCaptureCreate ( LPCGUID  lpcGUID,
LPDIRECTSOUNDCAPTURE ppDSC,
LPUNKNOWN  pUnkOuter 
)

Definition at line 322 of file capture.c.

326{
327 return InternalDirectSoundCaptureCreate(lpcGUID, (LPDIRECTSOUNDCAPTURE8*)ppDSC, pUnkOuter);
328}
HRESULT InternalDirectSoundCaptureCreate(LPCGUID lpcGUID, LPDIRECTSOUNDCAPTURE8 *ppDS, IUnknown *pUnkOuter)
Definition: capture.c:237
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE8
Definition: dsound.h:94

◆ DirectSoundCaptureCreate8()

HRESULT WINAPI DirectSoundCaptureCreate8 ( LPCGUID  lpcGUID,
LPDIRECTSOUNDCAPTURE8 ppDSC8,
LPUNKNOWN  pUnkOuter 
)

Definition at line 332 of file capture.c.

336{
337 return InternalDirectSoundCaptureCreate(lpcGUID, ppDSC8, pUnkOuter);
338}

◆ InternalDirectSoundCaptureCreate()

HRESULT InternalDirectSoundCaptureCreate ( LPCGUID  lpcGUID,
LPDIRECTSOUNDCAPTURE8 ppDS,
IUnknown pUnkOuter 
)

Definition at line 237 of file capture.c.

241{
243 HRESULT hr;
244
245 if (!ppDS || pUnkOuter != NULL)
246 {
247 /* invalid parameter passed */
248 return DSERR_INVALIDPARAM;
249 }
250
251 /* allocate CDirectSoundCaptureImpl struct */
253 if (!This)
254 {
255 /* not enough memory */
256 return DSERR_OUTOFMEMORY;
257 }
258
259 /* initialize IDirectSoundCapture object */
260 This->ref = 1;
261 This->lpVtbl = &vt_DirectSoundCapture;
262
263
264 /* initialize direct sound interface */
266
267 /* check for success */
268 if (!SUCCEEDED(hr))
269 {
270 /* failed */
271 DPRINT("Failed to initialize DirectSoundCapture object with %x\n", hr);
273 return hr;
274 }
275
276 /* store result */
277 *ppDS = (LPDIRECTSOUNDCAPTURE8)&This->lpVtbl;
278 DPRINT("DirectSoundCapture object %p\n", *ppDS);
279 return DS_OK;
280}
static IDirectSoundCaptureVtbl vt_DirectSoundCapture
Definition: capture.c:225
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define IDirectSoundCapture_Release(p)
Definition: dsound.h:736
#define IDirectSoundCapture_Initialize(p, a)
Definition: dsound.h:740
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
struct IDirectSound8 * LPDIRECTSOUND8
Definition: dsound.h:73
HRESULT hr
Definition: shlfolder.c:183

Referenced by DirectSoundCaptureCreate(), and DirectSoundCaptureCreate8().

◆ NewDirectSoundCapture()

HRESULT CALLBACK NewDirectSoundCapture ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppvObject 
)

Definition at line 284 of file capture.c.

288{
289 LPOLESTR pStr;
291
292 /* check requested interface */
293 if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IDirectSoundCapture) && !IsEqualIID(riid, &IID_IDirectSoundCapture8))
294 {
295 *ppvObject = 0;
296 StringFromIID(riid, &pStr);
297 DPRINT("NewDirectSoundCapture does not support Interface %ws\n", pStr);
298 CoTaskMemFree(pStr);
299 return E_NOINTERFACE;
300 }
301
302 /* allocate CDirectSoundCaptureImpl struct */
304 if (!This)
305 {
306 /* not enough memory */
307 return DSERR_OUTOFMEMORY;
308 }
309
310 /* initialize object */
311 This->ref = 1;
312 This->lpVtbl = &vt_DirectSoundCapture;
313 This->bInitialized = FALSE;
314 *ppvObject = (LPVOID)&This->lpVtbl;
315
316 return S_OK;
317}
#define FALSE
Definition: types.h:117
#define IID_IDirectSoundCapture8
Definition: dsound.h:93
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082

Variable Documentation

◆ vt_DirectSoundCapture

IDirectSoundCaptureVtbl vt_DirectSoundCapture
static
Initial value:
=
{
}
HRESULT WINAPI CDirectSoundCapture_fnGetCaps(LPDIRECTSOUNDCAPTURE8 iface, LPDSCCAPS pDSCCaps)
Definition: capture.c:124
HRESULT WINAPI CDirectSoundCapture_fnQueryInterface(LPDIRECTSOUNDCAPTURE8 iface, REFIID riid, LPVOID *ppobj)
Definition: capture.c:23
HRESULT WINAPI CDirectSoundCapture_fnInitialize(LPDIRECTSOUNDCAPTURE8 iface, LPCGUID pcGuidDevice)
Definition: capture.c:173
ULONG WINAPI CDirectSoundCapture_fnAddRef(LPDIRECTSOUNDCAPTURE8 iface)
Definition: capture.c:51
ULONG WINAPI CDirectSoundCapture_fnRelease(LPDIRECTSOUNDCAPTURE8 iface)
Definition: capture.c:65
HRESULT WINAPI CDirectSoundCapture_fnCreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 iface, LPCDSCBUFFERDESC lpcDSBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter)
Definition: capture.c:85

Definition at line 225 of file capture.c.

Referenced by InternalDirectSoundCaptureCreate(), and NewDirectSoundCapture().