2003-02-15 01:01:17 +01:00
|
|
|
/* DirectSoundCapture
|
2002-06-13 21:15:06 +02:00
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Rob Riggs
|
|
|
|
* Copyright 2000-2001 TransGaming Technologies, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* TODO:
|
2003-03-04 03:12:34 +01:00
|
|
|
* Implement DirectSoundFullDuplex support.
|
|
|
|
* Implement FX support.
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-06-13 21:15:06 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/fcntl.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-06-13 21:15:06 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "mmsystem.h"
|
2003-02-15 01:01:17 +01:00
|
|
|
#include "mmddk.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2003-02-15 01:01:17 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winnls.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
2003-02-15 01:01:17 +01:00
|
|
|
#include "dsdriver.h"
|
|
|
|
#include "dsound_private.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
|
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCGUID lpcGUID );
|
2003-03-04 03:12:34 +01:00
|
|
|
static ULONG WINAPI IDirectSoundCaptureImpl_Release(
|
|
|
|
LPDIRECTSOUNDCAPTURE iface );
|
|
|
|
static ULONG WINAPI IDirectSoundCaptureBufferImpl_Release(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface );
|
2003-02-15 01:01:17 +01:00
|
|
|
static HRESULT DSOUND_CreateDirectSoundCaptureBuffer(
|
|
|
|
IDirectSoundCaptureImpl *ipDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
|
|
|
LPVOID* ppobj );
|
2003-03-06 23:46:34 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(
|
|
|
|
LPDIRECTSOUNDFULLDUPLEX iface,
|
|
|
|
LPCGUID pCaptureGuid,
|
|
|
|
LPCGUID pRendererGuid,
|
|
|
|
LPCDSCBUFFERDESC lpDscBufferDesc,
|
|
|
|
LPCDSBUFFERDESC lpDsBufferDesc,
|
|
|
|
HWND hWnd,
|
|
|
|
DWORD dwLevel,
|
|
|
|
LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
|
|
|
|
LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectSoundCapture) dscvt;
|
|
|
|
static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt;
|
2003-03-04 03:12:34 +01:00
|
|
|
static ICOM_VTABLE(IDirectSoundFullDuplex) dsfdvt;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
IDirectSoundCaptureImpl* dsound_capture = NULL;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureCreate [DSOUND.6]
|
|
|
|
*
|
2003-05-02 22:16:48 +02:00
|
|
|
* Create and initialize a DirectSoundCapture interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpcGUID [I] Address of the GUID that identifies the sound capture device.
|
|
|
|
* lplpDSC [O] Address of a variable to receive the interface pointer.
|
|
|
|
* pUnkOuter [I] Must be NULL.
|
2002-06-13 21:15:06 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
|
|
|
|
* DSERR_OUTOFMEMORY
|
2003-05-02 22:16:48 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* lpcGUID must be one of the values returned from DirectSoundCaptureEnumerate
|
|
|
|
* or NULL for the default device or DSDEVID_DefaultCapture or
|
|
|
|
* DSDEVID_DefaultVoiceCapture.
|
|
|
|
*
|
|
|
|
* DSERR_ALLOCATED is returned for sound devices that do not support full duplex.
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
2003-02-15 01:01:17 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
DirectSoundCaptureCreate8(
|
|
|
|
LPCGUID lpcGUID,
|
|
|
|
LPDIRECTSOUNDCAPTURE* lplpDSC,
|
|
|
|
LPUNKNOWN pUnkOuter )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-03-15 01:54:11 +01:00
|
|
|
IDirectSoundCaptureImpl** ippDSC=(IDirectSoundCaptureImpl**)lplpDSC;
|
2003-02-15 01:01:17 +01:00
|
|
|
TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), lplpDSC, pUnkOuter);
|
|
|
|
|
|
|
|
if ( pUnkOuter ) {
|
2003-05-02 22:16:48 +02:00
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !lplpDSC ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("invalid parameter: lplpDSC == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default device? */
|
2003-03-15 01:54:11 +01:00
|
|
|
if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) )
|
|
|
|
lpcGUID = &DSDEVID_DefaultCapture;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
*ippDSC = (IDirectSoundCaptureImpl*)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY, sizeof(IDirectSoundCaptureImpl));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
if (*ippDSC == NULL) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("out of memory\n");
|
2003-03-15 01:54:11 +01:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2003-05-22 05:39:13 +02:00
|
|
|
} else {
|
2003-03-15 01:54:11 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl, *ippDSC);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
This->ref = 1;
|
|
|
|
This->state = STATE_STOPPED;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
InitializeCriticalSection( &(This->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-04-10 20:17:34 +02:00
|
|
|
This->lpVtbl = &dscvt;
|
2003-03-15 01:54:11 +01:00
|
|
|
dsound_capture = This;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (GetDeviceID(lpcGUID, &This->guid) == DS_OK) {
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IDirectSoundCaptureImpl_Initialize( (LPDIRECTSOUNDCAPTURE)This, &This->guid);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDirectSoundCaptureImpl_Initialize failed\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("invalid GUID: %s\n", debugstr_guid(lpcGUID));
|
2003-03-15 01:54:11 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureEnumerateA [DSOUND.7]
|
|
|
|
*
|
2003-05-02 22:16:48 +02:00
|
|
|
* Enumerate all DirectSound drivers installed in the system.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpDSEnumCallback [I] Address of callback function.
|
|
|
|
* lpContext [I] Address of user defined context passed to callback function.
|
2002-06-13 21:15:06 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_INVALIDPARAM
|
|
|
|
*/
|
2003-02-15 01:01:17 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
DirectSoundCaptureEnumerateA(
|
|
|
|
LPDSENUMCALLBACKA lpDSEnumCallback,
|
|
|
|
LPVOID lpContext)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
unsigned devs, wid;
|
2003-03-15 01:54:11 +01:00
|
|
|
DSDRIVERDESC desc;
|
|
|
|
GUID guid;
|
|
|
|
int err;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
|
|
|
|
|
|
|
|
if (lpDSEnumCallback == NULL) {
|
2003-05-02 22:16:48 +02:00
|
|
|
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
devs = waveInGetNumDevs();
|
2003-03-15 01:54:11 +01:00
|
|
|
if (devs > 0) {
|
|
|
|
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
|
|
|
|
GUID temp;
|
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&temp,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
if (IsEqualGUID( &guid, &temp ) ) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
|
|
|
debugstr_guid(&DSDEVID_DefaultCapture),"Primary Sound Capture Driver",desc.szDrvName,lpContext);
|
2003-09-15 22:08:05 +02:00
|
|
|
if (lpDSEnumCallback(NULL, "Primary Sound Capture Driver", desc.szDrvName, lpContext) == FALSE)
|
2003-03-15 01:54:11 +01:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2003-03-15 01:54:11 +01:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
|
|
|
debugstr_guid(&guid),desc.szDesc,desc.szDrvName,lpContext);
|
|
|
|
if (lpDSEnumCallback(&guid, desc.szDesc, desc.szDrvName, lpContext) == FALSE)
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureEnumerateW [DSOUND.8]
|
|
|
|
*
|
2003-05-02 22:16:48 +02:00
|
|
|
* Enumerate all DirectSound drivers installed in the system.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpDSEnumCallback [I] Address of callback function.
|
|
|
|
* lpContext [I] Address of user defined context passed to callback function.
|
2002-06-13 21:15:06 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_INVALIDPARAM
|
|
|
|
*/
|
2003-02-15 01:01:17 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
DirectSoundCaptureEnumerateW(
|
|
|
|
LPDSENUMCALLBACKW lpDSEnumCallback,
|
|
|
|
LPVOID lpContext)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
unsigned devs, wid;
|
2003-03-15 01:54:11 +01:00
|
|
|
DSDRIVERDESC desc;
|
|
|
|
GUID guid;
|
|
|
|
int err;
|
|
|
|
WCHAR wDesc[MAXPNAMELEN];
|
|
|
|
WCHAR wName[MAXPNAMELEN];
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
|
|
|
|
|
|
|
|
if (lpDSEnumCallback == NULL) {
|
2003-05-02 22:16:48 +02:00
|
|
|
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
devs = waveInGetNumDevs();
|
2003-03-15 01:54:11 +01:00
|
|
|
if (devs > 0) {
|
|
|
|
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
|
|
|
|
GUID temp;
|
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&temp,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
if (IsEqualGUID( &guid, &temp ) ) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
|
|
|
debugstr_guid(&DSDEVID_DefaultCapture),"Primary Sound Capture Driver",desc.szDrvName,lpContext);
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
|
|
|
|
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1,
|
|
|
|
wName, sizeof(wName)/sizeof(WCHAR) );
|
2003-09-15 22:08:05 +02:00
|
|
|
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
|
2003-03-15 01:54:11 +01:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2003-03-15 01:54:11 +01:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&desc,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)&guid,0));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
|
|
|
debugstr_guid(&DSDEVID_DefaultCapture),desc.szDesc,desc.szDrvName,lpContext);
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
|
|
|
|
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1,
|
|
|
|
wName, sizeof(wName)/sizeof(WCHAR) );
|
|
|
|
if (lpDSEnumCallback((LPGUID)&DSDEVID_DefaultCapture, wDesc, wName, lpContext) == FALSE)
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
static void CALLBACK
|
|
|
|
DSOUND_capture_callback(
|
|
|
|
HWAVEIN hwi,
|
|
|
|
UINT msg,
|
|
|
|
DWORD dwUser,
|
|
|
|
DWORD dw1,
|
|
|
|
DWORD dw2 )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
IDirectSoundCaptureImpl* This = (IDirectSoundCaptureImpl*)dwUser;
|
2003-05-02 22:16:48 +02:00
|
|
|
TRACE("(%p,%08x(%s),%08lx,%08lx,%08lx) entering at %ld\n",hwi,msg,
|
|
|
|
msg == MM_WIM_OPEN ? "MM_WIM_OPEN" : msg == MM_WIM_CLOSE ? "MM_WIM_CLOSE" :
|
|
|
|
msg == MM_WIM_DATA ? "MM_WIM_DATA" : "UNKNOWN",dwUser,dw1,dw2,GetTickCount());
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
if (msg == MM_WIM_DATA) {
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection( &(This->lock) );
|
|
|
|
TRACE("DirectSoundCapture msg=MM_WIM_DATA, old This->state=%ld, old This->index=%d\n",This->state,This->index);
|
|
|
|
if (This->state != STATE_STOPPED) {
|
|
|
|
if (This->state == STATE_STARTING) {
|
|
|
|
MMTIME mtime;
|
|
|
|
mtime.wType = TIME_BYTES;
|
|
|
|
waveInGetPosition(This->hwi, &mtime, sizeof(mtime));
|
|
|
|
TRACE("mtime.u.cb=%ld,This->buflen=%ld\n", mtime.u.cb, This->buflen);
|
|
|
|
mtime.u.cb = mtime.u.cb % This->buflen;
|
|
|
|
This->read_position = mtime.u.cb;
|
|
|
|
This->state = STATE_CAPTURING;
|
|
|
|
}
|
|
|
|
waveInUnprepareHeader(hwi,&(This->pwave[This->index]),sizeof(WAVEHDR));
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->capture_buffer->nrofnotifies)
|
|
|
|
SetEvent(This->capture_buffer->notifies[This->index].hEventNotify);
|
2003-09-15 22:08:05 +02:00
|
|
|
This->index = (This->index + 1) % This->nrofpwaves;
|
2003-03-04 03:12:34 +01:00
|
|
|
if ( (This->index == 0) && !(This->capture_buffer->flags & DSCBSTART_LOOPING) ) {
|
|
|
|
TRACE("end of buffer\n");
|
|
|
|
This->state = STATE_STOPPED;
|
|
|
|
} else {
|
|
|
|
if (This->state == STATE_CAPTURING) {
|
|
|
|
waveInPrepareHeader(hwi,&(This->pwave[This->index]),sizeof(WAVEHDR));
|
|
|
|
waveInAddBuffer(hwi, &(This->pwave[This->index]), sizeof(WAVEHDR));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("DirectSoundCapture new This->state=%ld, new This->index=%d\n",This->state,This->index);
|
|
|
|
LeaveCriticalSection( &(This->lock) );
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("completed\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This->driver) {
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IDsCaptureDriver_QueryInterface(This->driver, riid, ppobj);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriver_QueryInterface failed\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
2003-02-15 01:01:17 +01:00
|
|
|
return E_FAIL;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection( &(This->lock) );
|
2003-02-15 01:01:17 +01:00
|
|
|
uRef = ++(This->ref);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->driver)
|
|
|
|
IDsCaptureDriver_AddRef(This->driver);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection( &(This->lock) );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
return uRef;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection( &(This->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
uRef = --(This->ref);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection( &(This->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if ( uRef == 0 ) {
|
|
|
|
TRACE("deleting object\n");
|
|
|
|
if (This->capture_buffer)
|
2003-03-04 03:12:34 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_Release(
|
|
|
|
(LPDIRECTSOUNDCAPTUREBUFFER8) This->capture_buffer);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (This->driver) {
|
|
|
|
IDsCaptureDriver_Close(This->driver);
|
|
|
|
IDsCaptureDriver_Release(This->driver);
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
DeleteCriticalSection( &(This->lock) );
|
2003-02-15 01:01:17 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2003-03-04 03:12:34 +01:00
|
|
|
dsound_capture = NULL;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) released\n",This);
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return uRef;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_CreateCaptureBuffer(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
|
|
|
|
LPUNKNOWN pUnk )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
HRESULT hr;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE( "(%p,%p,%p,%p)\n",This,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpcDSCBufferDesc == NULL) {
|
|
|
|
WARN("invalid parameter: lpcDSCBufferDesc == NULL)\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lplpDSCaptureBuffer == NULL) {
|
|
|
|
WARN("invalid parameter: lplpDSCaptureBuffer == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pUnk != NULL) {
|
|
|
|
WARN("invalid parameter: pUnk != NULL\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
/* FIXME: We can only have one buffer so what do we do here? */
|
|
|
|
if (This->capture_buffer) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("lnvalid parameter: already has buffer\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM; /* DSERR_GENERIC ? */
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
hr = DSOUND_CreateDirectSoundCaptureBuffer( This, lpcDSCBufferDesc,
|
|
|
|
(LPVOID*)lplpDSCaptureBuffer );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hr != DS_OK)
|
|
|
|
WARN("DSOUND_CreateDirectSoundCaptureBuffer failed\n");
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return hr;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_GetCaps(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPDSCCAPS lpDSCCaps )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
|
|
|
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (lpDSCCaps== NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCCaps->dwSize < sizeof(*lpDSCCaps)) {
|
|
|
|
WARN("invalid parameter: lpDSCCaps->dwSize = %ld < %d\n",
|
|
|
|
lpDSCCaps->dwSize, sizeof(*lpDSCCaps));
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if ( !(This->initialized) ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
lpDSCCaps->dwFlags = This->drvcaps.dwFlags;
|
|
|
|
lpDSCCaps->dwFormats = This->drvcaps.dwFormats;
|
|
|
|
lpDSCCaps->dwChannels = This->drvcaps.dwChannels;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
TRACE("(flags=0x%08lx,format=0x%08lx,channels=%ld)\n",lpDSCCaps->dwFlags,
|
|
|
|
lpDSCCaps->dwFormats, lpDSCCaps->dwChannels);
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_Initialize(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCGUID lpcGUID )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-03-15 01:54:11 +01:00
|
|
|
HRESULT err = DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
unsigned wid, widn;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureImpl,iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (!This) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("invalid parameter: This == NULL\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (This->initialized) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("already initialized\n");
|
|
|
|
return DSERR_ALREADYINITIALIZED;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
widn = waveInGetNumDevs();
|
|
|
|
|
|
|
|
if (!widn) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("no audio devices found\n");
|
|
|
|
return DSERR_NODRIVER;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
/* Get dsound configuration */
|
|
|
|
setup_dsound_options();
|
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
/* enumerate WINMM audio devices and find the one we want */
|
|
|
|
for (wid=0; wid<widn; wid++) {
|
|
|
|
GUID guid;
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDGUID,(DWORD)(&guid),0));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("waveInMessage failed; err=%lx\n",err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
if (IsEqualGUID( lpcGUID, &guid) ) {
|
|
|
|
err = DS_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&(This->driver),0));
|
|
|
|
if ( (err != DS_OK) && (err != DSERR_UNSUPPORTED) ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("waveInMessage failed; err=%lx\n",err);
|
|
|
|
return err;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
err = DS_OK;
|
|
|
|
|
2003-03-06 23:46:34 +01:00
|
|
|
/* Disable the direct sound driver to force emulation if requested. */
|
|
|
|
if (ds_hw_accel == DS_HW_ACCEL_EMULATION)
|
|
|
|
This->driver = NULL;
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
/* Get driver description */
|
|
|
|
if (This->driver) {
|
|
|
|
TRACE("using DirectSound driver\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriver_GetDriverDesc(This->driver, &(This->drvdesc));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetDriverDesc failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
|
|
|
TRACE("using WINMM\n");
|
|
|
|
/* if no DirectSound interface available, use WINMM API instead */
|
|
|
|
This->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN |
|
|
|
|
DSDDESC_DOMMSYSTEMSETFORMAT;
|
|
|
|
}
|
2003-04-05 07:11:02 +02:00
|
|
|
|
|
|
|
This->drvdesc.dnDevNode = wid;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
/* open the DirectSound driver if available */
|
|
|
|
if (This->driver && (err == DS_OK))
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriver_Open(This->driver);
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
if (err == DS_OK) {
|
|
|
|
This->initialized = TRUE;
|
|
|
|
|
|
|
|
/* the driver is now open, so it's now allowed to call GetCaps */
|
|
|
|
if (This->driver) {
|
2003-03-06 23:46:34 +01:00
|
|
|
This->drvcaps.dwSize = sizeof(This->drvcaps);
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriver_GetCaps(This->driver,&(This->drvcaps));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetCaps failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else /*if (This->hwi)*/ {
|
2003-02-15 01:01:17 +01:00
|
|
|
WAVEINCAPSA wic;
|
2003-03-04 03:12:34 +01:00
|
|
|
err = mmErr(waveInGetDevCapsA((UINT)This->drvdesc.dnDevNode, &wic, sizeof(wic)));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
if (err == DS_OK) {
|
|
|
|
This->drvcaps.dwFlags = 0;
|
|
|
|
strncpy(This->drvdesc.szDrvName, wic.szPname,
|
|
|
|
sizeof(This->drvdesc.szDrvName));
|
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
This->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER;
|
2003-03-04 03:12:34 +01:00
|
|
|
This->drvcaps.dwFormats = wic.dwFormats;
|
|
|
|
This->drvcaps.dwChannels = wic.wChannels;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return err;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectSoundCapture) dscvt =
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureImpl_AddRef,
|
|
|
|
IDirectSoundCaptureImpl_Release,
|
|
|
|
|
|
|
|
/* IDirectSoundCapture methods */
|
|
|
|
IDirectSoundCaptureImpl_CreateCaptureBuffer,
|
|
|
|
IDirectSoundCaptureImpl_GetCaps,
|
|
|
|
IDirectSoundCaptureImpl_Initialize
|
2002-06-13 21:15:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT
|
2003-02-15 01:01:17 +01:00
|
|
|
DSOUND_CreateDirectSoundCaptureBuffer(
|
|
|
|
IDirectSoundCaptureImpl *ipDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
LPWAVEFORMATEX wfex;
|
|
|
|
TRACE( "(%p,%p)\n", lpcDSCBufferDesc, ppobj );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (ipDSC == NULL) {
|
|
|
|
WARN("invalid parameter: ipDSC == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpcDSCBufferDesc == NULL) {
|
|
|
|
WARN("invalid parameter: lpcDSCBufferDesc == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter: ppobj == NULL\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (lpcDSCBufferDesc->dwSize < sizeof(DSCBUFFERDESC)) ||
|
|
|
|
(lpcDSCBufferDesc->dwBufferBytes == 0) ||
|
|
|
|
(lpcDSCBufferDesc->lpwfxFormat == NULL) ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("invalid lpcDSCBufferDesc\n");
|
2003-05-22 05:39:13 +02:00
|
|
|
*ppobj = NULL;
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !ipDSC->initialized ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("not initialized\n");
|
2003-05-22 05:39:13 +02:00
|
|
|
*ppobj = NULL;
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_UNINITIALIZED;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
wfex = lpcDSCBufferDesc->lpwfxFormat;
|
|
|
|
|
|
|
|
if (wfex) {
|
|
|
|
TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
|
|
|
|
"bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
|
|
|
|
wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
|
|
|
|
wfex->nAvgBytesPerSec, wfex->nBlockAlign,
|
|
|
|
wfex->wBitsPerSample, wfex->cbSize);
|
|
|
|
|
2003-04-12 01:59:19 +02:00
|
|
|
if (wfex->wFormatTag == WAVE_FORMAT_PCM)
|
|
|
|
memcpy(&(ipDSC->wfx), wfex, sizeof(WAVEFORMATEX));
|
2003-02-15 01:01:17 +01:00
|
|
|
else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("non PCM formats not supported\n");
|
2003-05-22 05:39:13 +02:00
|
|
|
*ppobj = NULL;
|
2003-04-12 01:59:19 +02:00
|
|
|
return DSERR_BADFORMAT;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
} else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("lpcDSCBufferDesc->lpwfxFormat == 0\n");
|
2003-05-22 05:39:13 +02:00
|
|
|
*ppobj = NULL;
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_INVALIDPARAM; /* FIXME: DSERR_BADFORMAT ? */
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(IDirectSoundCaptureBufferImpl));
|
|
|
|
|
|
|
|
if ( *ppobj == NULL ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("out of memory\n");
|
2003-05-22 05:39:13 +02:00
|
|
|
*ppobj = NULL;
|
2003-03-04 03:12:34 +01:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
2003-03-04 03:12:34 +01:00
|
|
|
HRESULT err = DS_OK;
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,*ppobj);
|
|
|
|
|
|
|
|
This->ref = 1;
|
|
|
|
This->dsound = ipDSC;
|
|
|
|
This->dsound->capture_buffer = This;
|
2003-09-02 01:58:43 +02:00
|
|
|
This->notify = NULL;
|
|
|
|
This->nrofnotifies = 0;
|
|
|
|
This->hwnotify = NULL;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
This->pdscbd = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
lpcDSCBufferDesc->dwSize);
|
|
|
|
if (This->pdscbd)
|
|
|
|
memcpy(This->pdscbd, lpcDSCBufferDesc, lpcDSCBufferDesc->dwSize);
|
|
|
|
else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("no memory\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
This->dsound->capture_buffer = 0;
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-04-10 20:17:34 +02:00
|
|
|
This->lpVtbl = &dscbvt;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (ipDSC->driver) {
|
|
|
|
err = IDsCaptureDriver_CreateCaptureBuffer(ipDSC->driver,
|
|
|
|
&(ipDSC->wfx),0,0,&(ipDSC->buflen),&(ipDSC->buffer),(LPVOID*)&(ipDSC->hwbuf));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
|
2003-04-12 01:59:19 +02:00
|
|
|
This->dsound->capture_buffer = 0;
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
2003-03-04 03:12:34 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LPBYTE newbuf;
|
|
|
|
DWORD buflen;
|
2003-03-06 23:46:34 +01:00
|
|
|
DWORD flags = CALLBACK_FUNCTION;
|
|
|
|
if (ds_hw_accel != DS_HW_ACCEL_EMULATION)
|
|
|
|
flags |= WAVE_DIRECTSOUND;
|
2003-03-04 03:12:34 +01:00
|
|
|
err = mmErr(waveInOpen(&(ipDSC->hwi),
|
|
|
|
ipDSC->drvdesc.dnDevNode, &(ipDSC->wfx),
|
2003-03-06 23:46:34 +01:00
|
|
|
(DWORD)DSOUND_capture_callback, (DWORD)ipDSC, flags));
|
2003-03-04 03:12:34 +01:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("waveInOpen failed\n");
|
2003-04-12 01:59:19 +02:00
|
|
|
This->dsound->capture_buffer = 0;
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
2003-03-04 03:12:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
buflen = lpcDSCBufferDesc->dwBufferBytes;
|
|
|
|
TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->buffer);
|
|
|
|
newbuf = (LPBYTE)HeapReAlloc(GetProcessHeap(),0,ipDSC->buffer,buflen);
|
|
|
|
|
|
|
|
if (newbuf == NULL) {
|
|
|
|
WARN("failed to allocate capture buffer\n");
|
|
|
|
err = DSERR_OUTOFMEMORY;
|
|
|
|
/* but the old buffer might still exist and must be re-prepared */
|
|
|
|
} else {
|
|
|
|
ipDSC->buffer = newbuf;
|
|
|
|
ipDSC->buflen = buflen;
|
|
|
|
}
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundCaptureNotify
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundCaptureNotifyImpl,iface);
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (This->dscb == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IDirectSoundCaptureBuffer_QueryInterface((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb, riid, ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundCaptureNotifyImpl,iface);
|
|
|
|
DWORD ref;
|
|
|
|
|
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
|
|
|
|
|
|
|
ref = InterlockedIncrement(&(This->ref));
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundCaptureNotifyImpl,iface);
|
|
|
|
DWORD ref;
|
|
|
|
|
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&(This->ref));
|
|
|
|
if (ref == 0) {
|
|
|
|
This->dscb->notify=NULL;
|
|
|
|
IDirectSoundCaptureBuffer_Release((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
TRACE("(%p) released\n",This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
DWORD howmuch,
|
|
|
|
LPCDSBPOSITIONNOTIFY notify)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundCaptureNotifyImpl,iface);
|
|
|
|
TRACE("(%p,0x%08lx,%p)\n",This,howmuch,notify);
|
|
|
|
|
|
|
|
if (notify == NULL) {
|
|
|
|
WARN("invalid parameter: notify == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TRACE_ON(dsound)) {
|
|
|
|
int i;
|
|
|
|
for (i=0;i<howmuch;i++)
|
|
|
|
TRACE("notify at %ld to 0x%08lx\n",
|
|
|
|
notify[i].dwOffset,(DWORD)notify[i].hEventNotify);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dscb->hwnotify) {
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IDsDriverNotify_SetNotificationPositions(This->dscb->hwnotify, howmuch, notify);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverNotify_SetNotificationPositions failed\n");
|
|
|
|
return hres;
|
|
|
|
} else {
|
|
|
|
/* Make an internal copy of the caller-supplied array.
|
|
|
|
* Replace the existing copy if one is already present. */
|
|
|
|
This->dscb->notifies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
This->dscb->notifies, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
if (This->dscb->notifies == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(This->dscb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
This->dscb->nrofnotifies = howmuch;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ICOM_VTABLE(IDirectSoundNotify) dscnvt =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IDirectSoundCaptureNotifyImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureNotifyImpl_AddRef,
|
|
|
|
IDirectSoundCaptureNotifyImpl_Release,
|
|
|
|
IDirectSoundCaptureNotifyImpl_SetNotificationPositions,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirectSoundCaptureNotifyImpl_Create(
|
|
|
|
IDirectSoundCaptureBufferImpl *dscb,
|
|
|
|
IDirectSoundCaptureNotifyImpl **pdscn)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl * dscn;
|
|
|
|
TRACE("(%p,%p)\n",dscb,pdscn);
|
|
|
|
|
|
|
|
dscn = (IDirectSoundCaptureNotifyImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(dscn));
|
|
|
|
|
|
|
|
if (dscn == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dscn->ref = 0;
|
|
|
|
dscn->lpVtbl = &dscnvt;
|
|
|
|
dscn->dscb = dscb;
|
|
|
|
dscb->notify = dscn;
|
|
|
|
IDirectSoundCaptureBuffer_AddRef((LPDIRECTSOUNDCAPTUREBUFFER)dscb);
|
|
|
|
|
|
|
|
*pdscn = dscn;
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundCaptureBuffer
|
|
|
|
*/
|
2002-06-13 21:15:06 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_QueryInterface(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
HRESULT hres;
|
2003-02-15 01:01:17 +01:00
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
2003-05-02 22:16:48 +02:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirectSoundNotify8, riid ) ) {
|
2003-09-02 01:58:43 +02:00
|
|
|
if (!This->notify)
|
|
|
|
hres = IDirectSoundCaptureNotifyImpl_Create(This, &This->notify);
|
2003-05-02 22:16:48 +02:00
|
|
|
if (This->notify) {
|
|
|
|
if (This->dsound->hwbuf) {
|
2003-09-02 01:58:43 +02:00
|
|
|
hres = IDsCaptureDriverBuffer_QueryInterface(This->dsound->hwbuf,
|
|
|
|
&IID_IDsDriverNotify, (LPVOID*)&(This->hwnotify));
|
|
|
|
if (hres != DS_OK) {
|
2003-05-02 22:16:48 +02:00
|
|
|
WARN("IDsCaptureDriverBuffer_QueryInterface failed\n");
|
|
|
|
*ppobj = 0;
|
2003-09-02 01:58:43 +02:00
|
|
|
return hres;
|
2003-05-02 22:16:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSoundNotify_AddRef((LPDIRECTSOUNDNOTIFY)This->notify);
|
|
|
|
*ppobj = (LPVOID)This->notify;
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("IID_IDirectSoundNotify\n");
|
2003-05-02 22:16:48 +02:00
|
|
|
return E_FAIL;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-02 22:16:48 +02:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundCaptureBuffer, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirectSoundCaptureBuffer8, riid ) ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
IDirectSoundCaptureBuffer8_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2003-03-15 01:54:11 +01:00
|
|
|
FIXME("(%p,%s,%p) unsupported GUID\n", This, debugstr_guid(riid), ppobj);
|
2003-05-02 22:16:48 +02:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
assert(This->dsound);
|
|
|
|
|
|
|
|
EnterCriticalSection( &(This->dsound->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
uRef = ++(This->ref);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection( &(This->dsound->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return uRef;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
assert(This->dsound);
|
|
|
|
|
|
|
|
EnterCriticalSection( &(This->dsound->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
uRef = --(This->ref);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection( &(This->dsound->lock) );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if ( uRef == 0 ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("deleting object\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->pdscbd)
|
|
|
|
HeapFree(GetProcessHeap(),0, This->pdscbd);
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (This->dsound->hwi) {
|
|
|
|
waveInReset(This->dsound->hwi);
|
|
|
|
waveInClose(This->dsound->hwi);
|
|
|
|
if (This->dsound->pwave) {
|
|
|
|
HeapFree(GetProcessHeap(),0, This->dsound->pwave);
|
|
|
|
This->dsound->pwave = 0;
|
|
|
|
}
|
|
|
|
This->dsound->hwi = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound->hwbuf)
|
|
|
|
IDsCaptureDriverBuffer_Release(This->dsound->hwbuf);
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
/* remove from IDirectSoundCaptureImpl */
|
|
|
|
if (This->dsound)
|
|
|
|
This->dsound->capture_buffer = NULL;
|
|
|
|
else
|
|
|
|
ERR("does not reference dsound\n");
|
|
|
|
|
2003-05-02 22:16:48 +02:00
|
|
|
if (This->notify)
|
|
|
|
IDirectSoundNotify_Release((LPDIRECTSOUNDNOTIFY)This->notify);
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->notifies != NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->notifies);
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) released\n",This);
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return uRef;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCaps(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDSCBCAPS lpDSCBCaps )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p,%p)\n", This, lpDSCBCaps );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (lpDSCBCaps == NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCBCaps == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCBCaps->dwSize < sizeof(DSCBCAPS)) {
|
|
|
|
WARN("invalid parameter: lpDSCBCaps->dwSize = %ld < %d\n",
|
|
|
|
lpDSCBCaps->dwSize, sizeof(DSCBCAPS));
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpDSCBCaps->dwSize = sizeof(DSCBCAPS);
|
|
|
|
lpDSCBCaps->dwFlags = This->flags;
|
|
|
|
lpDSCBCaps->dwBufferBytes = This->pdscbd->dwBufferBytes;
|
|
|
|
lpDSCBCaps->dwReserved = 0;
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCurrentPosition(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwCapturePosition,
|
|
|
|
LPDWORD lpdwReadPosition )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p,%p,%p)\n", This, lpdwCapturePosition, lpdwReadPosition );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound->driver) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres;
|
|
|
|
hres = IDsCaptureDriverBuffer_GetPosition(This->dsound->hwbuf, lpdwCapturePosition, lpdwReadPosition );
|
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriverBuffer_GetPosition failed\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
} else if (This->dsound->hwi) {
|
2003-03-06 23:46:34 +01:00
|
|
|
EnterCriticalSection(&(This->dsound->lock));
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("old This->dsound->state=%ld\n",This->dsound->state);
|
2003-02-15 01:01:17 +01:00
|
|
|
if (lpdwCapturePosition) {
|
|
|
|
MMTIME mtime;
|
|
|
|
mtime.wType = TIME_BYTES;
|
|
|
|
waveInGetPosition(This->dsound->hwi, &mtime, sizeof(mtime));
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("mtime.u.cb=%ld,This->dsound->buflen=%ld\n", mtime.u.cb,
|
|
|
|
This->dsound->buflen);
|
|
|
|
mtime.u.cb = mtime.u.cb % This->dsound->buflen;
|
2003-02-15 01:01:17 +01:00
|
|
|
*lpdwCapturePosition = mtime.u.cb;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (lpdwReadPosition) {
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->dsound->state == STATE_STARTING) {
|
2003-03-04 03:12:34 +01:00
|
|
|
if (lpdwCapturePosition)
|
|
|
|
This->dsound->read_position = *lpdwCapturePosition;
|
2003-02-15 01:01:17 +01:00
|
|
|
This->dsound->state = STATE_CAPTURING;
|
|
|
|
}
|
|
|
|
*lpdwReadPosition = This->dsound->read_position;
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("new This->dsound->state=%ld\n",This->dsound->state);
|
2003-03-06 23:46:34 +01:00
|
|
|
LeaveCriticalSection(&(This->dsound->lock));
|
2003-03-04 03:12:34 +01:00
|
|
|
if (lpdwCapturePosition) TRACE("*lpdwCapturePosition=%ld\n",*lpdwCapturePosition);
|
|
|
|
if (lpdwReadPosition) TRACE("*lpdwReadPosition=%ld\n",*lpdwReadPosition);
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("no driver\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFormat(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPWAVEFORMATEX lpwfxFormat,
|
|
|
|
DWORD dwSizeAllocated,
|
|
|
|
LPDWORD lpdwSizeWritten )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p,%p,0x%08lx,%p)\n", This, lpwfxFormat, dwSizeAllocated,
|
|
|
|
lpdwSizeWritten );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: use real size for extended formats someday */
|
|
|
|
if (dwSizeAllocated > sizeof(This->dsound->wfx))
|
|
|
|
dwSizeAllocated = sizeof(This->dsound->wfx);
|
|
|
|
if (lpwfxFormat) { /* NULL is valid (just want size) */
|
|
|
|
memcpy(lpwfxFormat,&(This->dsound->wfx),dwSizeAllocated);
|
|
|
|
if (lpdwSizeWritten)
|
|
|
|
*lpdwSizeWritten = dwSizeAllocated;
|
|
|
|
} else {
|
|
|
|
if (lpdwSizeWritten)
|
|
|
|
*lpdwSizeWritten = sizeof(This->dsound->wfx);
|
|
|
|
else {
|
2003-05-22 05:39:13 +02:00
|
|
|
TRACE("invalid parameter: lpdwSizeWritten = NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetStatus(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwStatus )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE( "(%p, %p), thread is %04lx\n", This, lpdwStatus, GetCurrentThreadId() );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpdwStatus == NULL) {
|
|
|
|
WARN("invalid parameter: lpdwStatus == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
*lpdwStatus = 0;
|
2003-03-06 23:46:34 +01:00
|
|
|
EnterCriticalSection(&(This->dsound->lock));
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("old This->dsound->state=%ld, old lpdwStatus=%08lx\n",This->dsound->state,*lpdwStatus);
|
2003-02-15 01:01:17 +01:00
|
|
|
if ((This->dsound->state == STATE_STARTING) ||
|
|
|
|
(This->dsound->state == STATE_CAPTURING)) {
|
|
|
|
*lpdwStatus |= DSCBSTATUS_CAPTURING;
|
|
|
|
if (This->flags & DSCBSTART_LOOPING)
|
|
|
|
*lpdwStatus |= DSCBSTATUS_LOOPING;
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("new This->dsound->state=%ld, new lpdwStatus=%08lx\n",This->dsound->state,*lpdwStatus);
|
2003-03-06 23:46:34 +01:00
|
|
|
LeaveCriticalSection(&(This->dsound->lock));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("status=%lx\n", *lpdwStatus);
|
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Initialize(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDIRECTSOUNDCAPTURE lpDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBDesc )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
FIXME( "(%p,%p,%p): stub\n", This, lpDSC, lpcDSCBDesc );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Lock(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwReadCusor,
|
|
|
|
DWORD dwReadBytes,
|
|
|
|
LPVOID* lplpvAudioPtr1,
|
|
|
|
LPDWORD lpdwAudioBytes1,
|
|
|
|
LPVOID* lplpvAudioPtr2,
|
|
|
|
LPDWORD lpdwAudioBytes2,
|
|
|
|
DWORD dwFlags )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-03-04 03:12:34 +01:00
|
|
|
HRESULT err = DS_OK;
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE( "(%p,%08lu,%08lu,%p,%p,%p,%p,0x%08lx) at %ld\n", This, dwReadCusor,
|
2003-02-15 01:01:17 +01:00
|
|
|
dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2,
|
2003-03-04 03:12:34 +01:00
|
|
|
lpdwAudioBytes2, dwFlags, GetTickCount() );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lplpvAudioPtr1 == NULL) {
|
|
|
|
WARN("invalid parameter: lplpvAudioPtr1 == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpdwAudioBytes1 == NULL) {
|
|
|
|
WARN("invalid parameter: lpdwAudioBytes1 == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection(&(This->dsound->lock));
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->dsound->driver) {
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriverBuffer_Lock(This->dsound->hwbuf, lplpvAudioPtr1,
|
|
|
|
lpdwAudioBytes1, lplpvAudioPtr2, lpdwAudioBytes2,
|
|
|
|
dwReadCusor, dwReadBytes, dwFlags);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (err != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Lock failed\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
} else if (This->dsound->hwi) {
|
|
|
|
*lplpvAudioPtr1 = This->dsound->buffer + dwReadCusor;
|
|
|
|
if ( (dwReadCusor + dwReadBytes) > This->dsound->buflen) {
|
|
|
|
*lpdwAudioBytes1 = This->dsound->buflen - dwReadCusor;
|
2003-03-04 03:12:34 +01:00
|
|
|
if (lplpvAudioPtr2)
|
|
|
|
*lplpvAudioPtr2 = This->dsound->buffer;
|
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = dwReadBytes - *lpdwAudioBytes1;
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
|
|
|
*lpdwAudioBytes1 = dwReadBytes;
|
2003-03-04 03:12:34 +01:00
|
|
|
if (lplpvAudioPtr2)
|
|
|
|
*lplpvAudioPtr2 = 0;
|
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = 0;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TRACE("invalid call\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
err = DSERR_INVALIDCALL; /* DSERR_NODRIVER ? */
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection(&(This->dsound->lock));
|
|
|
|
|
|
|
|
return err;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Start(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwFlags )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
HRESULT err = DS_OK;
|
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p,0x%08lx)\n", This, dwFlags );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (This->dsound->driver == 0) && (This->dsound->hwi == 0) ) {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("no driver\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection(&(This->dsound->lock));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
This->flags = dwFlags;
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("old This->dsound->state=%ld\n",This->dsound->state);
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->dsound->state == STATE_STOPPED)
|
|
|
|
This->dsound->state = STATE_STARTING;
|
|
|
|
else if (This->dsound->state == STATE_STOPPING)
|
|
|
|
This->dsound->state = STATE_CAPTURING;
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("new This->dsound->state=%ld\n",This->dsound->state);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&(This->dsound->lock));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
if (This->dsound->driver) {
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriverBuffer_Start(This->dsound->hwbuf, dwFlags);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (err != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Start failed\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
return err;
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
|
|
|
IDirectSoundCaptureImpl* ipDSC = This->dsound;
|
|
|
|
|
|
|
|
if (ipDSC->buffer) {
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->nrofnotifies) {
|
2003-03-04 03:12:34 +01:00
|
|
|
unsigned c;
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
ipDSC->nrofpwaves = This->nrofnotifies;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
/* prepare headers */
|
|
|
|
ipDSC->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->pwave,
|
2003-03-04 03:12:34 +01:00
|
|
|
ipDSC->nrofpwaves*sizeof(WAVEHDR));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
for (c = 0; c < ipDSC->nrofpwaves; c++) {
|
2003-02-15 01:01:17 +01:00
|
|
|
if (c == 0) {
|
|
|
|
ipDSC->pwave[0].lpData = ipDSC->buffer;
|
|
|
|
ipDSC->pwave[0].dwBufferLength =
|
2003-09-02 01:58:43 +02:00
|
|
|
This->notifies[0].dwOffset + 1;
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
|
|
|
ipDSC->pwave[c].lpData = ipDSC->buffer +
|
2003-09-02 01:58:43 +02:00
|
|
|
This->notifies[c-1].dwOffset + 1;
|
2003-02-15 01:01:17 +01:00
|
|
|
ipDSC->pwave[c].dwBufferLength =
|
2003-09-02 01:58:43 +02:00
|
|
|
This->notifies[c].dwOffset -
|
|
|
|
This->notifies[c-1].dwOffset;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
ipDSC->pwave[c].dwUser = (DWORD)ipDSC;
|
|
|
|
ipDSC->pwave[c].dwFlags = 0;
|
|
|
|
ipDSC->pwave[c].dwLoops = 0;
|
|
|
|
err = mmErr(waveInPrepareHeader(ipDSC->hwi,
|
|
|
|
&(ipDSC->pwave[c]),sizeof(WAVEHDR)));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
while (c--)
|
|
|
|
waveInUnprepareHeader(ipDSC->hwi,
|
|
|
|
&(ipDSC->pwave[c]),sizeof(WAVEHDR));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(ipDSC->buffer,
|
|
|
|
(ipDSC->wfx.wBitsPerSample == 16) ? 0 : 128, ipDSC->buflen);
|
2003-03-04 03:12:34 +01:00
|
|
|
} else {
|
|
|
|
TRACE("no notifiers specified\n");
|
|
|
|
/* no notifiers specified so just create a single default header */
|
|
|
|
ipDSC->nrofpwaves = 1;
|
|
|
|
ipDSC->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->pwave,sizeof(WAVEHDR));
|
|
|
|
ipDSC->pwave[0].lpData = ipDSC->buffer;
|
|
|
|
ipDSC->pwave[0].dwBufferLength = ipDSC->buflen;
|
|
|
|
ipDSC->pwave[0].dwUser = (DWORD)ipDSC;
|
|
|
|
ipDSC->pwave[0].dwFlags = 0;
|
|
|
|
ipDSC->pwave[0].dwLoops = 0;
|
|
|
|
|
|
|
|
err = mmErr(waveInPrepareHeader(ipDSC->hwi,
|
|
|
|
&(ipDSC->pwave[0]),sizeof(WAVEHDR)));
|
|
|
|
if (err != DS_OK) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("waveInPrepareHeader failed\n");
|
2003-03-04 03:12:34 +01:00
|
|
|
waveInUnprepareHeader(ipDSC->hwi,
|
|
|
|
&(ipDSC->pwave[0]),sizeof(WAVEHDR));
|
|
|
|
}
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ipDSC->index = 0;
|
|
|
|
ipDSC->read_position = 0;
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (err == DS_OK) {
|
|
|
|
err = mmErr(waveInReset(ipDSC->hwi));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
/* add the first buffer to the queue */
|
|
|
|
err = mmErr(waveInAddBuffer(ipDSC->hwi, &(ipDSC->pwave[0]), sizeof(WAVEHDR)));
|
|
|
|
if (err == DS_OK) {
|
|
|
|
/* start filling the first buffer */
|
|
|
|
err = mmErr(waveInStart(ipDSC->hwi));
|
2003-05-22 05:39:13 +02:00
|
|
|
} else
|
|
|
|
WARN("waveInAddBuffer failed\n");
|
|
|
|
} else
|
|
|
|
WARN("waveInReset failed\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("calling waveInClose because of error\n");
|
|
|
|
waveInClose(This->dsound->hwi);
|
|
|
|
This->dsound->hwi = 0;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE("returning %ld\n", err);
|
|
|
|
return err;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2003-03-04 03:12:34 +01:00
|
|
|
HRESULT err = DS_OK;
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p)\n", This );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
EnterCriticalSection(&(This->dsound->lock));
|
|
|
|
|
|
|
|
TRACE("old This->dsound->state=%ld\n",This->dsound->state);
|
|
|
|
if (This->dsound->state == STATE_CAPTURING)
|
|
|
|
This->dsound->state = STATE_STOPPING;
|
|
|
|
else if (This->dsound->state == STATE_STARTING)
|
|
|
|
This->dsound->state = STATE_STOPPED;
|
|
|
|
TRACE("new This->dsound->state=%ld\n",This->dsound->state);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&(This->dsound->lock));
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if (This->dsound->driver) {
|
2003-03-04 03:12:34 +01:00
|
|
|
err = IDsCaptureDriverBuffer_Stop(This->dsound->hwbuf);
|
|
|
|
if (err == DSERR_BUFFERLOST) {
|
|
|
|
/* Wine-only: the driver wants us to reopen the device */
|
|
|
|
IDsCaptureDriverBuffer_Release(This->dsound->hwbuf);
|
|
|
|
err = IDsCaptureDriver_CreateCaptureBuffer(This->dsound->driver,
|
|
|
|
&(This->dsound->wfx),0,0,&(This->dsound->buflen),&(This->dsound->buffer),
|
|
|
|
(LPVOID*)&(This->dsound->hwbuf));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
|
|
|
|
This->dsound->hwbuf = 0;
|
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
} else if (err != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Stop failed\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
} else if (This->dsound->hwi) {
|
2003-03-04 03:12:34 +01:00
|
|
|
err = waveInStop(This->dsound->hwi);
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("no driver\n");
|
|
|
|
err = DSERR_NODRIVER;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
TRACE( "(%p) returning 0x%08lx\n", This,err);
|
|
|
|
return err;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Unlock(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPVOID lpvAudioPtr1,
|
|
|
|
DWORD dwAudioBytes1,
|
|
|
|
LPVOID lpvAudioPtr2,
|
|
|
|
DWORD dwAudioBytes2 )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
|
|
|
TRACE( "(%p,%p,%08lu,%p,%08lu)\n", This, lpvAudioPtr1, dwAudioBytes1,
|
|
|
|
lpvAudioPtr2, dwAudioBytes2 );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpvAudioPtr1 == NULL) {
|
|
|
|
WARN("invalid parameter: lpvAudioPtr1 == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound->driver) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres;
|
|
|
|
hres = IDsCaptureDriverBuffer_Unlock(This->dsound->hwbuf, lpvAudioPtr1,
|
2003-03-04 03:12:34 +01:00
|
|
|
dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Unlock failed\n");
|
|
|
|
return hres;
|
2003-02-15 01:01:17 +01:00
|
|
|
} else if (This->dsound->hwi) {
|
|
|
|
This->dsound->read_position = (This->dsound->read_position +
|
|
|
|
(dwAudioBytes1 + dwAudioBytes2)) % This->dsound->buflen;
|
|
|
|
} else {
|
2003-03-04 03:12:34 +01:00
|
|
|
WARN("invalid call\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetObjectInPath(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
REFGUID rguidObject,
|
|
|
|
DWORD dwIndex,
|
|
|
|
REFGUID rguidInterface,
|
|
|
|
LPVOID* ppObject )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
FIXME( "(%p,%s,%lu,%s,%p): stub\n", This, debugstr_guid(rguidObject),
|
|
|
|
dwIndex, debugstr_guid(rguidInterface), ppObject );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFXStatus(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwFXCount,
|
|
|
|
LPDWORD pdwFXStatus )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
FIXME( "(%p,%lu,%p): stub\n", This, dwFXCount, pdwFXStatus );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt =
|
|
|
|
{
|
2003-02-15 01:01:17 +01:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureBufferImpl_AddRef,
|
|
|
|
IDirectSoundCaptureBufferImpl_Release,
|
|
|
|
|
|
|
|
/* IDirectSoundCaptureBuffer methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCaps,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCurrentPosition,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFormat,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetStatus,
|
|
|
|
IDirectSoundCaptureBufferImpl_Initialize,
|
|
|
|
IDirectSoundCaptureBufferImpl_Lock,
|
|
|
|
IDirectSoundCaptureBufferImpl_Start,
|
|
|
|
IDirectSoundCaptureBufferImpl_Stop,
|
|
|
|
IDirectSoundCaptureBufferImpl_Unlock,
|
|
|
|
|
|
|
|
/* IDirectSoundCaptureBuffer methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_GetObjectInPath,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFXStatus
|
2002-06-13 21:15:06 +02:00
|
|
|
};
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundCapture ClassFactory
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSCCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
DSCCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
TRACE("(%p) ref was %ld\n", This, This->ref);
|
|
|
|
return ++(This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
DSCCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
/* static class, won't be freed */
|
|
|
|
TRACE("(%p) ref was %ld\n", This, This->ref);
|
|
|
|
return --(This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSCCF_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirectSoundCapture8, riid ) ) {
|
|
|
|
return DirectSoundCaptureCreate8(0,(LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter);
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSCCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IClassFactory) DSCCF_Vtbl =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
DSCCF_QueryInterface,
|
|
|
|
DSCCF_AddRef,
|
|
|
|
DSCCF_Release,
|
|
|
|
DSCCF_CreateInstance,
|
|
|
|
DSCCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
IClassFactoryImpl DSOUND_CAPTURE_CF = { &DSCCF_Vtbl, 1 };
|
|
|
|
|
2003-03-06 23:46:34 +01:00
|
|
|
/***************************************************************************
|
2003-05-02 22:16:48 +02:00
|
|
|
* DirectSoundFullDuplexCreate8 [DSOUND.10]
|
|
|
|
*
|
|
|
|
* Create and initialize a DirectSoundFullDuplex interface.
|
2003-03-06 23:46:34 +01:00
|
|
|
*
|
2003-05-02 22:16:48 +02:00
|
|
|
* PARAMS
|
|
|
|
* pcGuidCaptureDevice [I] Address of sound capture device GUID.
|
|
|
|
* pcGuidRenderDevice [I] Address of sound render device GUID.
|
|
|
|
* pcDSCBufferDesc [I] Address of capture buffer description.
|
|
|
|
* pcDSBufferDesc [I] Address of render buffer description.
|
|
|
|
* hWnd [I] Handle to application window.
|
|
|
|
* dwLevel [I] Cooperative level.
|
|
|
|
* ppDSFD [O] Address where full duplex interface returned.
|
|
|
|
* ppDSCBuffer8 [0] Address where capture buffer interface returned.
|
|
|
|
* ppDSBuffer8 [0] Address where render buffer interface returned.
|
|
|
|
* pUnkOuter [I] Must be NULL.
|
2003-03-06 23:46:34 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
|
|
|
|
* DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI
|
|
|
|
DirectSoundFullDuplexCreate8(
|
|
|
|
LPCGUID pcGuidCaptureDevice,
|
|
|
|
LPCGUID pcGuidRenderDevice,
|
|
|
|
LPCDSCBUFFERDESC pcDSCBufferDesc,
|
|
|
|
LPCDSBUFFERDESC pcDSBufferDesc,
|
|
|
|
HWND hWnd,
|
|
|
|
DWORD dwLevel,
|
|
|
|
LPDIRECTSOUNDFULLDUPLEX *ppDSFD,
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8,
|
|
|
|
LPDIRECTSOUNDBUFFER8 *ppDSBuffer8,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
IDirectSoundFullDuplexImpl** ippDSFD=(IDirectSoundFullDuplexImpl**)ppDSFD;
|
|
|
|
TRACE("(%s,%s,%p,%p,%lx,%lx,%p,%p,%p,%p)\n", debugstr_guid(pcGuidCaptureDevice),
|
|
|
|
debugstr_guid(pcGuidRenderDevice), pcDSCBufferDesc, pcDSBufferDesc,
|
|
|
|
(DWORD)hWnd, dwLevel, ppDSFD, ppDSCBuffer8, ppDSBuffer8, pUnkOuter);
|
|
|
|
|
|
|
|
if ( pUnkOuter ) {
|
|
|
|
WARN("pUnkOuter != 0\n");
|
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ippDSFD = (IDirectSoundFullDuplexImpl*)HeapAlloc(GetProcessHeap(),
|
2003-03-15 01:54:11 +01:00
|
|
|
HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
|
2003-03-06 23:46:34 +01:00
|
|
|
|
|
|
|
if (*ippDSFD == NULL) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("out of memory\n");
|
2003-03-06 23:46:34 +01:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2003-05-22 05:39:13 +02:00
|
|
|
} else {
|
|
|
|
HRESULT hres;
|
2003-03-06 23:46:34 +01:00
|
|
|
ICOM_THIS(IDirectSoundFullDuplexImpl, *ippDSFD);
|
|
|
|
|
|
|
|
This->ref = 1;
|
2003-04-10 20:17:34 +02:00
|
|
|
This->lpVtbl = &dsfdvt;
|
2003-03-06 23:46:34 +01:00
|
|
|
|
|
|
|
InitializeCriticalSection( &(This->lock) );
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDirectSoundFullDuplexImpl_Initialize( (LPDIRECTSOUNDFULLDUPLEX)This,
|
2003-03-06 23:46:34 +01:00
|
|
|
pcGuidCaptureDevice, pcGuidRenderDevice,
|
|
|
|
pcDSCBufferDesc, pcDSBufferDesc,
|
|
|
|
hWnd, dwLevel, ppDSCBuffer8, ppDSBuffer8);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
|
|
|
|
return hres;
|
2003-03-06 23:46:34 +01:00
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
|
|
|
|
return DSERR_GENERIC;
|
2003-03-06 23:46:34 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundFullDuplexImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDFULLDUPLEX iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundFullDuplexImpl,iface);
|
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2003-03-04 03:12:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
|
|
|
|
{
|
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundFullDuplexImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2003-03-04 03:12:34 +01:00
|
|
|
|
|
|
|
EnterCriticalSection( &(This->lock) );
|
|
|
|
|
|
|
|
uRef = ++(This->ref);
|
2003-03-06 23:46:34 +01:00
|
|
|
|
2003-03-04 03:12:34 +01:00
|
|
|
LeaveCriticalSection( &(This->lock) );
|
|
|
|
|
|
|
|
return uRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
|
|
|
|
{
|
|
|
|
ULONG uRef;
|
|
|
|
ICOM_THIS(IDirectSoundFullDuplexImpl,iface);
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
|
2003-03-04 03:12:34 +01:00
|
|
|
|
|
|
|
EnterCriticalSection( &(This->lock) );
|
|
|
|
|
|
|
|
uRef = --(This->ref);
|
|
|
|
|
|
|
|
LeaveCriticalSection( &(This->lock) );
|
|
|
|
|
|
|
|
if ( uRef == 0 ) {
|
|
|
|
DeleteCriticalSection( &(This->lock) );
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p) released\n",This);
|
2003-03-04 03:12:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return uRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundFullDuplexImpl_Initialize(
|
|
|
|
LPDIRECTSOUNDFULLDUPLEX iface,
|
|
|
|
LPCGUID pCaptureGuid,
|
|
|
|
LPCGUID pRendererGuid,
|
|
|
|
LPCDSCBUFFERDESC lpDscBufferDesc,
|
|
|
|
LPCDSBUFFERDESC lpDsBufferDesc,
|
|
|
|
HWND hWnd,
|
|
|
|
DWORD dwLevel,
|
|
|
|
LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
|
|
|
|
LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 )
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectSoundFullDuplexImpl,iface);
|
|
|
|
IDirectSoundCaptureBufferImpl** ippdscb=(IDirectSoundCaptureBufferImpl**)lplpDirectSoundCaptureBuffer8;
|
|
|
|
IDirectSoundBufferImpl** ippdsc=(IDirectSoundBufferImpl**)lplpDirectSoundBuffer8;
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
FIXME( "(%p,%s,%s,%p,%p,%lx,%lx,%p,%p) stub!\n", This, debugstr_guid(pCaptureGuid),
|
2003-03-04 03:12:34 +01:00
|
|
|
debugstr_guid(pRendererGuid), lpDscBufferDesc, lpDsBufferDesc, (DWORD)hWnd, dwLevel,
|
|
|
|
ippdscb, ippdsc);
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectSoundFullDuplex) dsfdvt =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundFullDuplexImpl_QueryInterface,
|
|
|
|
IDirectSoundFullDuplexImpl_AddRef,
|
|
|
|
IDirectSoundFullDuplexImpl_Release,
|
|
|
|
|
|
|
|
/* IDirectSoundFullDuplex methods */
|
|
|
|
IDirectSoundFullDuplexImpl_Initialize
|
|
|
|
};
|
2003-08-07 00:57:24 +02:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundFullDuplex ClassFactory
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSFDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
DSFDCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
TRACE("(%p) ref was %ld\n", This, This->ref);
|
|
|
|
return ++(This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
DSFDCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
/* static class, won't be freed */
|
|
|
|
TRACE("(%p) ref was %ld\n", This, This->ref);
|
|
|
|
return --(This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSFDCF_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundFullDuplex, riid ) ) {
|
|
|
|
/* FIXME: how do we do this one ? */
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
DSFDCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IClassFactoryImpl,iface);
|
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IClassFactory) DSFDCF_Vtbl =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
DSFDCF_QueryInterface,
|
|
|
|
DSFDCF_AddRef,
|
|
|
|
DSFDCF_Release,
|
|
|
|
DSFDCF_CreateInstance,
|
|
|
|
DSFDCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
IClassFactoryImpl DSOUND_FULLDUPLEX_CF = { &DSFDCF_Vtbl, 1 };
|