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 DirectSoundFullDuplex support.
24 * Implement FX support.
31 #include <sys/types.h>
32 #include <sys/fcntl.h>
49 #include "wine/debug.h"
52 #include "dsound_private.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
56 static HRESULT WINAPI
IDirectSoundCaptureImpl_Initialize(
57 LPDIRECTSOUNDCAPTURE iface
,
59 static ULONG WINAPI
IDirectSoundCaptureImpl_Release(
60 LPDIRECTSOUNDCAPTURE iface
);
61 static ULONG WINAPI
IDirectSoundCaptureBufferImpl_Release(
62 LPDIRECTSOUNDCAPTUREBUFFER8 iface
);
63 static HRESULT
DSOUND_CreateDirectSoundCaptureBuffer(
64 IDirectSoundCaptureImpl
*ipDSC
,
65 LPCDSCBUFFERDESC lpcDSCBufferDesc
,
67 static HRESULT WINAPI
IDirectSoundFullDuplexImpl_Initialize(
68 LPDIRECTSOUNDFULLDUPLEX iface
,
70 LPCGUID pRendererGuid
,
71 LPCDSCBUFFERDESC lpDscBufferDesc
,
72 LPCDSBUFFERDESC lpDsBufferDesc
,
75 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8
,
76 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8
);
78 static ICOM_VTABLE(IDirectSoundCapture
) dscvt
;
79 static ICOM_VTABLE(IDirectSoundCaptureBuffer8
) dscbvt
;
80 static ICOM_VTABLE(IDirectSoundFullDuplex
) dsfdvt
;
82 static IDirectSoundCaptureImpl
* dsound_capture
= NULL
;
84 static const char * captureStateString
[] = {
91 /***************************************************************************
92 * DirectSoundCaptureCreate [DSOUND.6]
94 * Create and initialize a DirectSoundCapture interface.
97 * lpcGUID [I] Address of the GUID that identifies the sound capture device.
98 * lplpDSC [O] Address of a variable to receive the interface pointer.
99 * pUnkOuter [I] Must be NULL.
103 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
107 * lpcGUID must be one of the values returned from DirectSoundCaptureEnumerate
108 * or NULL for the default device or DSDEVID_DefaultCapture or
109 * DSDEVID_DefaultVoiceCapture.
111 * DSERR_ALLOCATED is returned for sound devices that do not support full duplex.
114 DirectSoundCaptureCreate8(
116 LPDIRECTSOUNDCAPTURE
* lplpDSC
,
117 LPUNKNOWN pUnkOuter
)
119 IDirectSoundCaptureImpl
** ippDSC
=(IDirectSoundCaptureImpl
**)lplpDSC
;
120 TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID
), lplpDSC
, pUnkOuter
);
123 WARN("invalid parameter: pUnkOuter != NULL\n");
124 return DSERR_NOAGGREGATION
;
128 WARN("invalid parameter: lplpDSC == NULL\n");
129 return DSERR_INVALIDPARAM
;
132 /* Default device? */
133 if ( !lpcGUID
|| IsEqualGUID(lpcGUID
, &GUID_NULL
) )
134 lpcGUID
= &DSDEVID_DefaultCapture
;
136 *ippDSC
= (IDirectSoundCaptureImpl
*)HeapAlloc(GetProcessHeap(),
137 HEAP_ZERO_MEMORY
, sizeof(IDirectSoundCaptureImpl
));
139 if (*ippDSC
== NULL
) {
140 WARN("out of memory\n");
141 return DSERR_OUTOFMEMORY
;
143 ICOM_THIS(IDirectSoundCaptureImpl
, *ippDSC
);
146 This
->state
= STATE_STOPPED
;
148 InitializeCriticalSection( &(This
->lock
) );
150 This
->lpVtbl
= &dscvt
;
151 dsound_capture
= This
;
153 if (GetDeviceID(lpcGUID
, &This
->guid
) == DS_OK
) {
155 hres
= IDirectSoundCaptureImpl_Initialize( (LPDIRECTSOUNDCAPTURE
)This
, &This
->guid
);
157 WARN("IDirectSoundCaptureImpl_Initialize failed\n");
161 WARN("invalid GUID: %s\n", debugstr_guid(lpcGUID
));
162 return DSERR_INVALIDPARAM
;
165 /***************************************************************************
166 * DirectSoundCaptureEnumerateA [DSOUND.7]
168 * Enumerate all DirectSound drivers installed in the system.
171 * lpDSEnumCallback [I] Address of callback function.
172 * lpContext [I] Address of user defined context passed to callback function.
176 * Failure: DSERR_INVALIDPARAM
179 DirectSoundCaptureEnumerateA(
180 LPDSENUMCALLBACKA lpDSEnumCallback
,
188 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
190 if (lpDSEnumCallback
== NULL
) {
191 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
192 return DSERR_INVALIDPARAM
;
195 devs
= waveInGetNumDevs();
197 if (GetDeviceID(&DSDEVID_DefaultCapture
, &guid
) == DS_OK
) {
199 for (wid
= 0; wid
< devs
; ++wid
) {
200 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDGUID
,(DWORD
)&temp
,0));
202 if (IsEqualGUID( &guid
, &temp
) ) {
203 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD
)&desc
,0));
205 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
206 "Primary Sound Capture Driver",desc
.szDrvName
,lpContext
);
207 if (lpDSEnumCallback(NULL
, "Primary Sound Capture Driver", desc
.szDrvName
, lpContext
) == FALSE
)
216 for (wid
= 0; wid
< devs
; ++wid
) {
217 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD
)&desc
,0));
219 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDGUID
,(DWORD
)&guid
,0));
221 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
222 debugstr_guid(&guid
),desc
.szDesc
,desc
.szDrvName
,lpContext
);
223 if (lpDSEnumCallback(&guid
, desc
.szDesc
, desc
.szDrvName
, lpContext
) == FALSE
)
232 /***************************************************************************
233 * DirectSoundCaptureEnumerateW [DSOUND.8]
235 * Enumerate all DirectSound drivers installed in the system.
238 * lpDSEnumCallback [I] Address of callback function.
239 * lpContext [I] Address of user defined context passed to callback function.
243 * Failure: DSERR_INVALIDPARAM
246 DirectSoundCaptureEnumerateW(
247 LPDSENUMCALLBACKW lpDSEnumCallback
,
254 WCHAR wDesc
[MAXPNAMELEN
];
255 WCHAR wName
[MAXPNAMELEN
];
257 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
259 if (lpDSEnumCallback
== NULL
) {
260 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
261 return DSERR_INVALIDPARAM
;
264 devs
= waveInGetNumDevs();
266 if (GetDeviceID(&DSDEVID_DefaultCapture
, &guid
) == DS_OK
) {
268 for (wid
= 0; wid
< devs
; ++wid
) {
269 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDGUID
,(DWORD
)&temp
,0));
271 if (IsEqualGUID( &guid
, &temp
) ) {
272 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD
)&desc
,0));
274 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
275 "Primary Sound Capture Driver",desc
.szDrvName
,lpContext
);
276 MultiByteToWideChar( CP_ACP
, 0, "Primary Sound Capture Driver", -1,
277 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
278 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvName
, -1,
279 wName
, sizeof(wName
)/sizeof(WCHAR
) );
280 if (lpDSEnumCallback(NULL
, wDesc
, wName
, lpContext
) == FALSE
)
289 for (wid
= 0; wid
< devs
; ++wid
) {
290 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDDESC
,(DWORD
)&desc
,0));
292 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDGUID
,(DWORD
)&guid
,0));
294 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
295 debugstr_guid(&DSDEVID_DefaultCapture
),desc
.szDesc
,desc
.szDrvName
,lpContext
);
296 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1,
297 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
298 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvName
, -1,
299 wName
, sizeof(wName
)/sizeof(WCHAR
) );
300 if (lpDSEnumCallback((LPGUID
)&DSDEVID_DefaultCapture
, wDesc
, wName
, lpContext
) == FALSE
)
310 DSOUND_capture_callback(
317 IDirectSoundCaptureImpl
* This
= (IDirectSoundCaptureImpl
*)dwUser
;
318 TRACE("(%p,%08x(%s),%08lx,%08lx,%08lx) entering at %ld\n",hwi
,msg
,
319 msg
== MM_WIM_OPEN
? "MM_WIM_OPEN" : msg
== MM_WIM_CLOSE
? "MM_WIM_CLOSE" :
320 msg
== MM_WIM_DATA
? "MM_WIM_DATA" : "UNKNOWN",dwUser
,dw1
,dw2
,GetTickCount());
322 if (msg
== MM_WIM_DATA
) {
323 LPWAVEHDR pHdr
= (LPWAVEHDR
)dw1
;
324 EnterCriticalSection( &(This
->lock
) );
325 TRACE("DirectSoundCapture msg=MM_WIM_DATA, old This->state=%s, old This->index=%d\n",
326 captureStateString
[This
->state
],This
->index
);
327 if (This
->state
!= STATE_STOPPED
) {
328 int index
= This
->index
;
329 if (This
->state
== STATE_STARTING
) {
330 This
->read_position
= pHdr
->dwBytesRecorded
;
331 This
->state
= STATE_CAPTURING
;
333 waveInUnprepareHeader(hwi
,&(This
->pwave
[This
->index
]),sizeof(WAVEHDR
));
334 if (This
->capture_buffer
->nrofnotifies
)
335 SetEvent(This
->capture_buffer
->notifies
[This
->index
].hEventNotify
);
336 This
->index
= (This
->index
+ 1) % This
->nrofpwaves
;
337 if ( (This
->index
== 0) && !(This
->capture_buffer
->flags
& DSCBSTART_LOOPING
) ) {
338 TRACE("end of buffer\n");
339 This
->state
= STATE_STOPPED
;
341 if (This
->state
== STATE_CAPTURING
) {
342 waveInPrepareHeader(hwi
,&(This
->pwave
[index
]),sizeof(WAVEHDR
));
343 waveInAddBuffer(hwi
, &(This
->pwave
[index
]), sizeof(WAVEHDR
));
344 } else if (This
->state
== STATE_STOPPING
) {
346 This
->state
= STATE_STOPPED
;
350 TRACE("DirectSoundCapture new This->state=%s, new This->index=%d\n",
351 captureStateString
[This
->state
],This
->index
);
352 LeaveCriticalSection( &(This
->lock
) );
355 TRACE("completed\n");
358 static HRESULT WINAPI
359 IDirectSoundCaptureImpl_QueryInterface(
360 LPDIRECTSOUNDCAPTURE iface
,
364 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
365 TRACE( "(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
368 WARN("invalid parameter\n");
376 hres
= IDsCaptureDriver_QueryInterface(This
->driver
, riid
, ppobj
);
378 WARN("IDsCaptureDriver_QueryInterface failed\n");
382 WARN("unsupported riid: %s\n", debugstr_guid(riid
));
387 IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface
)
390 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
391 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
393 EnterCriticalSection( &(This
->lock
) );
394 uRef
= ++(This
->ref
);
397 IDsCaptureDriver_AddRef(This
->driver
);
399 LeaveCriticalSection( &(This
->lock
) );
405 IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface
)
408 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
409 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
411 EnterCriticalSection( &(This
->lock
) );
413 uRef
= --(This
->ref
);
415 LeaveCriticalSection( &(This
->lock
) );
418 TRACE("deleting object\n");
420 IDsCaptureDriver_Close(This
->driver
);
421 IDsCaptureDriver_Release(This
->driver
);
424 if (This
->capture_buffer
)
425 IDirectSoundCaptureBufferImpl_Release(
426 (LPDIRECTSOUNDCAPTUREBUFFER8
) This
->capture_buffer
);
429 HeapFree(GetProcessHeap(), 0, This
->pwfx
);
431 DeleteCriticalSection( &(This
->lock
) );
432 HeapFree( GetProcessHeap(), 0, This
);
433 dsound_capture
= NULL
;
434 TRACE("(%p) released\n",This
);
440 static HRESULT WINAPI
441 IDirectSoundCaptureImpl_CreateCaptureBuffer(
442 LPDIRECTSOUNDCAPTURE iface
,
443 LPCDSCBUFFERDESC lpcDSCBufferDesc
,
444 LPDIRECTSOUNDCAPTUREBUFFER
* lplpDSCaptureBuffer
,
448 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
450 TRACE( "(%p,%p,%p,%p)\n",This
,lpcDSCBufferDesc
,lplpDSCaptureBuffer
,pUnk
);
453 WARN("invalid parameter: This == NULL\n");
454 return DSERR_INVALIDPARAM
;
457 if (lpcDSCBufferDesc
== NULL
) {
458 WARN("invalid parameter: lpcDSCBufferDesc == NULL)\n");
459 return DSERR_INVALIDPARAM
;
462 if (lplpDSCaptureBuffer
== NULL
) {
463 WARN("invalid parameter: lplpDSCaptureBuffer == NULL\n");
464 return DSERR_INVALIDPARAM
;
468 WARN("invalid parameter: pUnk != NULL\n");
469 return DSERR_INVALIDPARAM
;
472 /* FIXME: We can only have one buffer so what do we do here? */
473 if (This
->capture_buffer
) {
474 WARN("lnvalid parameter: already has buffer\n");
475 return DSERR_INVALIDPARAM
; /* DSERR_GENERIC ? */
478 hr
= DSOUND_CreateDirectSoundCaptureBuffer( This
, lpcDSCBufferDesc
,
479 (LPVOID
*)lplpDSCaptureBuffer
);
482 WARN("DSOUND_CreateDirectSoundCaptureBuffer failed\n");
487 static HRESULT WINAPI
488 IDirectSoundCaptureImpl_GetCaps(
489 LPDIRECTSOUNDCAPTURE iface
,
490 LPDSCCAPS lpDSCCaps
)
492 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
493 TRACE("(%p,%p)\n",This
,lpDSCCaps
);
495 if (lpDSCCaps
== NULL
) {
496 WARN("invalid parameter: lpDSCCaps== NULL\n");
497 return DSERR_INVALIDPARAM
;
500 if (lpDSCCaps
->dwSize
< sizeof(*lpDSCCaps
)) {
501 WARN("invalid parameter: lpDSCCaps->dwSize = %ld < %d\n",
502 lpDSCCaps
->dwSize
, sizeof(*lpDSCCaps
));
503 return DSERR_INVALIDPARAM
;
506 if ( !(This
->initialized
) ) {
507 WARN("not initialized\n");
508 return DSERR_UNINITIALIZED
;
511 lpDSCCaps
->dwFlags
= This
->drvcaps
.dwFlags
;
512 lpDSCCaps
->dwFormats
= This
->drvcaps
.dwFormats
;
513 lpDSCCaps
->dwChannels
= This
->drvcaps
.dwChannels
;
515 TRACE("(flags=0x%08lx,format=0x%08lx,channels=%ld)\n",lpDSCCaps
->dwFlags
,
516 lpDSCCaps
->dwFormats
, lpDSCCaps
->dwChannels
);
521 static HRESULT WINAPI
522 IDirectSoundCaptureImpl_Initialize(
523 LPDIRECTSOUNDCAPTURE iface
,
526 HRESULT err
= DSERR_INVALIDPARAM
;
528 ICOM_THIS(IDirectSoundCaptureImpl
,iface
);
529 TRACE("(%p)\n", This
);
532 WARN("invalid parameter: This == NULL\n");
533 return DSERR_INVALIDPARAM
;
536 if (This
->initialized
) {
537 WARN("already initialized\n");
538 return DSERR_ALREADYINITIALIZED
;
541 widn
= waveInGetNumDevs();
544 WARN("no audio devices found\n");
545 return DSERR_NODRIVER
;
548 /* Get dsound configuration */
549 setup_dsound_options();
551 /* enumerate WINMM audio devices and find the one we want */
552 for (wid
=0; wid
<widn
; wid
++) {
554 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDGUID
,(DWORD
)(&guid
),0));
556 WARN("waveInMessage failed; err=%lx\n",err
);
559 if (IsEqualGUID( lpcGUID
, &guid
) ) {
566 WARN("invalid parameter\n");
567 return DSERR_INVALIDPARAM
;
570 err
= mmErr(waveInMessage((HWAVEIN
)wid
,DRV_QUERYDSOUNDIFACE
,(DWORD
)&(This
->driver
),0));
571 if ( (err
!= DS_OK
) && (err
!= DSERR_UNSUPPORTED
) ) {
572 WARN("waveInMessage failed; err=%lx\n",err
);
577 /* Disable the direct sound driver to force emulation if requested. */
578 if (ds_hw_accel
== DS_HW_ACCEL_EMULATION
)
581 /* Get driver description */
583 TRACE("using DirectSound driver\n");
584 err
= IDsCaptureDriver_GetDriverDesc(This
->driver
, &(This
->drvdesc
));
586 WARN("IDsCaptureDriver_GetDriverDesc failed\n");
590 TRACE("using WINMM\n");
591 /* if no DirectSound interface available, use WINMM API instead */
592 This
->drvdesc
.dwFlags
= DSDDESC_DOMMSYSTEMOPEN
|
593 DSDDESC_DOMMSYSTEMSETFORMAT
;
596 This
->drvdesc
.dnDevNode
= wid
;
598 /* open the DirectSound driver if available */
599 if (This
->driver
&& (err
== DS_OK
))
600 err
= IDsCaptureDriver_Open(This
->driver
);
603 This
->initialized
= TRUE
;
605 /* the driver is now open, so it's now allowed to call GetCaps */
607 This
->drvcaps
.dwSize
= sizeof(This
->drvcaps
);
608 err
= IDsCaptureDriver_GetCaps(This
->driver
,&(This
->drvcaps
));
610 WARN("IDsCaptureDriver_GetCaps failed\n");
613 } else /*if (This->hwi)*/ {
615 err
= mmErr(waveInGetDevCapsA((UINT
)This
->drvdesc
.dnDevNode
, &wic
, sizeof(wic
)));
618 This
->drvcaps
.dwFlags
= 0;
619 strncpy(This
->drvdesc
.szDrvName
, wic
.szPname
,
620 sizeof(This
->drvdesc
.szDrvName
));
622 This
->drvcaps
.dwFlags
|= DSCCAPS_EMULDRIVER
;
623 This
->drvcaps
.dwFormats
= wic
.dwFormats
;
624 This
->drvcaps
.dwChannels
= wic
.wChannels
;
632 static ICOM_VTABLE(IDirectSoundCapture
) dscvt
=
634 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
635 /* IUnknown methods */
636 IDirectSoundCaptureImpl_QueryInterface
,
637 IDirectSoundCaptureImpl_AddRef
,
638 IDirectSoundCaptureImpl_Release
,
640 /* IDirectSoundCapture methods */
641 IDirectSoundCaptureImpl_CreateCaptureBuffer
,
642 IDirectSoundCaptureImpl_GetCaps
,
643 IDirectSoundCaptureImpl_Initialize
647 DSOUND_CreateDirectSoundCaptureBuffer(
648 IDirectSoundCaptureImpl
*ipDSC
,
649 LPCDSCBUFFERDESC lpcDSCBufferDesc
,
653 TRACE( "(%p,%p)\n", lpcDSCBufferDesc
, ppobj
);
656 WARN("invalid parameter: ipDSC == NULL\n");
657 return DSERR_INVALIDPARAM
;
660 if (lpcDSCBufferDesc
== NULL
) {
661 WARN("invalid parameter: lpcDSCBufferDesc == NULL\n");
662 return DSERR_INVALIDPARAM
;
666 WARN("invalid parameter: ppobj == NULL\n");
667 return DSERR_INVALIDPARAM
;
670 if ( ((lpcDSCBufferDesc
->dwSize
!= sizeof(DSCBUFFERDESC
)) &&
671 (lpcDSCBufferDesc
->dwSize
!= sizeof(DSCBUFFERDESC1
))) ||
672 (lpcDSCBufferDesc
->dwBufferBytes
== 0) ||
673 (lpcDSCBufferDesc
->lpwfxFormat
== NULL
) ) {
674 WARN("invalid lpcDSCBufferDesc\n");
676 return DSERR_INVALIDPARAM
;
679 if ( !ipDSC
->initialized
) {
680 WARN("not initialized\n");
682 return DSERR_UNINITIALIZED
;
685 wfex
= lpcDSCBufferDesc
->lpwfxFormat
;
688 TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
689 "bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
690 wfex
->wFormatTag
, wfex
->nChannels
, wfex
->nSamplesPerSec
,
691 wfex
->nAvgBytesPerSec
, wfex
->nBlockAlign
,
692 wfex
->wBitsPerSample
, wfex
->cbSize
);
694 if (wfex
->wFormatTag
== WAVE_FORMAT_PCM
) {
695 ipDSC
->pwfx
= HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX
));
696 memcpy(ipDSC
->pwfx
, wfex
, sizeof(WAVEFORMATEX
));
697 ipDSC
->pwfx
->cbSize
= 0;
699 ipDSC
->pwfx
= HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX
)+wfex
->cbSize
);
700 memcpy(ipDSC
->pwfx
, wfex
, sizeof(WAVEFORMATEX
)+wfex
->cbSize
);
703 WARN("lpcDSCBufferDesc->lpwfxFormat == 0\n");
705 return DSERR_INVALIDPARAM
; /* FIXME: DSERR_BADFORMAT ? */
708 *ppobj
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,
709 sizeof(IDirectSoundCaptureBufferImpl
));
711 if ( *ppobj
== NULL
) {
712 WARN("out of memory\n");
714 return DSERR_OUTOFMEMORY
;
717 ICOM_THIS(IDirectSoundCaptureBufferImpl
,*ppobj
);
720 This
->dsound
= ipDSC
;
721 This
->dsound
->capture_buffer
= This
;
723 This
->nrofnotifies
= 0;
724 This
->hwnotify
= NULL
;
726 This
->pdscbd
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,
727 lpcDSCBufferDesc
->dwSize
);
729 memcpy(This
->pdscbd
, lpcDSCBufferDesc
, lpcDSCBufferDesc
->dwSize
);
732 This
->dsound
->capture_buffer
= 0;
733 HeapFree( GetProcessHeap(), 0, This
);
735 return DSERR_OUTOFMEMORY
;
738 This
->lpVtbl
= &dscbvt
;
741 err
= IDsCaptureDriver_CreateCaptureBuffer(ipDSC
->driver
,
742 ipDSC
->pwfx
,0,0,&(ipDSC
->buflen
),&(ipDSC
->buffer
),(LPVOID
*)&(ipDSC
->hwbuf
));
744 WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
745 This
->dsound
->capture_buffer
= 0;
746 HeapFree( GetProcessHeap(), 0, This
);
753 DWORD flags
= CALLBACK_FUNCTION
;
754 if (ds_hw_accel
!= DS_HW_ACCEL_EMULATION
)
755 flags
|= WAVE_DIRECTSOUND
;
756 err
= mmErr(waveInOpen(&(ipDSC
->hwi
),
757 ipDSC
->drvdesc
.dnDevNode
, ipDSC
->pwfx
,
758 (DWORD
)DSOUND_capture_callback
, (DWORD
)ipDSC
, flags
));
760 WARN("waveInOpen failed\n");
761 This
->dsound
->capture_buffer
= 0;
762 HeapFree( GetProcessHeap(), 0, This
);
767 buflen
= lpcDSCBufferDesc
->dwBufferBytes
;
768 TRACE("desired buflen=%ld, old buffer=%p\n", buflen
, ipDSC
->buffer
);
770 newbuf
= (LPBYTE
)HeapReAlloc(GetProcessHeap(),0,ipDSC
->buffer
,buflen
);
772 newbuf
= (LPBYTE
)HeapAlloc(GetProcessHeap(),0,buflen
);
773 if (newbuf
== NULL
) {
774 WARN("failed to allocate capture buffer\n");
775 err
= DSERR_OUTOFMEMORY
;
776 /* but the old buffer might still exist and must be re-prepared */
778 ipDSC
->buffer
= newbuf
;
779 ipDSC
->buflen
= buflen
;
784 TRACE("returning DS_OK\n");
788 /*******************************************************************************
789 * IDirectSoundCaptureNotify
791 static HRESULT WINAPI
IDirectSoundCaptureNotifyImpl_QueryInterface(
792 LPDIRECTSOUNDNOTIFY iface
,
796 ICOM_THIS(IDirectSoundCaptureNotifyImpl
,iface
);
797 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
799 if (This
->dscb
== NULL
) {
800 WARN("invalid parameter\n");
804 return IDirectSoundCaptureBuffer_QueryInterface((LPDIRECTSOUNDCAPTUREBUFFER
)This
->dscb
, riid
, ppobj
);
807 static ULONG WINAPI
IDirectSoundCaptureNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface
)
809 ICOM_THIS(IDirectSoundCaptureNotifyImpl
,iface
);
812 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
814 ref
= InterlockedIncrement(&(This
->ref
));
818 static ULONG WINAPI
IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface
)
820 ICOM_THIS(IDirectSoundCaptureNotifyImpl
,iface
);
823 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
825 ref
= InterlockedDecrement(&(This
->ref
));
827 if (This
->dscb
->hwnotify
)
828 IDsDriverNotify_Release(This
->dscb
->hwnotify
);
829 This
->dscb
->notify
=NULL
;
830 IDirectSoundCaptureBuffer_Release((LPDIRECTSOUNDCAPTUREBUFFER
)This
->dscb
);
831 HeapFree(GetProcessHeap(),0,This
);
832 TRACE("(%p) released\n",This
);
837 static HRESULT WINAPI
IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
838 LPDIRECTSOUNDNOTIFY iface
,
840 LPCDSBPOSITIONNOTIFY notify
)
842 ICOM_THIS(IDirectSoundCaptureNotifyImpl
,iface
);
843 TRACE("(%p,0x%08lx,%p)\n",This
,howmuch
,notify
);
845 if (howmuch
> 0 && notify
== NULL
) {
846 WARN("invalid parameter: notify == NULL\n");
847 return DSERR_INVALIDPARAM
;
850 if (TRACE_ON(dsound
)) {
852 for (i
=0;i
<howmuch
;i
++)
853 TRACE("notify at %ld to 0x%08lx\n",
854 notify
[i
].dwOffset
,(DWORD
)notify
[i
].hEventNotify
);
857 if (This
->dscb
->hwnotify
) {
859 hres
= IDsDriverNotify_SetNotificationPositions(This
->dscb
->hwnotify
, howmuch
, notify
);
861 WARN("IDsDriverNotify_SetNotificationPositions failed\n");
863 } else if (howmuch
> 0) {
864 /* Make an internal copy of the caller-supplied array.
865 * Replace the existing copy if one is already present. */
866 if (This
->dscb
->notifies
)
867 This
->dscb
->notifies
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
868 This
->dscb
->notifies
, howmuch
* sizeof(DSBPOSITIONNOTIFY
));
870 This
->dscb
->notifies
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
871 howmuch
* sizeof(DSBPOSITIONNOTIFY
));
873 if (This
->dscb
->notifies
== NULL
) {
874 WARN("out of memory\n");
875 return DSERR_OUTOFMEMORY
;
877 memcpy(This
->dscb
->notifies
, notify
, howmuch
* sizeof(DSBPOSITIONNOTIFY
));
878 This
->dscb
->nrofnotifies
= howmuch
;
880 if (This
->dscb
->notifies
) {
881 HeapFree(GetProcessHeap(), 0, This
->dscb
->notifies
);
882 This
->dscb
->notifies
= NULL
;
884 This
->dscb
->nrofnotifies
= 0;
890 ICOM_VTABLE(IDirectSoundNotify
) dscnvt
=
892 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
893 IDirectSoundCaptureNotifyImpl_QueryInterface
,
894 IDirectSoundCaptureNotifyImpl_AddRef
,
895 IDirectSoundCaptureNotifyImpl_Release
,
896 IDirectSoundCaptureNotifyImpl_SetNotificationPositions
,
899 HRESULT WINAPI
IDirectSoundCaptureNotifyImpl_Create(
900 IDirectSoundCaptureBufferImpl
*dscb
,
901 IDirectSoundCaptureNotifyImpl
**pdscn
)
903 IDirectSoundCaptureNotifyImpl
* dscn
;
904 TRACE("(%p,%p)\n",dscb
,pdscn
);
906 dscn
= (IDirectSoundCaptureNotifyImpl
*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(dscn
));
909 WARN("out of memory\n");
910 return DSERR_OUTOFMEMORY
;
914 dscn
->lpVtbl
= &dscnvt
;
917 IDirectSoundCaptureBuffer_AddRef((LPDIRECTSOUNDCAPTUREBUFFER
)dscb
);
923 /*******************************************************************************
924 * IDirectSoundCaptureBuffer
926 static HRESULT WINAPI
927 IDirectSoundCaptureBufferImpl_QueryInterface(
928 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
932 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
934 TRACE( "(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
937 WARN("invalid parameter\n");
943 if ( IsEqualGUID( &IID_IDirectSoundNotify
, riid
) ||
944 IsEqualGUID( &IID_IDirectSoundNotify8
, riid
) ) {
946 hres
= IDirectSoundCaptureNotifyImpl_Create(This
, &This
->notify
);
948 if (This
->dsound
->hwbuf
) {
949 hres
= IDsCaptureDriverBuffer_QueryInterface(This
->dsound
->hwbuf
,
950 &IID_IDsDriverNotify
, (LPVOID
*)&(This
->hwnotify
));
952 WARN("IDsCaptureDriverBuffer_QueryInterface failed\n");
958 IDirectSoundNotify_AddRef((LPDIRECTSOUNDNOTIFY
)This
->notify
);
959 *ppobj
= (LPVOID
)This
->notify
;
963 WARN("IID_IDirectSoundNotify\n");
967 if ( IsEqualGUID( &IID_IDirectSoundCaptureBuffer
, riid
) ||
968 IsEqualGUID( &IID_IDirectSoundCaptureBuffer8
, riid
) ) {
969 IDirectSoundCaptureBuffer8_AddRef(iface
);
974 FIXME("(%p,%s,%p) unsupported GUID\n", This
, debugstr_guid(riid
), ppobj
);
975 return E_NOINTERFACE
;
979 IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
982 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
983 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
985 assert(This
->dsound
);
987 EnterCriticalSection( &(This
->dsound
->lock
) );
989 uRef
= ++(This
->ref
);
991 LeaveCriticalSection( &(This
->dsound
->lock
) );
997 IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
1000 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1001 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
1003 assert(This
->dsound
);
1005 EnterCriticalSection( &(This
->dsound
->lock
) );
1007 uRef
= --(This
->ref
);
1009 LeaveCriticalSection( &(This
->dsound
->lock
) );
1012 TRACE("deleting object\n");
1014 HeapFree(GetProcessHeap(),0, This
->pdscbd
);
1016 if (This
->dsound
->hwi
) {
1017 waveInReset(This
->dsound
->hwi
);
1018 waveInClose(This
->dsound
->hwi
);
1019 if (This
->dsound
->pwave
) {
1020 HeapFree(GetProcessHeap(),0, This
->dsound
->pwave
);
1021 This
->dsound
->pwave
= 0;
1023 This
->dsound
->hwi
= 0;
1026 if (This
->dsound
->hwbuf
)
1027 IDsCaptureDriverBuffer_Release(This
->dsound
->hwbuf
);
1029 /* remove from IDirectSoundCaptureImpl */
1031 This
->dsound
->capture_buffer
= NULL
;
1033 ERR("does not reference dsound\n");
1036 IDirectSoundNotify_Release((LPDIRECTSOUNDNOTIFY
)This
->notify
);
1038 if (This
->notifies
!= NULL
)
1039 HeapFree(GetProcessHeap(), 0, This
->notifies
);
1041 HeapFree( GetProcessHeap(), 0, This
);
1042 TRACE("(%p) released\n",This
);
1048 static HRESULT WINAPI
1049 IDirectSoundCaptureBufferImpl_GetCaps(
1050 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1051 LPDSCBCAPS lpDSCBCaps
)
1053 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1054 TRACE( "(%p,%p)\n", This
, lpDSCBCaps
);
1057 WARN("invalid parameter: This == NULL\n");
1058 return DSERR_INVALIDPARAM
;
1061 if (lpDSCBCaps
== NULL
) {
1062 WARN("invalid parameter: lpDSCBCaps == NULL\n");
1063 return DSERR_INVALIDPARAM
;
1066 if (lpDSCBCaps
->dwSize
< sizeof(DSCBCAPS
)) {
1067 WARN("invalid parameter: lpDSCBCaps->dwSize = %ld < %d\n",
1068 lpDSCBCaps
->dwSize
, sizeof(DSCBCAPS
));
1069 return DSERR_INVALIDPARAM
;
1072 if (This
->dsound
== NULL
) {
1073 WARN("invalid parameter: This->dsound == NULL\n");
1074 return DSERR_INVALIDPARAM
;
1077 lpDSCBCaps
->dwSize
= sizeof(DSCBCAPS
);
1078 lpDSCBCaps
->dwFlags
= This
->flags
;
1079 lpDSCBCaps
->dwBufferBytes
= This
->pdscbd
->dwBufferBytes
;
1080 lpDSCBCaps
->dwReserved
= 0;
1082 TRACE("returning DS_OK\n");
1086 static HRESULT WINAPI
1087 IDirectSoundCaptureBufferImpl_GetCurrentPosition(
1088 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1089 LPDWORD lpdwCapturePosition
,
1090 LPDWORD lpdwReadPosition
)
1092 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1093 TRACE( "(%p,%p,%p)\n", This
, lpdwCapturePosition
, lpdwReadPosition
);
1096 WARN("invalid parameter: This == NULL\n");
1097 return DSERR_INVALIDPARAM
;
1100 if (This
->dsound
== NULL
) {
1101 WARN("invalid parameter: This->dsound == NULL\n");
1102 return DSERR_INVALIDPARAM
;
1105 if (This
->dsound
->driver
) {
1107 hres
= IDsCaptureDriverBuffer_GetPosition(This
->dsound
->hwbuf
, lpdwCapturePosition
, lpdwReadPosition
);
1108 if (hres
!= DS_OK
) {
1109 WARN("IDsCaptureDriverBuffer_GetPosition failed\n");
1112 } else if (This
->dsound
->hwi
) {
1113 EnterCriticalSection(&(This
->dsound
->lock
));
1114 TRACE("old This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1115 if (lpdwCapturePosition
) {
1117 mtime
.wType
= TIME_BYTES
;
1118 waveInGetPosition(This
->dsound
->hwi
, &mtime
, sizeof(mtime
));
1119 TRACE("mtime.u.cb=%ld,This->dsound->buflen=%ld\n", mtime
.u
.cb
,
1120 This
->dsound
->buflen
);
1121 mtime
.u
.cb
= mtime
.u
.cb
% This
->dsound
->buflen
;
1122 *lpdwCapturePosition
= mtime
.u
.cb
;
1125 if (lpdwReadPosition
) {
1126 if (This
->dsound
->state
== STATE_STARTING
) {
1127 if (lpdwCapturePosition
)
1128 This
->dsound
->read_position
= *lpdwCapturePosition
;
1129 This
->dsound
->state
= STATE_CAPTURING
;
1131 *lpdwReadPosition
= This
->dsound
->read_position
;
1133 TRACE("new This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1134 LeaveCriticalSection(&(This
->dsound
->lock
));
1135 if (lpdwCapturePosition
) TRACE("*lpdwCapturePosition=%ld\n",*lpdwCapturePosition
);
1136 if (lpdwReadPosition
) TRACE("*lpdwReadPosition=%ld\n",*lpdwReadPosition
);
1138 WARN("no driver\n");
1139 return DSERR_NODRIVER
;
1142 TRACE("returning DS_OK\n");
1146 static HRESULT WINAPI
1147 IDirectSoundCaptureBufferImpl_GetFormat(
1148 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1149 LPWAVEFORMATEX lpwfxFormat
,
1150 DWORD dwSizeAllocated
,
1151 LPDWORD lpdwSizeWritten
)
1153 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1154 TRACE( "(%p,%p,0x%08lx,%p)\n", This
, lpwfxFormat
, dwSizeAllocated
,
1158 WARN("invalid parameter: This == NULL\n");
1159 return DSERR_INVALIDPARAM
;
1162 if (This
->dsound
== NULL
) {
1163 WARN("invalid parameter: This->dsound == NULL\n");
1164 return DSERR_INVALIDPARAM
;
1167 if (dwSizeAllocated
> (sizeof(WAVEFORMATEX
) + This
->dsound
->pwfx
->cbSize
))
1168 dwSizeAllocated
= sizeof(WAVEFORMATEX
) + This
->dsound
->pwfx
->cbSize
;
1170 if (lpwfxFormat
) { /* NULL is valid (just want size) */
1171 memcpy(lpwfxFormat
, This
->dsound
->pwfx
, dwSizeAllocated
);
1172 if (lpdwSizeWritten
)
1173 *lpdwSizeWritten
= dwSizeAllocated
;
1175 if (lpdwSizeWritten
)
1176 *lpdwSizeWritten
= sizeof(WAVEFORMATEX
) + This
->dsound
->pwfx
->cbSize
;
1178 TRACE("invalid parameter: lpdwSizeWritten = NULL\n");
1179 return DSERR_INVALIDPARAM
;
1183 TRACE("returning DS_OK\n");
1187 static HRESULT WINAPI
1188 IDirectSoundCaptureBufferImpl_GetStatus(
1189 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1190 LPDWORD lpdwStatus
)
1192 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1193 TRACE( "(%p, %p), thread is %04lx\n", This
, lpdwStatus
, GetCurrentThreadId() );
1196 WARN("invalid parameter: This == NULL\n");
1197 return DSERR_INVALIDPARAM
;
1200 if (This
->dsound
== NULL
) {
1201 WARN("invalid parameter: This->dsound == NULL\n");
1202 return DSERR_INVALIDPARAM
;
1205 if (lpdwStatus
== NULL
) {
1206 WARN("invalid parameter: lpdwStatus == NULL\n");
1207 return DSERR_INVALIDPARAM
;
1211 EnterCriticalSection(&(This
->dsound
->lock
));
1213 TRACE("old This->dsound->state=%s, old lpdwStatus=%08lx\n",
1214 captureStateString
[This
->dsound
->state
],*lpdwStatus
);
1215 if ((This
->dsound
->state
== STATE_STARTING
) ||
1216 (This
->dsound
->state
== STATE_CAPTURING
)) {
1217 *lpdwStatus
|= DSCBSTATUS_CAPTURING
;
1218 if (This
->flags
& DSCBSTART_LOOPING
)
1219 *lpdwStatus
|= DSCBSTATUS_LOOPING
;
1221 TRACE("new This->dsound->state=%s, new lpdwStatus=%08lx\n",
1222 captureStateString
[This
->dsound
->state
],*lpdwStatus
);
1223 LeaveCriticalSection(&(This
->dsound
->lock
));
1225 TRACE("status=%lx\n", *lpdwStatus
);
1226 TRACE("returning DS_OK\n");
1230 static HRESULT WINAPI
1231 IDirectSoundCaptureBufferImpl_Initialize(
1232 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1233 LPDIRECTSOUNDCAPTURE lpDSC
,
1234 LPCDSCBUFFERDESC lpcDSCBDesc
)
1236 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1238 FIXME( "(%p,%p,%p): stub\n", This
, lpDSC
, lpcDSCBDesc
);
1243 static HRESULT WINAPI
1244 IDirectSoundCaptureBufferImpl_Lock(
1245 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1248 LPVOID
* lplpvAudioPtr1
,
1249 LPDWORD lpdwAudioBytes1
,
1250 LPVOID
* lplpvAudioPtr2
,
1251 LPDWORD lpdwAudioBytes2
,
1254 HRESULT err
= DS_OK
;
1255 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1256 TRACE( "(%p,%08lu,%08lu,%p,%p,%p,%p,0x%08lx) at %ld\n", This
, dwReadCusor
,
1257 dwReadBytes
, lplpvAudioPtr1
, lpdwAudioBytes1
, lplpvAudioPtr2
,
1258 lpdwAudioBytes2
, dwFlags
, GetTickCount() );
1261 WARN("invalid parameter: This == NULL\n");
1262 return DSERR_INVALIDPARAM
;
1265 if (This
->dsound
== NULL
) {
1266 WARN("invalid parameter: This->dsound == NULL\n");
1267 return DSERR_INVALIDPARAM
;
1270 if (lplpvAudioPtr1
== NULL
) {
1271 WARN("invalid parameter: lplpvAudioPtr1 == NULL\n");
1272 return DSERR_INVALIDPARAM
;
1275 if (lpdwAudioBytes1
== NULL
) {
1276 WARN("invalid parameter: lpdwAudioBytes1 == NULL\n");
1277 return DSERR_INVALIDPARAM
;
1280 EnterCriticalSection(&(This
->dsound
->lock
));
1282 if (This
->dsound
->driver
) {
1283 err
= IDsCaptureDriverBuffer_Lock(This
->dsound
->hwbuf
, lplpvAudioPtr1
,
1284 lpdwAudioBytes1
, lplpvAudioPtr2
, lpdwAudioBytes2
,
1285 dwReadCusor
, dwReadBytes
, dwFlags
);
1287 WARN("IDsCaptureDriverBuffer_Lock failed\n");
1288 } else if (This
->dsound
->hwi
) {
1289 *lplpvAudioPtr1
= This
->dsound
->buffer
+ dwReadCusor
;
1290 if ( (dwReadCusor
+ dwReadBytes
) > This
->dsound
->buflen
) {
1291 *lpdwAudioBytes1
= This
->dsound
->buflen
- dwReadCusor
;
1293 *lplpvAudioPtr2
= This
->dsound
->buffer
;
1294 if (lpdwAudioBytes2
)
1295 *lpdwAudioBytes2
= dwReadBytes
- *lpdwAudioBytes1
;
1297 *lpdwAudioBytes1
= dwReadBytes
;
1299 *lplpvAudioPtr2
= 0;
1300 if (lpdwAudioBytes2
)
1301 *lpdwAudioBytes2
= 0;
1304 TRACE("invalid call\n");
1305 err
= DSERR_INVALIDCALL
; /* DSERR_NODRIVER ? */
1308 LeaveCriticalSection(&(This
->dsound
->lock
));
1313 static HRESULT WINAPI
1314 IDirectSoundCaptureBufferImpl_Start(
1315 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1318 HRESULT err
= DS_OK
;
1319 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1320 TRACE( "(%p,0x%08lx)\n", This
, dwFlags
);
1323 WARN("invalid parameter: This == NULL\n");
1324 return DSERR_INVALIDPARAM
;
1327 if (This
->dsound
== NULL
) {
1328 WARN("invalid parameter: This->dsound == NULL\n");
1329 return DSERR_INVALIDPARAM
;
1332 if ( (This
->dsound
->driver
== 0) && (This
->dsound
->hwi
== 0) ) {
1333 WARN("no driver\n");
1334 return DSERR_NODRIVER
;
1337 EnterCriticalSection(&(This
->dsound
->lock
));
1339 This
->flags
= dwFlags
;
1340 TRACE("old This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1341 if (This
->dsound
->state
== STATE_STOPPED
)
1342 This
->dsound
->state
= STATE_STARTING
;
1343 else if (This
->dsound
->state
== STATE_STOPPING
)
1344 This
->dsound
->state
= STATE_CAPTURING
;
1345 TRACE("new This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1347 LeaveCriticalSection(&(This
->dsound
->lock
));
1349 if (This
->dsound
->driver
) {
1350 err
= IDsCaptureDriverBuffer_Start(This
->dsound
->hwbuf
, dwFlags
);
1352 WARN("IDsCaptureDriverBuffer_Start failed\n");
1355 IDirectSoundCaptureImpl
* ipDSC
= This
->dsound
;
1357 if (ipDSC
->buffer
) {
1358 if (This
->nrofnotifies
) {
1361 ipDSC
->nrofpwaves
= This
->nrofnotifies
;
1362 TRACE("nrofnotifies=%d\n", This
->nrofnotifies
);
1364 /* prepare headers */
1366 ipDSC
->pwave
= HeapReAlloc(GetProcessHeap(),0,ipDSC
->pwave
,
1367 ipDSC
->nrofpwaves
*sizeof(WAVEHDR
));
1369 ipDSC
->pwave
= HeapAlloc(GetProcessHeap(),0,
1370 ipDSC
->nrofpwaves
*sizeof(WAVEHDR
));
1372 for (c
= 0; c
< ipDSC
->nrofpwaves
; c
++) {
1373 if (This
->notifies
[c
].dwOffset
== DSBPN_OFFSETSTOP
) {
1374 TRACE("got DSBPN_OFFSETSTOP\n");
1375 ipDSC
->nrofpwaves
= c
;
1379 ipDSC
->pwave
[0].lpData
= ipDSC
->buffer
;
1380 ipDSC
->pwave
[0].dwBufferLength
=
1381 This
->notifies
[0].dwOffset
+ 1;
1383 ipDSC
->pwave
[c
].lpData
= ipDSC
->buffer
+
1384 This
->notifies
[c
-1].dwOffset
+ 1;
1385 ipDSC
->pwave
[c
].dwBufferLength
=
1386 This
->notifies
[c
].dwOffset
-
1387 This
->notifies
[c
-1].dwOffset
;
1389 ipDSC
->pwave
[c
].dwBytesRecorded
= 0;
1390 ipDSC
->pwave
[c
].dwUser
= (DWORD
)ipDSC
;
1391 ipDSC
->pwave
[c
].dwFlags
= 0;
1392 ipDSC
->pwave
[c
].dwLoops
= 0;
1393 err
= mmErr(waveInPrepareHeader(ipDSC
->hwi
,
1394 &(ipDSC
->pwave
[c
]),sizeof(WAVEHDR
)));
1396 WARN("waveInPrepareHeader failed\n");
1398 waveInUnprepareHeader(ipDSC
->hwi
,
1399 &(ipDSC
->pwave
[c
]),sizeof(WAVEHDR
));
1403 err
= mmErr(waveInAddBuffer(ipDSC
->hwi
,
1404 &(ipDSC
->pwave
[c
]), sizeof(WAVEHDR
)));
1406 WARN("waveInAddBuffer failed\n");
1408 waveInUnprepareHeader(ipDSC
->hwi
,
1409 &(ipDSC
->pwave
[c
]),sizeof(WAVEHDR
));
1414 memset(ipDSC
->buffer
,
1415 (ipDSC
->pwfx
->wBitsPerSample
== 8) ? 128 : 0, ipDSC
->buflen
);
1417 TRACE("no notifiers specified\n");
1418 /* no notifiers specified so just create a single default header */
1419 ipDSC
->nrofpwaves
= 1;
1421 ipDSC
->pwave
= HeapReAlloc(GetProcessHeap(),0,ipDSC
->pwave
,sizeof(WAVEHDR
));
1423 ipDSC
->pwave
= HeapAlloc(GetProcessHeap(),0,sizeof(WAVEHDR
));
1425 ipDSC
->pwave
[0].lpData
= ipDSC
->buffer
;
1426 ipDSC
->pwave
[0].dwBufferLength
= ipDSC
->buflen
;
1427 ipDSC
->pwave
[0].dwBytesRecorded
= 0;
1428 ipDSC
->pwave
[0].dwUser
= (DWORD
)ipDSC
;
1429 ipDSC
->pwave
[0].dwFlags
= 0;
1430 ipDSC
->pwave
[0].dwLoops
= 0;
1432 err
= mmErr(waveInPrepareHeader(ipDSC
->hwi
,
1433 &(ipDSC
->pwave
[0]),sizeof(WAVEHDR
)));
1435 WARN("waveInPrepareHeader failed\n");
1436 waveInUnprepareHeader(ipDSC
->hwi
,
1437 &(ipDSC
->pwave
[0]),sizeof(WAVEHDR
));
1439 err
= mmErr(waveInAddBuffer(ipDSC
->hwi
,
1440 &(ipDSC
->pwave
[0]), sizeof(WAVEHDR
)));
1442 WARN("waveInAddBuffer failed\n");
1443 waveInUnprepareHeader(ipDSC
->hwi
,
1444 &(ipDSC
->pwave
[0]),sizeof(WAVEHDR
));
1450 ipDSC
->read_position
= 0;
1453 /* start filling the first buffer */
1454 err
= mmErr(waveInStart(ipDSC
->hwi
));
1456 WARN("waveInStart failed\n");
1461 WARN("calling waveInClose because of error\n");
1462 waveInClose(This
->dsound
->hwi
);
1463 This
->dsound
->hwi
= 0;
1466 TRACE("returning %ld\n", err
);
1470 static HRESULT WINAPI
1471 IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface
)
1473 HRESULT err
= DS_OK
;
1474 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1475 TRACE( "(%p)\n", This
);
1478 WARN("invalid parameter: This == NULL\n");
1479 return DSERR_INVALIDPARAM
;
1482 if (This
->dsound
== NULL
) {
1483 WARN("invalid parameter: This->dsound == NULL\n");
1484 return DSERR_INVALIDPARAM
;
1487 EnterCriticalSection(&(This
->dsound
->lock
));
1489 TRACE("old This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1490 if (This
->dsound
->state
== STATE_CAPTURING
)
1491 This
->dsound
->state
= STATE_STOPPING
;
1492 else if (This
->dsound
->state
== STATE_STARTING
)
1493 This
->dsound
->state
= STATE_STOPPED
;
1494 TRACE("new This->dsound->state=%s\n",captureStateString
[This
->dsound
->state
]);
1496 LeaveCriticalSection(&(This
->dsound
->lock
));
1498 if (This
->dsound
->driver
) {
1499 err
= IDsCaptureDriverBuffer_Stop(This
->dsound
->hwbuf
);
1500 if (err
== DSERR_BUFFERLOST
) {
1501 /* Wine-only: the driver wants us to reopen the device */
1502 IDsCaptureDriverBuffer_Release(This
->dsound
->hwbuf
);
1503 err
= IDsCaptureDriver_CreateCaptureBuffer(This
->dsound
->driver
,
1504 This
->dsound
->pwfx
,0,0,&(This
->dsound
->buflen
),&(This
->dsound
->buffer
),
1505 (LPVOID
*)&(This
->dsound
->hwbuf
));
1507 WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
1508 This
->dsound
->hwbuf
= 0;
1510 } else if (err
!= DS_OK
)
1511 WARN("IDsCaptureDriverBuffer_Stop failed\n");
1512 } else if (This
->dsound
->hwi
) {
1513 err
= waveInStop(This
->dsound
->hwi
);
1515 WARN("no driver\n");
1516 err
= DSERR_NODRIVER
;
1519 TRACE( "(%p) returning 0x%08lx\n", This
,err
);
1523 static HRESULT WINAPI
1524 IDirectSoundCaptureBufferImpl_Unlock(
1525 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1526 LPVOID lpvAudioPtr1
,
1527 DWORD dwAudioBytes1
,
1528 LPVOID lpvAudioPtr2
,
1529 DWORD dwAudioBytes2
)
1531 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1532 TRACE( "(%p,%p,%08lu,%p,%08lu)\n", This
, lpvAudioPtr1
, dwAudioBytes1
,
1533 lpvAudioPtr2
, dwAudioBytes2
);
1536 WARN("invalid parameter: This == NULL\n");
1537 return DSERR_INVALIDPARAM
;
1540 if (lpvAudioPtr1
== NULL
) {
1541 WARN("invalid parameter: lpvAudioPtr1 == NULL\n");
1542 return DSERR_INVALIDPARAM
;
1545 if (This
->dsound
->driver
) {
1547 hres
= IDsCaptureDriverBuffer_Unlock(This
->dsound
->hwbuf
, lpvAudioPtr1
,
1548 dwAudioBytes1
, lpvAudioPtr2
, dwAudioBytes2
);
1550 WARN("IDsCaptureDriverBuffer_Unlock failed\n");
1552 } else if (This
->dsound
->hwi
) {
1553 This
->dsound
->read_position
= (This
->dsound
->read_position
+
1554 (dwAudioBytes1
+ dwAudioBytes2
)) % This
->dsound
->buflen
;
1556 WARN("invalid call\n");
1557 return DSERR_INVALIDCALL
;
1563 static HRESULT WINAPI
1564 IDirectSoundCaptureBufferImpl_GetObjectInPath(
1565 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1566 REFGUID rguidObject
,
1568 REFGUID rguidInterface
,
1571 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1573 FIXME( "(%p,%s,%lu,%s,%p): stub\n", This
, debugstr_guid(rguidObject
),
1574 dwIndex
, debugstr_guid(rguidInterface
), ppObject
);
1579 static HRESULT WINAPI
1580 IDirectSoundCaptureBufferImpl_GetFXStatus(
1581 LPDIRECTSOUNDCAPTUREBUFFER8 iface
,
1583 LPDWORD pdwFXStatus
)
1585 ICOM_THIS(IDirectSoundCaptureBufferImpl
,iface
);
1587 FIXME( "(%p,%lu,%p): stub\n", This
, dwFXCount
, pdwFXStatus
);
1592 static ICOM_VTABLE(IDirectSoundCaptureBuffer8
) dscbvt
=
1594 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1595 /* IUnknown methods */
1596 IDirectSoundCaptureBufferImpl_QueryInterface
,
1597 IDirectSoundCaptureBufferImpl_AddRef
,
1598 IDirectSoundCaptureBufferImpl_Release
,
1600 /* IDirectSoundCaptureBuffer methods */
1601 IDirectSoundCaptureBufferImpl_GetCaps
,
1602 IDirectSoundCaptureBufferImpl_GetCurrentPosition
,
1603 IDirectSoundCaptureBufferImpl_GetFormat
,
1604 IDirectSoundCaptureBufferImpl_GetStatus
,
1605 IDirectSoundCaptureBufferImpl_Initialize
,
1606 IDirectSoundCaptureBufferImpl_Lock
,
1607 IDirectSoundCaptureBufferImpl_Start
,
1608 IDirectSoundCaptureBufferImpl_Stop
,
1609 IDirectSoundCaptureBufferImpl_Unlock
,
1611 /* IDirectSoundCaptureBuffer methods */
1612 IDirectSoundCaptureBufferImpl_GetObjectInPath
,
1613 IDirectSoundCaptureBufferImpl_GetFXStatus
1616 /*******************************************************************************
1617 * DirectSoundCapture ClassFactory
1620 static HRESULT WINAPI
1621 DSCCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
1623 ICOM_THIS(IClassFactoryImpl
,iface
);
1625 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
1626 return E_NOINTERFACE
;
1630 DSCCF_AddRef(LPCLASSFACTORY iface
)
1632 ICOM_THIS(IClassFactoryImpl
,iface
);
1633 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
1634 return ++(This
->ref
);
1638 DSCCF_Release(LPCLASSFACTORY iface
)
1640 ICOM_THIS(IClassFactoryImpl
,iface
);
1641 /* static class, won't be freed */
1642 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
1643 return --(This
->ref
);
1646 static HRESULT WINAPI
1647 DSCCF_CreateInstance(
1648 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
)
1650 ICOM_THIS(IClassFactoryImpl
,iface
);
1651 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1653 if (ppobj
== NULL
) {
1654 WARN("invalid parameter\n");
1655 return E_INVALIDARG
;
1660 if ( IsEqualGUID( &IID_IDirectSoundCapture
, riid
) ||
1661 IsEqualGUID( &IID_IDirectSoundCapture8
, riid
) ) {
1662 return DirectSoundCaptureCreate8(0,(LPDIRECTSOUNDCAPTURE8
*)ppobj
,pOuter
);
1665 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1666 return E_NOINTERFACE
;
1669 static HRESULT WINAPI
1670 DSCCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
1672 ICOM_THIS(IClassFactoryImpl
,iface
);
1673 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
1677 static ICOM_VTABLE(IClassFactory
) DSCCF_Vtbl
=
1679 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1680 DSCCF_QueryInterface
,
1683 DSCCF_CreateInstance
,
1687 IClassFactoryImpl DSOUND_CAPTURE_CF
= { &DSCCF_Vtbl
, 1 };
1689 /***************************************************************************
1690 * DirectSoundFullDuplexCreate [DSOUND.10]
1692 * Create and initialize a DirectSoundFullDuplex interface.
1695 * pcGuidCaptureDevice [I] Address of sound capture device GUID.
1696 * pcGuidRenderDevice [I] Address of sound render device GUID.
1697 * pcDSCBufferDesc [I] Address of capture buffer description.
1698 * pcDSBufferDesc [I] Address of render buffer description.
1699 * hWnd [I] Handle to application window.
1700 * dwLevel [I] Cooperative level.
1701 * ppDSFD [O] Address where full duplex interface returned.
1702 * ppDSCBuffer8 [0] Address where capture buffer interface returned.
1703 * ppDSBuffer8 [0] Address where render buffer interface returned.
1704 * pUnkOuter [I] Must be NULL.
1708 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
1709 * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
1712 DirectSoundFullDuplexCreate(
1713 LPCGUID pcGuidCaptureDevice
,
1714 LPCGUID pcGuidRenderDevice
,
1715 LPCDSCBUFFERDESC pcDSCBufferDesc
,
1716 LPCDSBUFFERDESC pcDSBufferDesc
,
1719 LPDIRECTSOUNDFULLDUPLEX
*ppDSFD
,
1720 LPDIRECTSOUNDCAPTUREBUFFER8
*ppDSCBuffer8
,
1721 LPDIRECTSOUNDBUFFER8
*ppDSBuffer8
,
1722 LPUNKNOWN pUnkOuter
)
1724 IDirectSoundFullDuplexImpl
** ippDSFD
=(IDirectSoundFullDuplexImpl
**)ppDSFD
;
1725 TRACE("(%s,%s,%p,%p,%lx,%lx,%p,%p,%p,%p)\n", debugstr_guid(pcGuidCaptureDevice
),
1726 debugstr_guid(pcGuidRenderDevice
), pcDSCBufferDesc
, pcDSBufferDesc
,
1727 (DWORD
)hWnd
, dwLevel
, ppDSFD
, ppDSCBuffer8
, ppDSBuffer8
, pUnkOuter
);
1730 WARN("pUnkOuter != 0\n");
1731 return DSERR_NOAGGREGATION
;
1734 *ippDSFD
= (IDirectSoundFullDuplexImpl
*)HeapAlloc(GetProcessHeap(),
1735 HEAP_ZERO_MEMORY
, sizeof(IDirectSoundFullDuplexImpl
));
1737 if (*ippDSFD
== NULL
) {
1738 WARN("out of memory\n");
1739 return DSERR_OUTOFMEMORY
;
1742 ICOM_THIS(IDirectSoundFullDuplexImpl
, *ippDSFD
);
1745 This
->lpVtbl
= &dsfdvt
;
1747 InitializeCriticalSection( &(This
->lock
) );
1749 hres
= IDirectSoundFullDuplexImpl_Initialize( (LPDIRECTSOUNDFULLDUPLEX
)This
,
1750 pcGuidCaptureDevice
, pcGuidRenderDevice
,
1751 pcDSCBufferDesc
, pcDSBufferDesc
,
1752 hWnd
, dwLevel
, ppDSCBuffer8
, ppDSBuffer8
);
1754 WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
1758 return DSERR_GENERIC
;
1761 static HRESULT WINAPI
1762 IDirectSoundFullDuplexImpl_QueryInterface(
1763 LPDIRECTSOUNDFULLDUPLEX iface
,
1767 ICOM_THIS(IDirectSoundFullDuplexImpl
,iface
);
1768 TRACE( "(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
1770 if (ppobj
== NULL
) {
1771 WARN("invalid parameter\n");
1772 return E_INVALIDARG
;
1776 return E_NOINTERFACE
;
1780 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface
)
1783 ICOM_THIS(IDirectSoundFullDuplexImpl
,iface
);
1784 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
1786 EnterCriticalSection( &(This
->lock
) );
1788 uRef
= ++(This
->ref
);
1790 LeaveCriticalSection( &(This
->lock
) );
1796 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface
)
1799 ICOM_THIS(IDirectSoundFullDuplexImpl
,iface
);
1800 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
1802 EnterCriticalSection( &(This
->lock
) );
1804 uRef
= --(This
->ref
);
1806 LeaveCriticalSection( &(This
->lock
) );
1809 DeleteCriticalSection( &(This
->lock
) );
1810 HeapFree( GetProcessHeap(), 0, This
);
1811 TRACE("(%p) released\n",This
);
1817 static HRESULT WINAPI
1818 IDirectSoundFullDuplexImpl_Initialize(
1819 LPDIRECTSOUNDFULLDUPLEX iface
,
1820 LPCGUID pCaptureGuid
,
1821 LPCGUID pRendererGuid
,
1822 LPCDSCBUFFERDESC lpDscBufferDesc
,
1823 LPCDSBUFFERDESC lpDsBufferDesc
,
1826 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8
,
1827 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8
)
1829 ICOM_THIS(IDirectSoundFullDuplexImpl
,iface
);
1830 IDirectSoundCaptureBufferImpl
** ippdscb
=(IDirectSoundCaptureBufferImpl
**)lplpDirectSoundCaptureBuffer8
;
1831 IDirectSoundBufferImpl
** ippdsc
=(IDirectSoundBufferImpl
**)lplpDirectSoundBuffer8
;
1833 FIXME( "(%p,%s,%s,%p,%p,%lx,%lx,%p,%p) stub!\n", This
, debugstr_guid(pCaptureGuid
),
1834 debugstr_guid(pRendererGuid
), lpDscBufferDesc
, lpDsBufferDesc
, (DWORD
)hWnd
, dwLevel
,
1840 static ICOM_VTABLE(IDirectSoundFullDuplex
) dsfdvt
=
1842 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1843 /* IUnknown methods */
1844 IDirectSoundFullDuplexImpl_QueryInterface
,
1845 IDirectSoundFullDuplexImpl_AddRef
,
1846 IDirectSoundFullDuplexImpl_Release
,
1848 /* IDirectSoundFullDuplex methods */
1849 IDirectSoundFullDuplexImpl_Initialize
1852 /*******************************************************************************
1853 * DirectSoundFullDuplex ClassFactory
1856 static HRESULT WINAPI
1857 DSFDCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
1859 ICOM_THIS(IClassFactoryImpl
,iface
);
1861 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
1862 return E_NOINTERFACE
;
1866 DSFDCF_AddRef(LPCLASSFACTORY iface
)
1868 ICOM_THIS(IClassFactoryImpl
,iface
);
1869 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
1870 return ++(This
->ref
);
1874 DSFDCF_Release(LPCLASSFACTORY iface
)
1876 ICOM_THIS(IClassFactoryImpl
,iface
);
1877 /* static class, won't be freed */
1878 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
1879 return --(This
->ref
);
1882 static HRESULT WINAPI
1883 DSFDCF_CreateInstance(
1884 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
)
1886 ICOM_THIS(IClassFactoryImpl
,iface
);
1888 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1890 if (ppobj
== NULL
) {
1891 WARN("invalid parameter\n");
1892 return E_INVALIDARG
;
1897 if ( IsEqualGUID( &IID_IDirectSoundFullDuplex
, riid
) ) {
1898 /* FIXME: how do we do this one ? */
1899 FIXME("not implemented\n");
1900 return E_NOINTERFACE
;
1903 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1904 return E_NOINTERFACE
;
1907 static HRESULT WINAPI
1908 DSFDCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
1910 ICOM_THIS(IClassFactoryImpl
,iface
);
1911 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
1915 static ICOM_VTABLE(IClassFactory
) DSFDCF_Vtbl
=
1917 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1918 DSFDCF_QueryInterface
,
1921 DSFDCF_CreateInstance
,
1925 IClassFactoryImpl DSOUND_FULLDUPLEX_CF
= { &DSFDCF_Vtbl
, 1 };