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>
43 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
48 /*****************************************************************************
49 * Predeclare the interface implementation structures
51 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
52 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
55 /*****************************************************************************
56 * IDirectSoundCapture implementation structure
58 struct IDirectSoundCaptureImpl
61 ICOM_VFIELD(IDirectSoundCapture);
64 /* IDirectSoundCaptureImpl fields */
65 CRITICAL_SECTION lock;
68 /*****************************************************************************
69 * IDirectSoundCapture implementation structure
71 struct IDirectSoundCaptureBufferImpl
74 ICOM_VFIELD(IDirectSoundCaptureBuffer8);
77 /* IDirectSoundCaptureBufferImpl fields */
78 CRITICAL_SECTION lock;
82 static HRESULT DSOUND_CreateDirectSoundCapture( LPVOID* ppobj );
83 static HRESULT DSOUND_CreateDirectSoundCaptureBuffer( LPCDSCBUFFERDESC lpcDSCBufferDesc, LPVOID* ppobj );
85 static ICOM_VTABLE(IDirectSoundCapture) dscvt;
86 static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt;
89 /***************************************************************************
90 * DirectSoundCaptureCreate [DSOUND.6]
92 * Create and initialize a DirectSoundCapture interface
96 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
99 HRESULT WINAPI DirectSoundCaptureCreate8(
101 LPDIRECTSOUNDCAPTURE* lplpDSC,
102 LPUNKNOWN pUnkOuter )
104 TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), lplpDSC, pUnkOuter);
107 return DSERR_NOAGGREGATION;
110 /* Default device? */
112 IsEqualGUID(lpcGUID, &DSDEVID_DefaultCapture) ||
113 IsEqualGUID(lpcGUID, &DSDEVID_DefaultVoiceCapture) ) {
114 return DSOUND_CreateDirectSoundCapture( (LPVOID*)lplpDSC );
117 FIXME( "Unknown GUID %s\n", debugstr_guid(lpcGUID) );
120 return DSERR_OUTOFMEMORY;
123 /***************************************************************************
124 * DirectSoundCaptureEnumerateA [DSOUND.7]
126 * Enumerate all DirectSound drivers installed in the system
130 * Failure: DSERR_INVALIDPARAM
132 HRESULT WINAPI DirectSoundCaptureEnumerateA(
133 LPDSENUMCALLBACKA lpDSEnumCallback,
136 TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
138 if ( lpDSEnumCallback )
139 lpDSEnumCallback(NULL,"WINE Primary Sound Capture Driver",
140 "SoundCap",lpContext);
146 /***************************************************************************
147 * DirectSoundCaptureEnumerateW [DSOUND.8]
149 * Enumerate all DirectSound drivers installed in the system
153 * Failure: DSERR_INVALIDPARAM
155 HRESULT WINAPI DirectSoundCaptureEnumerateW(
156 LPDSENUMCALLBACKW lpDSEnumCallback,
159 FIXME("(%p,%p):stub\n", lpDSEnumCallback, lpContext );
164 DSOUND_CreateDirectSoundCapture( LPVOID* ppobj )
166 *ppobj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( IDirectSoundCaptureImpl ) );
168 if ( *ppobj == NULL ) {
169 return DSERR_OUTOFMEMORY;
173 ICOM_THIS(IDirectSoundCaptureImpl,*ppobj);
176 ICOM_VTBL(This) = &dscvt;
178 InitializeCriticalSection( &This->lock );
184 static HRESULT WINAPI
185 IDirectSoundCaptureImpl_QueryInterface(
186 LPDIRECTSOUNDCAPTURE iface,
190 ICOM_THIS(IDirectSoundCaptureImpl,iface);
192 FIXME( "(%p)->(%s,%p): stub\n", This, debugstr_guid(riid), ppobj );
198 IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
201 ICOM_THIS(IDirectSoundCaptureImpl,iface);
203 EnterCriticalSection( &This->lock );
205 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
206 uRef = ++(This->ref);
208 LeaveCriticalSection( &This->lock );
214 IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
217 ICOM_THIS(IDirectSoundCaptureImpl,iface);
219 EnterCriticalSection( &This->lock );
221 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
222 uRef = --(This->ref);
224 LeaveCriticalSection( &This->lock );
227 DeleteCriticalSection( &This->lock );
228 HeapFree( GetProcessHeap(), 0, This );
234 static HRESULT WINAPI
235 IDirectSoundCaptureImpl_CreateCaptureBuffer(
236 LPDIRECTSOUNDCAPTURE iface,
237 LPCDSCBUFFERDESC lpcDSCBufferDesc,
238 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
242 ICOM_THIS(IDirectSoundCaptureImpl,iface);
244 TRACE( "(%p)->(%p,%p,%p)\n", This, lpcDSCBufferDesc, lplpDSCaptureBuffer, pUnk );
247 return DSERR_INVALIDPARAM;
250 hr = DSOUND_CreateDirectSoundCaptureBuffer( lpcDSCBufferDesc, (LPVOID*)lplpDSCaptureBuffer );
255 static HRESULT WINAPI
256 IDirectSoundCaptureImpl_GetCaps(
257 LPDIRECTSOUNDCAPTURE iface,
258 LPDSCCAPS lpDSCCaps )
260 ICOM_THIS(IDirectSoundCaptureImpl,iface);
262 FIXME( "(%p)->(%p): stub\n", This, lpDSCCaps );
267 static HRESULT WINAPI
268 IDirectSoundCaptureImpl_Initialize(
269 LPDIRECTSOUNDCAPTURE iface,
272 ICOM_THIS(IDirectSoundCaptureImpl,iface);
274 FIXME( "(%p)->(%p): stub\n", This, lpcGUID );
280 static ICOM_VTABLE(IDirectSoundCapture) dscvt =
282 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
283 /* IUnknown methods */
284 IDirectSoundCaptureImpl_QueryInterface,
285 IDirectSoundCaptureImpl_AddRef,
286 IDirectSoundCaptureImpl_Release,
288 /* IDirectSoundCapture methods */
289 IDirectSoundCaptureImpl_CreateCaptureBuffer,
290 IDirectSoundCaptureImpl_GetCaps,
291 IDirectSoundCaptureImpl_Initialize
295 DSOUND_CreateDirectSoundCaptureBuffer( LPCDSCBUFFERDESC lpcDSCBufferDesc, LPVOID* ppobj )
298 FIXME( "(%p,%p): ignoring lpcDSCBufferDesc\n", lpcDSCBufferDesc, ppobj );
300 *ppobj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( IDirectSoundCaptureBufferImpl ) );
302 if ( *ppobj == NULL ) {
303 return DSERR_OUTOFMEMORY;
307 ICOM_THIS(IDirectSoundCaptureBufferImpl,*ppobj);
310 ICOM_VTBL(This) = &dscbvt;
312 InitializeCriticalSection( &This->lock );
319 static HRESULT WINAPI
320 IDirectSoundCaptureBufferImpl_QueryInterface(
321 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
325 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
327 FIXME( "(%p)->(%s,%p): stub\n", This, debugstr_guid(riid), ppobj );
333 IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
336 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
338 EnterCriticalSection( &This->lock );
340 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
341 uRef = ++(This->ref);
343 LeaveCriticalSection( &This->lock );
349 IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
352 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
354 EnterCriticalSection( &This->lock );
356 TRACE( "(%p) was 0x%08lx\n", This, This->ref );
357 uRef = --(This->ref);
359 LeaveCriticalSection( &This->lock );
362 DeleteCriticalSection( &This->lock );
363 HeapFree( GetProcessHeap(), 0, This );
369 static HRESULT WINAPI
370 IDirectSoundCaptureBufferImpl_GetCaps(
371 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
372 LPDSCBCAPS lpDSCBCaps )
374 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
376 FIXME( "(%p)->(%p): stub\n", This, lpDSCBCaps );
381 static HRESULT WINAPI
382 IDirectSoundCaptureBufferImpl_GetCurrentPosition(
383 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
384 LPDWORD lpdwCapturePosition,
385 LPDWORD lpdwReadPosition )
387 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
389 FIXME( "(%p)->(%p,%p): stub\n", This, lpdwCapturePosition, lpdwReadPosition );
394 static HRESULT WINAPI
395 IDirectSoundCaptureBufferImpl_GetFormat(
396 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
397 LPWAVEFORMATEX lpwfxFormat,
398 DWORD dwSizeAllocated,
399 LPDWORD lpdwSizeWritten )
401 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
403 FIXME( "(%p)->(%p,0x%08lx,%p): stub\n", This, lpwfxFormat, dwSizeAllocated, lpdwSizeWritten );
408 static HRESULT WINAPI
409 IDirectSoundCaptureBufferImpl_GetStatus(
410 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
413 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
415 FIXME( "(%p)->(%p): stub\n", This, lpdwStatus );
420 static HRESULT WINAPI
421 IDirectSoundCaptureBufferImpl_Initialize(
422 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
423 LPDIRECTSOUNDCAPTURE lpDSC,
424 LPCDSCBUFFERDESC lpcDSCBDesc )
426 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
428 FIXME( "(%p)->(%p,%p): stub\n", This, lpDSC, lpcDSCBDesc );
433 static HRESULT WINAPI
434 IDirectSoundCaptureBufferImpl_Lock(
435 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
438 LPVOID* lplpvAudioPtr1,
439 LPDWORD lpdwAudioBytes1,
440 LPVOID* lplpvAudioPtr2,
441 LPDWORD lpdwAudioBytes2,
444 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
446 FIXME( "(%p)->(%08lu,%08lu,%p,%p,%p,%p,0x%08lx): stub\n", This, dwReadCusor, dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2, lpdwAudioBytes2, dwFlags );
451 static HRESULT WINAPI
452 IDirectSoundCaptureBufferImpl_Start(
453 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
456 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
458 FIXME( "(%p)->(0x%08lx): stub\n", This, dwFlags );
463 static HRESULT WINAPI
464 IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
466 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
468 FIXME( "(%p): stub\n", This );
473 static HRESULT WINAPI
474 IDirectSoundCaptureBufferImpl_Unlock(
475 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
479 DWORD dwAudioBytes2 )
481 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
483 FIXME( "(%p)->(%p,%08lu,%p,%08lu): stub\n", This, lpvAudioPtr1, dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2 );
488 static HRESULT WINAPI
489 IDirectSoundCaptureBufferImpl_GetObjectInPath(
490 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
493 REFGUID rguidInterface,
496 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
498 FIXME( "(%p)->(%s,%lu,%s,%p): stub\n", This, debugstr_guid(rguidObject), dwIndex, debugstr_guid(rguidInterface), ppObject );
503 static HRESULT WINAPI
504 IDirectSoundCaptureBufferImpl_GetFXStatus(
505 LPDIRECTSOUNDCAPTUREBUFFER8 iface,
507 LPDWORD pdwFXStatus )
509 ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
511 FIXME( "(%p)->(%lu,%p): stub\n", This, dwFXCount, pdwFXStatus );
517 static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt =
519 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
520 /* IUnknown methods */
521 IDirectSoundCaptureBufferImpl_QueryInterface,
522 IDirectSoundCaptureBufferImpl_AddRef,
523 IDirectSoundCaptureBufferImpl_Release,
525 /* IDirectSoundCaptureBuffer methods */
526 IDirectSoundCaptureBufferImpl_GetCaps,
527 IDirectSoundCaptureBufferImpl_GetCurrentPosition,
528 IDirectSoundCaptureBufferImpl_GetFormat,
529 IDirectSoundCaptureBufferImpl_GetStatus,
530 IDirectSoundCaptureBufferImpl_Initialize,
531 IDirectSoundCaptureBufferImpl_Lock,
532 IDirectSoundCaptureBufferImpl_Start,
533 IDirectSoundCaptureBufferImpl_Stop,
534 IDirectSoundCaptureBufferImpl_Unlock,
536 /* IDirectSoundCaptureBuffer methods */
537 IDirectSoundCaptureBufferImpl_GetObjectInPath,
538 IDirectSoundCaptureBufferImpl_GetFXStatus