3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2001 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
23 * Implement DirectSoundCapture API
29 #include <sys/types.h>
30 #include <sys/fcntl.h>
41 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
46 /*****************************************************************************
47 * Predeclare the interface implementation structures
49 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
50 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
53 /*****************************************************************************
54 * IDirectSoundCapture implementation structure
56 struct IDirectSoundCaptureImpl
59 ICOM_VFIELD(IDirectSoundCapture);
62 /* IDirectSoundCaptureImpl fields */
63 CRITICAL_SECTION lock;
66 /*****************************************************************************
67 * IDirectSoundCapture implementation structure
69 struct IDirectSoundCaptureBufferImpl
72 ICOM_VFIELD(IDirectSoundCaptureBuffer8);
75 /* IDirectSoundCaptureBufferImpl fields */
76 CRITICAL_SECTION lock;
80 static HRESULT DSOUND_CreateDirectSoundCapture( LPVOID* ppobj );
81 static HRESULT DSOUND_CreateDirectSoundCaptureBuffer( LPCDSCBUFFERDESC lpcDSCBufferDesc, LPVOID* ppobj );
83 static ICOM_VTABLE(IDirectSoundCapture) dscvt;
84 static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt;
87 /***************************************************************************
88 * DirectSoundCaptureCreate [DSOUND.6]
90 * Create and initialize a DirectSoundCapture interface
94 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
97 HRESULT WINAPI DirectSoundCaptureCreate8(
99 LPDIRECTSOUNDCAPTURE* lplpDSC,
100 LPUNKNOWN pUnkOuter )
102 TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), lplpDSC, pUnkOuter);
105 return DSERR_NOAGGREGATION;
108 /* Default device? */
110 IsEqualGUID(lpcGUID, &DSDEVID_DefaultCapture) ||
111 IsEqualGUID(lpcGUID, &DSDEVID_DefaultVoiceCapture) ) {
112 return DSOUND_CreateDirectSoundCapture( (LPVOID*)lplpDSC );
115 FIXME( "Unknown GUID %s\n", debugstr_guid(lpcGUID) );
118 return DSERR_OUTOFMEMORY;
121 /***************************************************************************
122 * DirectSoundCaptureEnumerateA [DSOUND.7]
124 * Enumerate all DirectSound drivers installed in the system
128 * Failure: DSERR_INVALIDPARAM
130 HRESULT WINAPI DirectSoundCaptureEnumerateA(
131 LPDSENUMCALLBACKA lpDSEnumCallback,
134 TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
136 if ( lpDSEnumCallback )
137 lpDSEnumCallback(NULL,"WINE Primary Sound Capture Driver",
138 "SoundCap",lpContext);
144 /***************************************************************************
145 * DirectSoundCaptureEnumerateW [DSOUND.8]
147 * Enumerate all DirectSound drivers installed in the system
151 * Failure: DSERR_INVALIDPARAM
153 HRESULT WINAPI DirectSoundCaptureEnumerateW(
154 LPDSENUMCALLBACKW lpDSEnumCallback,
157 FIXME("(%p,%p):stub\n", lpDSEnumCallback, lpContext );
162 DSOUND_CreateDirectSoundCapture( LPVOID* ppobj )
164 *ppobj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( IDirectSoundCaptureImpl ) );
166 if ( *ppobj == NULL ) {
167 return DSERR_OUTOFMEMORY;
171 ICOM_THIS(IDirectSoundCaptureImpl,*ppobj);
174 ICOM_VTBL(This) = &dscvt;
176 InitializeCriticalSection( &This->lock );
182 static HRESULT WINAPI
183 IDirectSoundCaptureImpl_QueryInterface(
184 LPDIRECTSOUNDCAPTURE iface,
188 ICOM_THIS(IDirectSoundCaptureImpl,iface);
190 FIXME( "(%p)->(%s,%p): stub\n", This, debugstr_guid(riid), ppobj );
196 IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
199 ICOM_THIS(IDirectSoundCaptureImpl,iface);
201 EnterCriticalSection( &This->lock );
203 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
204 uRef = ++(This->ref);
206 LeaveCriticalSection( &This->lock );
212 IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
215 ICOM_THIS(IDirectSoundCaptureImpl,iface);
217 EnterCriticalSection( &This->lock );
219 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
220 uRef = --(This->ref);
222 LeaveCriticalSection( &This->lock );
225 DeleteCriticalSection( &This->lock );
226 HeapFree( GetProcessHeap(), 0, This );
232 static HRESULT WINAPI
233 IDirectSoundCaptureImpl_CreateCaptureBuffer(
234 LPDIRECTSOUNDCAPTURE iface,
235 LPCDSCBUFFERDESC lpcDSCBufferDesc,
236 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
240 ICOM_THIS(IDirectSoundCaptureImpl,iface);
242 TRACE( "(%p)->(%p,%p,%p)\n", This, lpcDSCBufferDesc, lplpDSCaptureBuffer, pUnk );
245 return DSERR_INVALIDPARAM;
248 hr = DSOUND_CreateDirectSoundCaptureBuffer( lpcDSCBufferDesc, (LPVOID*)lplpDSCaptureBuffer );
253 static HRESULT WINAPI
254 IDirectSoundCaptureImpl_GetCaps(
255 LPDIRECTSOUNDCAPTURE iface,
256 LPDSCCAPS lpDSCCaps )
258 ICOM_THIS(IDirectSoundCaptureImpl,iface);
260 FIXME( "(%p)->(%p): stub\n", This, lpDSCCaps );
265 static HRESULT WINAPI
266 IDirectSoundCaptureImpl_Initialize(
267 LPDIRECTSOUNDCAPTURE iface,
270 ICOM_THIS(IDirectSoundCaptureImpl,iface);
272 FIXME( "(%p)->(%p): stub\n", This, lpcGUID );
278 static ICOM_VTABLE(IDirectSoundCapture) dscvt =
280 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
281 /* IUnknown methods */
282 IDirectSoundCaptureImpl_QueryInterface,
283 IDirectSoundCaptureImpl_AddRef,
284 IDirectSoundCaptureImpl_Release,
286 /* IDirectSoundCapture methods */
287 IDirectSoundCaptureImpl_CreateCaptureBuffer,
288 IDirectSoundCaptureImpl_GetCaps,
289 IDirectSoundCaptureImpl_Initialize
293 DSOUND_CreateDirectSoundCaptureBuffer( LPCDSCBUFFERDESC lpcDSCBufferDesc, LPVOID* ppobj )
296 FIXME( "(%p,%p): ignoring lpcDSCBufferDesc\n", lpcDSCBufferDesc, ppobj );
298 *ppobj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( IDirectSoundCaptureBufferImpl ) );
300 if ( *ppobj == NULL ) {
301 return DSERR_OUTOFMEMORY;
305 ICOM_THIS(IDirectSoundCaptureBufferImpl,*ppobj);
308 ICOM_VTBL(This) = &dscbvt;
310 InitializeCriticalSection( &This->lock );
317 static HRESULT WINAPI
318 IDirectSoundCaptureBufferImpl_QueryInterface(
319 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
323 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
325 FIXME( "(%p)->(%s,%p): stub\n", This, debugstr_guid(riid), ppobj );
331 IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
334 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
336 EnterCriticalSection( &This->lock );
338 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
339 uRef = ++(This->ref);
341 LeaveCriticalSection( &This->lock );
347 IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
350 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
352 EnterCriticalSection( &This->lock );
354 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
355 uRef = --(This->ref);
357 LeaveCriticalSection( &This->lock );
360 DeleteCriticalSection( &This->lock );
361 HeapFree( GetProcessHeap(), 0, This );
367 static HRESULT WINAPI
368 IDirectSoundCaptureBufferImpl_GetCaps(
369 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
370 LPDSCBCAPS lpDSCBCaps )
372 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
374 FIXME( "(%p)->(%p): stub\n", This, lpDSCBCaps );
379 static HRESULT WINAPI
380 IDirectSoundCaptureBufferImpl_GetCurrentPosition(
381 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
382 LPDWORD lpdwCapturePosition,
383 LPDWORD lpdwReadPosition )
385 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
387 FIXME( "(%p)->(%p,%p): stub\n", This, lpdwCapturePosition, lpdwReadPosition );
392 static HRESULT WINAPI
393 IDirectSoundCaptureBufferImpl_GetFormat(
394 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
395 LPWAVEFORMATEX lpwfxFormat,
396 DWORD dwSizeAllocated,
397 LPDWORD lpdwSizeWritten )
399 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
401 FIXME( "(%p)->(%p,0x%08lx,%p): stub\n", This, lpwfxFormat, dwSizeAllocated, lpdwSizeWritten );
406 static HRESULT WINAPI
407 IDirectSoundCaptureBufferImpl_GetStatus(
408 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
411 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
413 FIXME( "(%p)->(%p): stub\n", This, lpdwStatus );
418 static HRESULT WINAPI
419 IDirectSoundCaptureBufferImpl_Initialize(
420 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
421 LPDIRECTSOUNDCAPTURE lpDSC,
422 LPCDSCBUFFERDESC lpcDSCBDesc )
424 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
426 FIXME( "(%p)->(%p,%p): stub\n", This, lpDSC, lpcDSCBDesc );
431 static HRESULT WINAPI
432 IDirectSoundCaptureBufferImpl_Lock(
433 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
436 LPVOID* lplpvAudioPtr1,
437 LPDWORD lpdwAudioBytes1,
438 LPVOID* lplpvAudioPtr2,
439 LPDWORD lpdwAudioBytes2,
442 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
444 FIXME( "(%p)->(%08lu,%08lu,%p,%p,%p,%p,0x%08lx): stub\n", This, dwReadCusor, dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2, lpdwAudioBytes2, dwFlags );
449 static HRESULT WINAPI
450 IDirectSoundCaptureBufferImpl_Start(
451 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
454 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
456 FIXME( "(%p)->(0x%08lx): stub\n", This, dwFlags );
461 static HRESULT WINAPI
462 IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
464 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
466 FIXME( "(%p): stub\n", This );
471 static HRESULT WINAPI
472 IDirectSoundCaptureBufferImpl_Unlock(
473 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
477 DWORD dwAudioBytes2 )
479 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
481 FIXME( "(%p)->(%p,%08lu,%p,%08lu): stub\n", This, lpvAudioPtr1, dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2 );
486 static HRESULT WINAPI
487 IDirectSoundCaptureBufferImpl_GetObjectInPath(
488 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
491 REFGUID rguidInterface,
494 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
496 FIXME( "(%p)->(%s,%lu,%s,%p): stub\n", This, debugstr_guid(rguidObject), dwIndex, debugstr_guid(rguidInterface), ppObject );
501 static HRESULT WINAPI
502 IDirectSoundCaptureBufferImpl_GetFXStatus(
503 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
505 LPDWORD pdwFXStatus )
507 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
509 FIXME( "(%p)->(%lu,%p): stub\n", This, dwFXCount, pdwFXStatus );
515 static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt =
517 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
518 /* IUnknown methods */
519 IDirectSoundCaptureBufferImpl_QueryInterface,
520 IDirectSoundCaptureBufferImpl_AddRef,
521 IDirectSoundCaptureBufferImpl_Release,
523 /* IDirectSoundCaptureBuffer methods */
524 IDirectSoundCaptureBufferImpl_GetCaps,
525 IDirectSoundCaptureBufferImpl_GetCurrentPosition,
526 IDirectSoundCaptureBufferImpl_GetFormat,
527 IDirectSoundCaptureBufferImpl_GetStatus,
528 IDirectSoundCaptureBufferImpl_Initialize,
529 IDirectSoundCaptureBufferImpl_Lock,
530 IDirectSoundCaptureBufferImpl_Start,
531 IDirectSoundCaptureBufferImpl_Stop,
532 IDirectSoundCaptureBufferImpl_Unlock,
534 /* IDirectSoundCaptureBuffer methods */
535 IDirectSoundCaptureBufferImpl_GetObjectInPath,
536 IDirectSoundCaptureBufferImpl_GetFXStatus