2003-02-15 00:01:17 +00:00
|
|
|
/* DirectSoundCapture
|
2002-06-13 19:15:06 +00: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 02:12:34 +00:00
|
|
|
* Implement FX support.
|
2005-06-04 09:38:14 +00:00
|
|
|
* Implement both IDirectSoundCaptureBuffer and IDirectSoundCaptureBuffer8
|
|
|
|
* Make DirectSoundCaptureCreate and DirectSoundCaptureCreate8 behave differently
|
2002-06-13 19:15:06 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-01-24 13:31:27 +00:00
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
2002-06-13 19:15:06 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "mmsystem.h"
|
2003-02-15 00:01:17 +00:00
|
|
|
#include "mmddk.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "winreg.h"
|
2003-02-15 00:01:17 +00:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winnls.h"
|
2002-06-13 19:15:06 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
2003-02-15 00:01:17 +00:00
|
|
|
#include "dsdriver.h"
|
|
|
|
#include "dsound_private.h"
|
2002-06-13 19:15:06 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
|
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCGUID lpcGUID );
|
2004-10-21 20:57:26 +00:00
|
|
|
static ULONG WINAPI IDirectSoundCaptureImpl_Release(
|
2003-03-04 02:12:34 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE iface );
|
2004-10-21 20:57:26 +00:00
|
|
|
static ULONG WINAPI IDirectSoundCaptureBufferImpl_Release(
|
2003-03-04 02:12:34 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface );
|
2003-02-15 00:01:17 +00:00
|
|
|
static HRESULT DSOUND_CreateDirectSoundCaptureBuffer(
|
2004-10-21 20:57:26 +00:00
|
|
|
IDirectSoundCaptureImpl *ipDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
2003-02-15 00:01:17 +00:00
|
|
|
LPVOID* ppobj );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IDirectSoundCaptureVtbl dscvt;
|
|
|
|
static const IDirectSoundCaptureBuffer8Vtbl dscbvt;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-11-14 21:03:24 +00:00
|
|
|
static const char * captureStateString[] = {
|
|
|
|
"STATE_STOPPED",
|
|
|
|
"STATE_STARTING",
|
|
|
|
"STATE_CAPTURING",
|
|
|
|
"STATE_STOPPING"
|
|
|
|
};
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
HRESULT WINAPI IDirectSoundCaptureImpl_Create(
|
|
|
|
LPDIRECTSOUNDCAPTURE8 * ppDSC)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureImpl *pDSC;
|
|
|
|
TRACE("(%p)\n", ppDSC);
|
|
|
|
|
|
|
|
/* Allocate memory */
|
|
|
|
pDSC = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundCaptureImpl));
|
|
|
|
if (pDSC == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppDSC = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDSC->lpVtbl = &dscvt;
|
|
|
|
pDSC->ref = 0;
|
|
|
|
pDSC->device = NULL;
|
|
|
|
|
|
|
|
*ppDSC = (LPDIRECTSOUNDCAPTURE8)pDSC;
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI DSOUND_CaptureCreate(
|
|
|
|
LPDIRECTSOUNDCAPTURE *ppDSC,
|
|
|
|
IUnknown *pUnkOuter)
|
|
|
|
{
|
|
|
|
LPDIRECTSOUNDCAPTURE pDSC;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p,%p)\n",ppDSC,pUnkOuter);
|
|
|
|
|
|
|
|
/* Get dsound configuration */
|
|
|
|
setup_dsound_options();
|
|
|
|
|
|
|
|
hr = IDirectSoundCaptureImpl_Create(&pDSC);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
IDirectSoundCapture_AddRef(pDSC);
|
|
|
|
*ppDSC = pDSC;
|
|
|
|
} else {
|
|
|
|
WARN("IDirectSoundCaptureImpl_Create failed\n");
|
|
|
|
*ppDSC = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI DSOUND_CaptureCreate8(
|
|
|
|
LPDIRECTSOUNDCAPTURE8 *ppDSC8,
|
|
|
|
IUnknown *pUnkOuter)
|
|
|
|
{
|
|
|
|
LPDIRECTSOUNDCAPTURE8 pDSC8;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p,%p)\n",ppDSC8,pUnkOuter);
|
|
|
|
|
|
|
|
/* Get dsound configuration */
|
|
|
|
setup_dsound_options();
|
|
|
|
|
|
|
|
hr = IDirectSoundCaptureImpl_Create(&pDSC8);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
IDirectSoundCapture_AddRef(pDSC8);
|
|
|
|
*ppDSC8 = pDSC8;
|
|
|
|
} else {
|
|
|
|
WARN("IDirectSoundCaptureImpl_Create failed\n");
|
|
|
|
*ppDSC8 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2002-06-13 19:15:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureCreate [DSOUND.6]
|
|
|
|
*
|
2003-05-02 20:16:48 +00: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 19:15:06 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
|
|
|
|
* DSERR_OUTOFMEMORY
|
2003-05-02 20:16:48 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* lpcGUID must be one of the values returned from DirectSoundCaptureEnumerate
|
2004-10-21 20:57:26 +00:00
|
|
|
* or NULL for the default device or DSDEVID_DefaultCapture or
|
2003-05-02 20:16:48 +00:00
|
|
|
* DSDEVID_DefaultVoiceCapture.
|
|
|
|
*
|
|
|
|
* DSERR_ALLOCATED is returned for sound devices that do not support full duplex.
|
2002-06-13 19:15:06 +00:00
|
|
|
*/
|
2005-06-04 09:38:14 +00:00
|
|
|
HRESULT WINAPI DirectSoundCaptureCreate(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPCGUID lpcGUID,
|
2005-06-04 09:38:14 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE *ppDSC,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2005-06-04 09:38:14 +00:00
|
|
|
HRESULT hr;
|
|
|
|
LPDIRECTSOUNDCAPTURE pDSC;
|
|
|
|
TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC, pUnkOuter);
|
|
|
|
|
|
|
|
if (ppDSC == NULL) {
|
|
|
|
WARN("invalid parameter: ppDSC == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (pUnkOuter) {
|
2003-05-02 20:16:48 +00:00
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
*ppDSC = NULL;
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
hr = DSOUND_CaptureCreate(&pDSC, (IUnknown *)pUnkOuter);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSoundCapture_Initialize(pDSC, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
IDirectSoundCapture_Release(pDSC);
|
|
|
|
pDSC = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppDSC = pDSC;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureCreate8 [DSOUND.12]
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
|
|
|
|
* DSERR_OUTOFMEMORY
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DirectSoundCaptureCreate8(
|
|
|
|
LPCGUID lpcGUID,
|
|
|
|
LPDIRECTSOUNDCAPTURE8 *ppDSC8,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
LPDIRECTSOUNDCAPTURE8 pDSC8;
|
|
|
|
TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC8, pUnkOuter);
|
|
|
|
|
|
|
|
if (ppDSC8 == NULL) {
|
|
|
|
WARN("invalid parameter: ppDSC8 == NULL\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (pUnkOuter) {
|
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
|
|
|
*ppDSC8 = NULL;
|
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DSOUND_CaptureCreate8(&pDSC8, (IUnknown *)pUnkOuter);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSoundCapture_Initialize(pDSC8, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
IDirectSoundCapture_Release(pDSC8);
|
|
|
|
pDSC8 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppDSC8 = pDSC8;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DirectSoundCaptureDevice_Create(
|
|
|
|
DirectSoundCaptureDevice ** ppDevice)
|
|
|
|
{
|
|
|
|
DirectSoundCaptureDevice * device;
|
|
|
|
TRACE("(%p)\n", ppDevice);
|
2005-06-05 17:44:30 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
/* Allocate memory */
|
|
|
|
device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DirectSoundCaptureDevice));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (device == NULL) {
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("out of memory\n");
|
2003-03-15 00:54:11 +00:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2005-06-04 09:38:14 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
device->ref = 1;
|
|
|
|
device->state = STATE_STOPPED;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
InitializeCriticalSection( &(device->lock) );
|
2005-09-09 10:19:44 +00:00
|
|
|
device->lock.DebugInfo->Spare[0] = (DWORD_PTR)"DSCAPTURE_lock";
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
*ppDevice = device;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureEnumerateA [DSOUND.7]
|
|
|
|
*
|
2003-05-02 20:16:48 +00: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 19:15:06 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_INVALIDPARAM
|
|
|
|
*/
|
2004-10-21 20:57:26 +00:00
|
|
|
HRESULT WINAPI
|
2003-02-15 00:01:17 +00:00
|
|
|
DirectSoundCaptureEnumerateA(
|
|
|
|
LPDSENUMCALLBACKA lpDSEnumCallback,
|
|
|
|
LPVOID lpContext)
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
unsigned devs, wid;
|
2003-03-15 00:54:11 +00:00
|
|
|
DSDRIVERDESC desc;
|
|
|
|
GUID guid;
|
|
|
|
int err;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
|
|
|
|
|
|
|
|
if (lpDSEnumCallback == NULL) {
|
2003-05-02 20:16:48 +00:00
|
|
|
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
devs = waveInGetNumDevs();
|
2003-03-15 00:54:11 +00:00
|
|
|
if (devs > 0) {
|
|
|
|
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
|
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2005-03-15 15:40:35 +00:00
|
|
|
if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
|
2005-09-12 15:14:06 +00:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
|
2004-08-20 20:01:31 +00:00
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
|
2005-01-28 17:21:07 +00:00
|
|
|
"Primary Sound Capture Driver",desc.szDrvname,lpContext);
|
|
|
|
if (lpDSEnumCallback(NULL, "Primary Sound Capture Driver", desc.szDrvname, lpContext) == FALSE)
|
2004-08-20 20:01:31 +00:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-03-15 00:54:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2005-09-12 15:14:06 +00:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
|
2003-03-15 00:54:11 +00:00
|
|
|
if (err == DS_OK) {
|
2004-08-20 20:01:31 +00:00
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
2005-03-15 15:40:35 +00:00
|
|
|
debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
|
|
|
|
if (lpDSEnumCallback(&DSOUND_capture_guids[wid], desc.szDesc, desc.szDrvname, lpContext) == FALSE)
|
2004-08-20 20:01:31 +00:00
|
|
|
return DS_OK;
|
2004-10-21 20:57:26 +00:00
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureEnumerateW [DSOUND.8]
|
|
|
|
*
|
2003-05-02 20:16:48 +00: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 19:15:06 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_INVALIDPARAM
|
|
|
|
*/
|
2004-10-21 20:57:26 +00:00
|
|
|
HRESULT WINAPI
|
2003-02-15 00:01:17 +00:00
|
|
|
DirectSoundCaptureEnumerateW(
|
|
|
|
LPDSENUMCALLBACKW lpDSEnumCallback,
|
|
|
|
LPVOID lpContext)
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
unsigned devs, wid;
|
2003-03-15 00:54:11 +00:00
|
|
|
DSDRIVERDESC desc;
|
|
|
|
GUID guid;
|
|
|
|
int err;
|
|
|
|
WCHAR wDesc[MAXPNAMELEN];
|
|
|
|
WCHAR wName[MAXPNAMELEN];
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
|
|
|
|
|
|
|
|
if (lpDSEnumCallback == NULL) {
|
2003-05-02 20:16:48 +00:00
|
|
|
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
devs = waveInGetNumDevs();
|
2003-03-15 00:54:11 +00:00
|
|
|
if (devs > 0) {
|
|
|
|
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
|
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2005-03-15 15:40:35 +00:00
|
|
|
if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
|
2005-09-12 15:14:06 +00:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
|
2004-08-20 20:01:31 +00:00
|
|
|
if (err == DS_OK) {
|
|
|
|
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
|
2005-01-28 17:21:07 +00:00
|
|
|
"Primary Sound Capture Driver",desc.szDrvname,lpContext);
|
2004-10-21 20:57:26 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
|
2004-08-20 20:01:31 +00:00
|
|
|
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
|
2005-01-28 17:21:07 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
|
2004-08-20 20:01:31 +00:00
|
|
|
wName, sizeof(wName)/sizeof(WCHAR) );
|
|
|
|
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-03-15 00:54:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
for (wid = 0; wid < devs; ++wid) {
|
2005-09-12 15:14:06 +00:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
|
2003-03-15 00:54:11 +00:00
|
|
|
if (err == DS_OK) {
|
2004-08-20 20:01:31 +00:00
|
|
|
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
|
2005-03-15 15:40:35 +00:00
|
|
|
debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
|
2004-10-21 20:57:26 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
|
2004-08-20 20:01:31 +00:00
|
|
|
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
|
2005-01-28 17:21:07 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
|
2004-08-20 20:01:31 +00:00
|
|
|
wName, sizeof(wName)/sizeof(WCHAR) );
|
2005-03-15 15:40:35 +00:00
|
|
|
if (lpDSEnumCallback((LPGUID)&DSOUND_capture_guids[wid], wDesc, wName, lpContext) == FALSE)
|
2004-08-20 20:01:31 +00:00
|
|
|
return DS_OK;
|
2004-10-21 20:57:26 +00:00
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
static void CALLBACK
|
2003-02-15 00:01:17 +00:00
|
|
|
DSOUND_capture_callback(
|
2004-10-21 20:57:26 +00:00
|
|
|
HWAVEIN hwi,
|
|
|
|
UINT msg,
|
|
|
|
DWORD dwUser,
|
|
|
|
DWORD dw1,
|
2003-02-15 00:01:17 +00:00
|
|
|
DWORD dw2 )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2005-06-04 09:38:14 +00:00
|
|
|
DirectSoundCaptureDevice * This = (DirectSoundCaptureDevice*)dwUser;
|
2003-05-02 20:16:48 +00: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 00:01:17 +00:00
|
|
|
|
|
|
|
if (msg == MM_WIM_DATA) {
|
2004-04-06 20:08:54 +00:00
|
|
|
LPWAVEHDR pHdr = (LPWAVEHDR)dw1;
|
2003-03-04 02:12:34 +00:00
|
|
|
EnterCriticalSection( &(This->lock) );
|
2003-11-14 21:03:24 +00:00
|
|
|
TRACE("DirectSoundCapture msg=MM_WIM_DATA, old This->state=%s, old This->index=%d\n",
|
|
|
|
captureStateString[This->state],This->index);
|
2003-03-04 02:12:34 +00:00
|
|
|
if (This->state != STATE_STOPPED) {
|
2003-10-08 22:35:26 +00:00
|
|
|
int index = This->index;
|
2004-10-21 20:57:26 +00:00
|
|
|
if (This->state == STATE_STARTING) {
|
2004-04-06 20:08:54 +00:00
|
|
|
This->read_position = pHdr->dwBytesRecorded;
|
2003-03-04 02:12:34 +00:00
|
|
|
This->state = STATE_CAPTURING;
|
|
|
|
}
|
2003-09-01 23:58:43 +00:00
|
|
|
if (This->capture_buffer->nrofnotifies)
|
|
|
|
SetEvent(This->capture_buffer->notifies[This->index].hEventNotify);
|
2003-09-15 20:08:05 +00:00
|
|
|
This->index = (This->index + 1) % This->nrofpwaves;
|
2003-03-04 02:12:34 +00: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) {
|
2003-10-08 22:35:26 +00:00
|
|
|
waveInAddBuffer(hwi, &(This->pwave[index]), sizeof(WAVEHDR));
|
2003-11-14 21:03:24 +00:00
|
|
|
} else if (This->state == STATE_STOPPING) {
|
|
|
|
TRACE("stopping\n");
|
|
|
|
This->state = STATE_STOPPED;
|
|
|
|
}
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-14 21:03:24 +00:00
|
|
|
TRACE("DirectSoundCapture new This->state=%s, new This->index=%d\n",
|
|
|
|
captureStateString[This->state],This->index);
|
2003-03-04 02:12:34 +00:00
|
|
|
LeaveCriticalSection( &(This->lock) );
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("completed\n");
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2005-06-05 17:44:30 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-08-06 22:57:24 +00:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
2005-06-05 17:44:30 +00:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
|
|
|
*ppobj = This;
|
|
|
|
return DS_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
|
|
|
|
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
|
|
|
*ppobj = This;
|
|
|
|
return DS_OK;
|
2003-05-22 03:39:13 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
2005-06-05 17:44:30 +00:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref - 1);
|
|
|
|
return ref;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
static ULONG DirectSoundCaptureDevice_Release(
|
|
|
|
DirectSoundCaptureDevice * device)
|
|
|
|
{
|
|
|
|
ULONG ref;
|
|
|
|
TRACE("(%p) ref was %lu\n", device, device->ref);
|
|
|
|
|
|
|
|
device->ref--;
|
|
|
|
ref=device->ref;
|
|
|
|
if (device->ref == 0) {
|
|
|
|
TRACE("deleting object\n");
|
|
|
|
if (device->capture_buffer)
|
|
|
|
IDirectSoundCaptureBufferImpl_Release(
|
|
|
|
(LPDIRECTSOUNDCAPTUREBUFFER8) device->capture_buffer);
|
|
|
|
|
|
|
|
if (device->driver) {
|
|
|
|
IDsCaptureDriver_Close(device->driver);
|
|
|
|
IDsCaptureDriver_Release(device->driver);
|
2005-06-05 17:44:30 +00:00
|
|
|
}
|
2005-06-04 09:38:14 +00:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, device->pwfx);
|
2005-09-09 10:19:44 +00:00
|
|
|
device->lock.DebugInfo->Spare[0] = 0;
|
2005-06-04 09:38:14 +00:00
|
|
|
DeleteCriticalSection( &(device->lock) );
|
|
|
|
DSOUND_capture[device->drvdesc.dnDevNode] = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, device);
|
|
|
|
TRACE("(%p) released\n", device);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2002-06-13 19:15:06 +00:00
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref + 1);
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-02-11 11:49:05 +00:00
|
|
|
if (!ref) {
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->device)
|
|
|
|
DirectSoundCaptureDevice_Release(This->device);
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2005-02-11 11:49:05 +00:00
|
|
|
TRACE("(%p) released\n", This);
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2005-02-11 11:49:05 +00:00
|
|
|
return ref;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_CreateCaptureBuffer(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
|
|
|
|
LPUNKNOWN pUnk )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
HRESULT hr;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE( "(%p,%p,%p,%p)\n",iface,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-22 03:39:13 +00: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 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
/* FIXME: We can only have one buffer so what do we do here? */
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->device->capture_buffer) {
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("lnvalid parameter: already has buffer\n");
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM; /* DSERR_GENERIC ? */
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
hr = DSOUND_CreateDirectSoundCaptureBuffer(This, lpcDSCBufferDesc,
|
2003-02-15 00:01:17 +00:00
|
|
|
(LPVOID*)lplpDSCaptureBuffer );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
if (hr != DS_OK)
|
|
|
|
WARN("DSOUND_CreateDirectSoundCaptureBuffer failed\n");
|
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return hr;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_GetCaps(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPDSCCAPS lpDSCCaps )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-05 17:44:30 +00:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
if (lpDSCCaps== NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCCaps->dwSize < sizeof(*lpDSCCaps)) {
|
2004-10-21 20:57:26 +00:00
|
|
|
WARN("invalid parameter: lpDSCCaps->dwSize = %ld < %d\n",
|
2003-05-22 03:39:13 +00:00
|
|
|
lpDSCCaps->dwSize, sizeof(*lpDSCCaps));
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags;
|
|
|
|
lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats;
|
|
|
|
lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
TRACE("(flags=0x%08lx,format=0x%08lx,channels=%ld)\n",lpDSCCaps->dwFlags,
|
|
|
|
lpDSCCaps->dwFormats, lpDSCCaps->dwChannels);
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_Initialize(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCGUID lpcGUID )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-03-15 00:54:11 +00:00
|
|
|
HRESULT err = DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
unsigned wid, widn;
|
2005-06-04 09:38:14 +00:00
|
|
|
BOOLEAN found = FALSE;
|
|
|
|
GUID devGUID;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
2005-06-04 09:38:14 +00:00
|
|
|
DirectSoundCaptureDevice *device = This->device;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (!This) {
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("invalid parameter: This == NULL\n");
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (device != NULL) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("already initialized\n");
|
|
|
|
return DSERR_ALREADYINITIALIZED;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
/* Default device? */
|
|
|
|
if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) )
|
|
|
|
lpcGUID = &DSDEVID_DefaultCapture;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) {
|
|
|
|
WARN("invalid parameter: lpcGUID\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
widn = waveInGetNumDevs();
|
2004-10-21 20:57:26 +00:00
|
|
|
if (!widn) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("no audio devices found\n");
|
|
|
|
return DSERR_NODRIVER;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2003-03-15 00:54:11 +00:00
|
|
|
/* enumerate WINMM audio devices and find the one we want */
|
|
|
|
for (wid=0; wid<widn; wid++) {
|
2005-06-04 09:38:14 +00:00
|
|
|
if (IsEqualGUID( &devGUID, &DSOUND_capture_guids[wid]) ) {
|
|
|
|
found = TRUE;
|
2003-03-15 00:54:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (found == FALSE) {
|
|
|
|
WARN("No device found matching given ID!\n");
|
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DSOUND_capture[wid]) {
|
|
|
|
WARN("already in use\n");
|
|
|
|
return DSERR_ALLOCATED;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = DirectSoundCaptureDevice_Create(&(device));
|
2003-03-15 00:54:11 +00:00
|
|
|
if (err != DS_OK) {
|
2005-06-04 09:38:14 +00:00
|
|
|
WARN("DirectSoundCaptureDevice_Create failed\n");
|
|
|
|
return err;
|
2003-03-15 00:54:11 +00:00
|
|
|
}
|
2005-06-05 17:44:30 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device = device;
|
|
|
|
device->guid = devGUID;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-09-12 15:14:06 +00:00
|
|
|
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&(This->device->driver),0));
|
2003-02-15 00:01:17 +00:00
|
|
|
if ( (err != DS_OK) && (err != DSERR_UNSUPPORTED) ) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("waveInMessage failed; err=%lx\n",err);
|
|
|
|
return err;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
err = DS_OK;
|
|
|
|
|
2003-03-06 22:46:34 +00:00
|
|
|
/* Disable the direct sound driver to force emulation if requested. */
|
|
|
|
if (ds_hw_accel == DS_HW_ACCEL_EMULATION)
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device->driver = NULL;
|
2003-03-06 22:46:34 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
/* Get driver description */
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->device->driver) {
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE("using DirectSound driver\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
err = IDsCaptureDriver_GetDriverDesc(This->device->driver, &(This->device->drvdesc));
|
2003-03-04 02:12:34 +00:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetDriverDesc failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
|
|
|
TRACE("using WINMM\n");
|
|
|
|
/* if no DirectSound interface available, use WINMM API instead */
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN |
|
2003-02-15 00:01:17 +00:00
|
|
|
DSDDESC_DOMMSYSTEMSETFORMAT;
|
|
|
|
}
|
2003-04-05 05:11:02 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device->drvdesc.dnDevNode = wid;
|
2004-10-21 20:57:26 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
/* open the DirectSound driver if available */
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->device->driver && (err == DS_OK))
|
|
|
|
err = IDsCaptureDriver_Open(This->device->driver);
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
if (err == DS_OK) {
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device = device;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
/* the driver is now open, so it's now allowed to call GetCaps */
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->device->driver) {
|
|
|
|
This->device->drvcaps.dwSize = sizeof(This->device->drvcaps);
|
|
|
|
err = IDsCaptureDriver_GetCaps(This->device->driver,&(This->device->drvcaps));
|
2003-03-04 02:12:34 +00:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetCaps failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else /*if (This->hwi)*/ {
|
2003-02-15 00:01:17 +00:00
|
|
|
WAVEINCAPSA wic;
|
2005-06-04 09:38:14 +00:00
|
|
|
err = mmErr(waveInGetDevCapsA((UINT)This->device->drvdesc.dnDevNode, &wic, sizeof(wic)));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
if (err == DS_OK) {
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device->drvcaps.dwFlags = 0;
|
|
|
|
lstrcpynA(This->device->drvdesc.szDrvname, wic.szPname,
|
|
|
|
sizeof(This->device->drvdesc.szDrvname));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
This->device->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER;
|
|
|
|
This->device->drvcaps.dwFormats = wic.dwFormats;
|
|
|
|
This->device->drvcaps.dwChannels = wic.wChannels;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return err;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IDirectSoundCaptureVtbl dscvt =
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureImpl_AddRef,
|
|
|
|
IDirectSoundCaptureImpl_Release,
|
|
|
|
|
|
|
|
/* IDirectSoundCapture methods */
|
|
|
|
IDirectSoundCaptureImpl_CreateCaptureBuffer,
|
|
|
|
IDirectSoundCaptureImpl_GetCaps,
|
|
|
|
IDirectSoundCaptureImpl_Initialize
|
2002-06-13 19:15:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT
|
2003-02-15 00:01:17 +00:00
|
|
|
DSOUND_CreateDirectSoundCaptureBuffer(
|
2004-10-21 20:57:26 +00:00
|
|
|
IDirectSoundCaptureImpl *ipDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
2003-02-15 00:01:17 +00:00
|
|
|
LPVOID* ppobj )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
LPWAVEFORMATEX wfex;
|
|
|
|
TRACE( "(%p,%p)\n", lpcDSCBufferDesc, ppobj );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
if ( ((lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC)) &&
|
|
|
|
(lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC1))) ||
|
2003-02-15 00:01:17 +00:00
|
|
|
(lpcDSCBufferDesc->dwBufferBytes == 0) ||
|
|
|
|
(lpcDSCBufferDesc->lpwfxFormat == NULL) ) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("invalid lpcDSCBufferDesc\n");
|
2003-05-22 03:39:13 +00:00
|
|
|
*ppobj = NULL;
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if ( !ipDSC->device) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("not initialized\n");
|
2003-05-22 03:39:13 +00:00
|
|
|
*ppobj = NULL;
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_UNINITIALIZED;
|
2003-02-15 00:01:17 +00: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-10-08 22:35:26 +00:00
|
|
|
if (wfex->wFormatTag == WAVE_FORMAT_PCM) {
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX));
|
|
|
|
CopyMemory(ipDSC->device->pwfx, wfex, sizeof(WAVEFORMATEX));
|
|
|
|
ipDSC->device->pwfx->cbSize = 0;
|
2003-10-08 22:35:26 +00:00
|
|
|
} else {
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX)+wfex->cbSize);
|
|
|
|
CopyMemory(ipDSC->device->pwfx, wfex, sizeof(WAVEFORMATEX)+wfex->cbSize);
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("lpcDSCBufferDesc->lpwfxFormat == 0\n");
|
2003-05-22 03:39:13 +00:00
|
|
|
*ppobj = NULL;
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_INVALIDPARAM; /* FIXME: DSERR_BADFORMAT ? */
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(IDirectSoundCaptureBufferImpl));
|
|
|
|
|
|
|
|
if ( *ppobj == NULL ) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("out of memory\n");
|
2003-05-22 03:39:13 +00:00
|
|
|
*ppobj = NULL;
|
2003-03-04 02:12:34 +00:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
2003-03-04 02:12:34 +00:00
|
|
|
HRESULT err = DS_OK;
|
2004-10-21 20:57:26 +00:00
|
|
|
LPBYTE newbuf;
|
|
|
|
DWORD buflen;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)*ppobj;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
This->ref = 1;
|
|
|
|
This->dsound = ipDSC;
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->capture_buffer = This;
|
2003-09-01 23:58:43 +00:00
|
|
|
This->notify = NULL;
|
|
|
|
This->nrofnotifies = 0;
|
|
|
|
This->hwnotify = NULL;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
This->pdscbd = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
lpcDSCBufferDesc->dwSize);
|
2004-10-21 20:57:26 +00:00
|
|
|
if (This->pdscbd)
|
2005-01-24 12:40:45 +00:00
|
|
|
CopyMemory(This->pdscbd, lpcDSCBufferDesc, lpcDSCBufferDesc->dwSize);
|
2003-02-15 00:01:17 +00:00
|
|
|
else {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("no memory\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->capture_buffer = 0;
|
2003-02-15 00:01:17 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
2004-10-21 20:57:26 +00:00
|
|
|
return DSERR_OUTOFMEMORY;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-04-10 18:17:34 +00:00
|
|
|
This->lpVtbl = &dscbvt;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (ipDSC->device->driver) {
|
|
|
|
if (This->dsound->device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
|
2004-10-21 20:57:26 +00:00
|
|
|
FIXME("DSDDESC_DOMMSYSTEMOPEN not supported\n");
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
|
2004-10-21 20:57:26 +00:00
|
|
|
/* allocate buffer from system memory */
|
|
|
|
buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->device->buffer);
|
|
|
|
if (ipDSC->device->buffer)
|
|
|
|
newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->buffer,buflen);
|
2004-10-21 20:57:26 +00:00
|
|
|
else
|
|
|
|
newbuf = HeapAlloc(GetProcessHeap(),0,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 {
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->buffer = newbuf;
|
|
|
|
ipDSC->device->buflen = buflen;
|
2004-10-21 20:57:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* let driver allocate memory */
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2004-10-21 20:57:26 +00:00
|
|
|
/* FIXME: */
|
2005-06-04 09:38:14 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, ipDSC->device->buffer);
|
|
|
|
ipDSC->device->buffer = NULL;
|
2004-10-21 20:57:26 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
err = IDsCaptureDriver_CreateCaptureBuffer(ipDSC->device->driver,
|
|
|
|
ipDSC->device->pwfx,0,0,&(ipDSC->device->buflen),&(ipDSC->device->buffer),(LPVOID*)&(ipDSC->device->hwbuf));
|
2003-03-04 02:12:34 +00:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->capture_buffer = 0;
|
2003-04-11 23:59:19 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-03-06 22:46:34 +00:00
|
|
|
DWORD flags = CALLBACK_FUNCTION;
|
|
|
|
if (ds_hw_accel != DS_HW_ACCEL_EMULATION)
|
|
|
|
flags |= WAVE_DIRECTSOUND;
|
2005-06-04 09:38:14 +00:00
|
|
|
err = mmErr(waveInOpen(&(ipDSC->device->hwi),
|
|
|
|
ipDSC->device->drvdesc.dnDevNode, ipDSC->device->pwfx,
|
2005-09-12 15:14:06 +00:00
|
|
|
(DWORD_PTR)DSOUND_capture_callback, (DWORD)ipDSC->device, flags));
|
2003-03-04 02:12:34 +00:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("waveInOpen failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->capture_buffer = 0;
|
2003-04-11 23:59:19 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->device->buffer);
|
|
|
|
if (ipDSC->device->buffer)
|
|
|
|
newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->buffer,buflen);
|
2003-10-14 05:24:20 +00:00
|
|
|
else
|
2004-10-21 20:57:26 +00:00
|
|
|
newbuf = HeapAlloc(GetProcessHeap(),0,buflen);
|
2003-03-04 02:12:34 +00:00
|
|
|
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 {
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->buffer = newbuf;
|
|
|
|
ipDSC->device->buflen = buflen;
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
2003-09-01 23:58:43 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundCaptureNotify
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppobj)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
2003-09-01 23:58:43 +00:00
|
|
|
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)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref - 1);
|
|
|
|
return ref;
|
2003-09-01 23:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref + 1);
|
2003-09-01 23:58:43 +00:00
|
|
|
|
2005-02-11 11:49:05 +00:00
|
|
|
if (!ref) {
|
2004-04-19 02:58:45 +00:00
|
|
|
if (This->dscb->hwnotify)
|
|
|
|
IDsDriverNotify_Release(This->dscb->hwnotify);
|
2003-09-01 23:58:43 +00:00
|
|
|
This->dscb->notify=NULL;
|
|
|
|
IDirectSoundCaptureBuffer_Release((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
2005-02-11 11:49:05 +00:00
|
|
|
TRACE("(%p) released\n", This);
|
2003-09-01 23:58:43 +00:00
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
DWORD howmuch,
|
|
|
|
LPCDSBPOSITIONNOTIFY notify)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
2003-09-01 23:58:43 +00:00
|
|
|
TRACE("(%p,0x%08lx,%p)\n",This,howmuch,notify);
|
|
|
|
|
2004-04-19 02:58:45 +00:00
|
|
|
if (howmuch > 0 && notify == NULL) {
|
2003-09-01 23:58:43 +00:00
|
|
|
WARN("invalid parameter: notify == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TRACE_ON(dsound)) {
|
2004-09-08 01:23:57 +00:00
|
|
|
unsigned int i;
|
2003-09-01 23:58:43 +00:00
|
|
|
for (i=0;i<howmuch;i++)
|
2005-09-12 14:12:46 +00:00
|
|
|
TRACE("notify at %ld to %p\n",
|
|
|
|
notify[i].dwOffset,notify[i].hEventNotify);
|
2003-09-01 23:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2004-04-19 02:58:45 +00:00
|
|
|
} else if (howmuch > 0) {
|
2003-09-01 23:58:43 +00:00
|
|
|
/* Make an internal copy of the caller-supplied array.
|
|
|
|
* Replace the existing copy if one is already present. */
|
2003-10-14 05:24:20 +00:00
|
|
|
if (This->dscb->notifies)
|
2004-10-21 20:57:26 +00:00
|
|
|
This->dscb->notifies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-10-14 05:24:20 +00:00
|
|
|
This->dscb->notifies, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
else
|
2004-10-21 20:57:26 +00:00
|
|
|
This->dscb->notifies = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-10-14 05:24:20 +00:00
|
|
|
howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
|
2003-09-01 23:58:43 +00:00
|
|
|
if (This->dscb->notifies == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2005-01-24 12:40:45 +00:00
|
|
|
CopyMemory(This->dscb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
2003-09-01 23:58:43 +00:00
|
|
|
This->dscb->nrofnotifies = howmuch;
|
2004-04-19 02:58:45 +00:00
|
|
|
} else {
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->dscb->notifies);
|
|
|
|
This->dscb->notifies = NULL;
|
2004-04-19 02:58:45 +00:00
|
|
|
This->dscb->nrofnotifies = 0;
|
2003-09-01 23:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IDirectSoundNotifyVtbl dscnvt =
|
2003-09-01 23:58:43 +00:00
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureNotifyImpl_AddRef,
|
|
|
|
IDirectSoundCaptureNotifyImpl_Release,
|
|
|
|
IDirectSoundCaptureNotifyImpl_SetNotificationPositions,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirectSoundCaptureNotifyImpl_Create(
|
|
|
|
IDirectSoundCaptureBufferImpl *dscb,
|
|
|
|
IDirectSoundCaptureNotifyImpl **pdscn)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl * dscn;
|
|
|
|
TRACE("(%p,%p)\n",dscb,pdscn);
|
|
|
|
|
2004-08-18 00:30:37 +00:00
|
|
|
dscn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(dscn));
|
2003-09-01 23:58:43 +00:00
|
|
|
|
|
|
|
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 19:15:06 +00:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_QueryInterface(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-09-01 23:58:43 +00:00
|
|
|
HRESULT hres;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
|
|
|
|
2003-08-06 22:57:24 +00:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
|
2003-09-01 23:58:43 +00:00
|
|
|
if (!This->notify)
|
|
|
|
hres = IDirectSoundCaptureNotifyImpl_Create(This, &This->notify);
|
2003-05-02 20:16:48 +00:00
|
|
|
if (This->notify) {
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->hwbuf) {
|
|
|
|
hres = IDsCaptureDriverBuffer_QueryInterface(This->dsound->device->hwbuf,
|
2003-09-01 23:58:43 +00:00
|
|
|
&IID_IDsDriverNotify, (LPVOID*)&(This->hwnotify));
|
|
|
|
if (hres != DS_OK) {
|
2003-05-02 20:16:48 +00:00
|
|
|
WARN("IDsCaptureDriverBuffer_QueryInterface failed\n");
|
|
|
|
*ppobj = 0;
|
2003-09-01 23:58:43 +00:00
|
|
|
return hres;
|
2003-05-02 20:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSoundNotify_AddRef((LPDIRECTSOUNDNOTIFY)This->notify);
|
|
|
|
*ppobj = (LPVOID)This->notify;
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("IID_IDirectSoundNotify\n");
|
2003-05-02 20:16:48 +00:00
|
|
|
return E_FAIL;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-02 20:16:48 +00:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundCaptureBuffer, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirectSoundCaptureBuffer8, riid ) ) {
|
2003-03-04 02:12:34 +00:00
|
|
|
IDirectSoundCaptureBuffer8_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2003-03-15 00:54:11 +00:00
|
|
|
FIXME("(%p,%s,%p) unsupported GUID\n", This, debugstr_guid(riid), ppobj);
|
2003-05-02 20:16:48 +00:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref - 1);
|
|
|
|
return ref;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref + 1);
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-02-11 11:49:05 +00:00
|
|
|
if (!ref) {
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE("deleting object\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->state == STATE_CAPTURING)
|
|
|
|
This->dsound->device->state = STATE_STOPPING;
|
2004-08-16 19:59:37 +00:00
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(),0, This->pdscbd);
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->hwi) {
|
|
|
|
waveInReset(This->dsound->device->hwi);
|
|
|
|
waveInClose(This->dsound->device->hwi);
|
|
|
|
HeapFree(GetProcessHeap(),0, This->dsound->device->pwave);
|
|
|
|
This->dsound->device->pwave = 0;
|
|
|
|
This->dsound->device->hwi = 0;
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->hwbuf)
|
|
|
|
IDsCaptureDriverBuffer_Release(This->dsound->device->hwbuf);
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
/* remove from IDirectSoundCaptureImpl */
|
|
|
|
if (This->dsound)
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->capture_buffer = NULL;
|
2003-02-15 00:01:17 +00:00
|
|
|
else
|
|
|
|
ERR("does not reference dsound\n");
|
|
|
|
|
2003-05-02 20:16:48 +00:00
|
|
|
if (This->notify)
|
|
|
|
IDirectSoundNotify_Release((LPDIRECTSOUNDNOTIFY)This->notify);
|
2004-10-21 20:57:26 +00:00
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->notifies);
|
2003-02-15 00:01:17 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2005-02-11 11:49:05 +00:00
|
|
|
TRACE("(%p) released\n", This);
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2005-02-11 11:49:05 +00:00
|
|
|
return ref;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCaps(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDSCBCAPS lpDSCBCaps )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p,%p)\n", This, lpDSCBCaps );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
if (This == NULL) {
|
|
|
|
WARN("invalid parameter: This == NULL\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-05-22 03:39:13 +00:00
|
|
|
if (lpDSCBCaps == NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCBCaps == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCBCaps->dwSize < sizeof(DSCBCAPS)) {
|
2004-10-21 20:57:26 +00:00
|
|
|
WARN("invalid parameter: lpDSCBCaps->dwSize = %ld < %d\n",
|
2003-05-22 03:39:13 +00:00
|
|
|
lpDSCBCaps->dwSize, sizeof(DSCBCAPS));
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->dsound == NULL) {
|
|
|
|
WARN("invalid parameter: This->dsound == NULL\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpDSCBCaps->dwSize = sizeof(DSCBCAPS);
|
|
|
|
lpDSCBCaps->dwFlags = This->flags;
|
|
|
|
lpDSCBCaps->dwBufferBytes = This->pdscbd->dwBufferBytes;
|
|
|
|
lpDSCBCaps->dwReserved = 0;
|
|
|
|
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCurrentPosition(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwCapturePosition,
|
|
|
|
LPDWORD lpdwReadPosition )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p,%p,%p)\n", This, lpdwCapturePosition, lpdwReadPosition );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_GetPosition(This->dsound->device->hwbuf, lpdwCapturePosition, lpdwReadPosition );
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK)
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("IDsCaptureDriverBuffer_GetPosition failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
} else if (This->dsound->device->hwi) {
|
|
|
|
EnterCriticalSection(&(This->dsound->device->lock));
|
|
|
|
TRACE("old This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]);
|
2003-02-15 00:01:17 +00:00
|
|
|
if (lpdwCapturePosition) {
|
|
|
|
MMTIME mtime;
|
|
|
|
mtime.wType = TIME_BYTES;
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInGetPosition(This->dsound->device->hwi, &mtime, sizeof(mtime));
|
|
|
|
TRACE("mtime.u.cb=%ld,This->dsound->device->buflen=%ld\n", mtime.u.cb,
|
|
|
|
This->dsound->device->buflen);
|
|
|
|
mtime.u.cb = mtime.u.cb % This->dsound->device->buflen;
|
2003-02-15 00:01:17 +00:00
|
|
|
*lpdwCapturePosition = mtime.u.cb;
|
|
|
|
}
|
2004-10-21 20:57:26 +00:00
|
|
|
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lpdwReadPosition) {
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->state == STATE_STARTING) {
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lpdwCapturePosition)
|
2005-06-04 09:38:14 +00:00
|
|
|
This->dsound->device->read_position = *lpdwCapturePosition;
|
|
|
|
This->dsound->device->state = STATE_CAPTURING;
|
2004-10-21 20:57:26 +00:00
|
|
|
}
|
2005-06-04 09:38:14 +00:00
|
|
|
*lpdwReadPosition = This->dsound->device->read_position;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]);
|
|
|
|
LeaveCriticalSection(&(This->dsound->device->lock));
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lpdwCapturePosition) TRACE("*lpdwCapturePosition=%ld\n",*lpdwCapturePosition);
|
|
|
|
if (lpdwReadPosition) TRACE("*lpdwReadPosition=%ld\n",*lpdwReadPosition);
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("no driver\n");
|
2004-11-19 17:56:56 +00:00
|
|
|
hres = DSERR_NODRIVER;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2004-10-21 20:57:26 +00:00
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFormat(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPWAVEFORMATEX lpwfxFormat,
|
|
|
|
DWORD dwSizeAllocated,
|
|
|
|
LPDWORD lpdwSizeWritten )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2004-10-21 20:57:26 +00:00
|
|
|
TRACE( "(%p,%p,0x%08lx,%p)\n", This, lpwfxFormat, dwSizeAllocated,
|
2003-02-15 00:01:17 +00:00
|
|
|
lpdwSizeWritten );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (dwSizeAllocated > (sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize))
|
|
|
|
dwSizeAllocated = sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize;
|
2003-10-08 22:35:26 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
if (lpwfxFormat) { /* NULL is valid (just want size) */
|
2005-06-04 09:38:14 +00:00
|
|
|
CopyMemory(lpwfxFormat, This->dsound->device->pwfx, dwSizeAllocated);
|
2003-02-15 00:01:17 +00:00
|
|
|
if (lpdwSizeWritten)
|
|
|
|
*lpdwSizeWritten = dwSizeAllocated;
|
|
|
|
} else {
|
|
|
|
if (lpdwSizeWritten)
|
2005-06-04 09:38:14 +00:00
|
|
|
*lpdwSizeWritten = sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize;
|
2003-02-15 00:01:17 +00:00
|
|
|
else {
|
2003-05-22 03:39:13 +00:00
|
|
|
TRACE("invalid parameter: lpdwSizeWritten = NULL\n");
|
2004-11-19 17:56:56 +00:00
|
|
|
hres = DSERR_INVALIDPARAM;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetStatus(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwStatus )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE( "(%p, %p), thread is %04lx\n", This, lpdwStatus, GetCurrentThreadId() );
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
*lpdwStatus = 0;
|
2005-06-04 09:38:14 +00:00
|
|
|
EnterCriticalSection(&(This->dsound->device->lock));
|
2003-03-06 22:46:34 +00:00
|
|
|
|
2003-11-14 21:03:24 +00:00
|
|
|
TRACE("old This->dsound->state=%s, old lpdwStatus=%08lx\n",
|
2005-06-04 09:38:14 +00:00
|
|
|
captureStateString[This->dsound->device->state],*lpdwStatus);
|
|
|
|
if ((This->dsound->device->state == STATE_STARTING) ||
|
|
|
|
(This->dsound->device->state == STATE_CAPTURING)) {
|
2003-02-15 00:01:17 +00:00
|
|
|
*lpdwStatus |= DSCBSTATUS_CAPTURING;
|
|
|
|
if (This->flags & DSCBSTART_LOOPING)
|
|
|
|
*lpdwStatus |= DSCBSTATUS_LOOPING;
|
|
|
|
}
|
2003-11-14 21:03:24 +00:00
|
|
|
TRACE("new This->dsound->state=%s, new lpdwStatus=%08lx\n",
|
2005-06-04 09:38:14 +00:00
|
|
|
captureStateString[This->dsound->device->state],*lpdwStatus);
|
|
|
|
LeaveCriticalSection(&(This->dsound->device->lock));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE("status=%lx\n", *lpdwStatus);
|
|
|
|
TRACE("returning DS_OK\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Initialize(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDIRECTSOUNDCAPTURE lpDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBDesc )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
FIXME( "(%p,%p,%p): stub\n", This, lpDSC, lpcDSCBDesc );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Lock(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwReadCusor,
|
|
|
|
DWORD dwReadBytes,
|
|
|
|
LPVOID* lplpvAudioPtr1,
|
|
|
|
LPDWORD lpdwAudioBytes1,
|
|
|
|
LPVOID* lplpvAudioPtr2,
|
|
|
|
LPDWORD lpdwAudioBytes2,
|
|
|
|
DWORD dwFlags )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-03-04 02:12:34 +00:00
|
|
|
TRACE( "(%p,%08lu,%08lu,%p,%p,%p,%p,0x%08lx) at %ld\n", This, dwReadCusor,
|
2003-02-15 00:01:17 +00:00
|
|
|
dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2,
|
2003-03-04 02:12:34 +00:00
|
|
|
lpdwAudioBytes2, dwFlags, GetTickCount() );
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
EnterCriticalSection(&(This->dsound->device->lock));
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Lock(This->dsound->device->hwbuf, lplpvAudioPtr1,
|
2004-11-19 17:56:56 +00:00
|
|
|
lpdwAudioBytes1, lplpvAudioPtr2,
|
|
|
|
lpdwAudioBytes2, dwReadCusor,
|
|
|
|
dwReadBytes, dwFlags);
|
|
|
|
if (hres != DS_OK)
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("IDsCaptureDriverBuffer_Lock failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
} else if (This->dsound->device->hwi) {
|
|
|
|
*lplpvAudioPtr1 = This->dsound->device->buffer + dwReadCusor;
|
|
|
|
if ( (dwReadCusor + dwReadBytes) > This->dsound->device->buflen) {
|
|
|
|
*lpdwAudioBytes1 = This->dsound->device->buflen - dwReadCusor;
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lplpvAudioPtr2)
|
2005-06-04 09:38:14 +00:00
|
|
|
*lplpvAudioPtr2 = This->dsound->device->buffer;
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = dwReadBytes - *lpdwAudioBytes1;
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
|
|
|
*lpdwAudioBytes1 = dwReadBytes;
|
2003-03-04 02:12:34 +00:00
|
|
|
if (lplpvAudioPtr2)
|
|
|
|
*lplpvAudioPtr2 = 0;
|
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = 0;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TRACE("invalid call\n");
|
2004-11-19 17:56:56 +00:00
|
|
|
hres = DSERR_INVALIDCALL; /* DSERR_NODRIVER ? */
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
LeaveCriticalSection(&(This->dsound->device->lock));
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Start(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwFlags )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p,0x%08lx)\n", This, dwFlags );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if ( (This->dsound->device->driver == 0) && (This->dsound->device->hwi == 0) ) {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("no driver\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
EnterCriticalSection(&(This->dsound->device->lock));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
This->flags = dwFlags;
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->device->state]);
|
|
|
|
if (This->dsound->device->state == STATE_STOPPED)
|
|
|
|
This->dsound->device->state = STATE_STARTING;
|
|
|
|
else if (This->dsound->device->state == STATE_STOPPING)
|
|
|
|
This->dsound->device->state = STATE_CAPTURING;
|
|
|
|
TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]);
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
LeaveCriticalSection(&(This->dsound->device->lock));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Start(This->dsound->device->hwbuf, dwFlags);
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK)
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("IDsCaptureDriverBuffer_Start failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
} else if (This->dsound->device->hwi) {
|
2003-02-15 00:01:17 +00:00
|
|
|
IDirectSoundCaptureImpl* ipDSC = This->dsound;
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (ipDSC->device->buffer) {
|
2003-09-01 23:58:43 +00:00
|
|
|
if (This->nrofnotifies) {
|
2004-09-08 01:23:57 +00:00
|
|
|
int c;
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->nrofpwaves = This->nrofnotifies;
|
2003-10-08 22:35:26 +00:00
|
|
|
TRACE("nrofnotifies=%d\n", This->nrofnotifies);
|
2003-02-15 00:01:17 +00:00
|
|
|
|
|
|
|
/* prepare headers */
|
2005-06-04 09:38:14 +00:00
|
|
|
if (ipDSC->device->pwave)
|
|
|
|
ipDSC->device->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->pwave,
|
|
|
|
ipDSC->device->nrofpwaves*sizeof(WAVEHDR));
|
2004-10-21 20:57:26 +00:00
|
|
|
else
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave = HeapAlloc(GetProcessHeap(),0,
|
|
|
|
ipDSC->device->nrofpwaves*sizeof(WAVEHDR));
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
for (c = 0; c < ipDSC->device->nrofpwaves; c++) {
|
2004-04-19 02:58:45 +00:00
|
|
|
if (This->notifies[c].dwOffset == DSBPN_OFFSETSTOP) {
|
|
|
|
TRACE("got DSBPN_OFFSETSTOP\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->nrofpwaves = c;
|
2004-04-19 02:58:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
if (c == 0) {
|
2005-08-30 08:56:35 +00:00
|
|
|
ipDSC->device->pwave[0].lpData = (LPSTR)ipDSC->device->buffer;
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave[0].dwBufferLength =
|
2003-09-01 23:58:43 +00:00
|
|
|
This->notifies[0].dwOffset + 1;
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
2005-08-30 08:56:35 +00:00
|
|
|
ipDSC->device->pwave[c].lpData = (LPSTR)ipDSC->device->buffer +
|
2003-09-01 23:58:43 +00:00
|
|
|
This->notifies[c-1].dwOffset + 1;
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave[c].dwBufferLength =
|
2004-10-21 20:57:26 +00:00
|
|
|
This->notifies[c].dwOffset -
|
2003-09-01 23:58:43 +00:00
|
|
|
This->notifies[c-1].dwOffset;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave[c].dwBytesRecorded = 0;
|
|
|
|
ipDSC->device->pwave[c].dwUser = (DWORD)ipDSC;
|
|
|
|
ipDSC->device->pwave[c].dwFlags = 0;
|
|
|
|
ipDSC->device->pwave[c].dwLoops = 0;
|
|
|
|
hres = mmErr(waveInPrepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[c]),sizeof(WAVEHDR)));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK) {
|
2004-04-19 02:58:45 +00:00
|
|
|
WARN("waveInPrepareHeader failed\n");
|
2003-10-08 22:35:26 +00:00
|
|
|
while (c--)
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInUnprepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[c]),sizeof(WAVEHDR));
|
2003-10-08 22:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
hres = mmErr(waveInAddBuffer(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[c]), sizeof(WAVEHDR)));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK) {
|
2004-04-19 02:58:45 +00:00
|
|
|
WARN("waveInAddBuffer failed\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
while (c--)
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInUnprepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[c]),sizeof(WAVEHDR));
|
2003-10-08 22:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
FillMemory(ipDSC->device->buffer, ipDSC->device->buflen,
|
|
|
|
(ipDSC->device->pwfx->wBitsPerSample == 8) ? 128 : 0);
|
2003-03-04 02:12:34 +00:00
|
|
|
} else {
|
|
|
|
TRACE("no notifiers specified\n");
|
|
|
|
/* no notifiers specified so just create a single default header */
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->nrofpwaves = 1;
|
|
|
|
if (ipDSC->device->pwave)
|
|
|
|
ipDSC->device->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->pwave,sizeof(WAVEHDR));
|
2003-10-14 05:24:20 +00:00
|
|
|
else
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEHDR));
|
2003-10-14 05:24:20 +00:00
|
|
|
|
2005-08-30 08:56:35 +00:00
|
|
|
ipDSC->device->pwave[0].lpData = (LPSTR)ipDSC->device->buffer;
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->pwave[0].dwBufferLength = ipDSC->device->buflen;
|
|
|
|
ipDSC->device->pwave[0].dwBytesRecorded = 0;
|
|
|
|
ipDSC->device->pwave[0].dwUser = (DWORD)ipDSC;
|
|
|
|
ipDSC->device->pwave[0].dwFlags = 0;
|
|
|
|
ipDSC->device->pwave[0].dwLoops = 0;
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
hres = mmErr(waveInPrepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[0]),sizeof(WAVEHDR)));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK) {
|
2003-05-22 03:39:13 +00:00
|
|
|
WARN("waveInPrepareHeader failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInUnprepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[0]),sizeof(WAVEHDR));
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
2005-06-04 09:38:14 +00:00
|
|
|
hres = mmErr(waveInAddBuffer(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[0]), sizeof(WAVEHDR)));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK) {
|
2004-04-19 02:58:45 +00:00
|
|
|
WARN("waveInAddBuffer failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInUnprepareHeader(ipDSC->device->hwi,
|
|
|
|
&(ipDSC->device->pwave[0]),sizeof(WAVEHDR));
|
2003-10-08 22:35:26 +00:00
|
|
|
}
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
ipDSC->device->index = 0;
|
|
|
|
ipDSC->device->read_position = 0;
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres == DS_OK) {
|
2003-10-08 22:35:26 +00:00
|
|
|
/* start filling the first buffer */
|
2005-06-04 09:38:14 +00:00
|
|
|
hres = mmErr(waveInStart(ipDSC->device->hwi));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK)
|
2004-04-19 02:58:45 +00:00
|
|
|
WARN("waveInStart failed\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("calling waveInClose because of error\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
waveInClose(This->dsound->device->hwi);
|
|
|
|
This->dsound->device->hwi = 0;
|
2004-11-19 17:56:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WARN("no driver\n");
|
|
|
|
hres = DSERR_NODRIVER;
|
2003-03-04 02:12:34 +00:00
|
|
|
}
|
2003-02-15 00:01:17 +00:00
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
|
|
|
{
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-02-15 00:01:17 +00:00
|
|
|
TRACE( "(%p)\n", This );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
EnterCriticalSection(&(This->dsound->device->lock));
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->device->state]);
|
|
|
|
if (This->dsound->device->state == STATE_CAPTURING)
|
|
|
|
This->dsound->device->state = STATE_STOPPING;
|
|
|
|
else if (This->dsound->device->state == STATE_STARTING)
|
|
|
|
This->dsound->device->state = STATE_STOPPED;
|
|
|
|
TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]);
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
LeaveCriticalSection(&(This->dsound->device->lock));
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Stop(This->dsound->device->hwbuf);
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Stop() failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
} else if (This->dsound->device->hwi) {
|
|
|
|
hres = mmErr(waveInReset(This->dsound->device->hwi));
|
2004-11-19 17:56:56 +00:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("waveInReset() failed\n");
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("no driver\n");
|
2004-11-19 17:56:56 +00:00
|
|
|
hres = DSERR_NODRIVER;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Unlock(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPVOID lpvAudioPtr1,
|
|
|
|
DWORD dwAudioBytes1,
|
|
|
|
LPVOID lpvAudioPtr2,
|
|
|
|
DWORD dwAudioBytes2 )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-11-19 17:56:56 +00:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2004-10-21 20:57:26 +00:00
|
|
|
TRACE( "(%p,%p,%08lu,%p,%08lu)\n", This, lpvAudioPtr1, dwAudioBytes1,
|
2003-02-15 00:01:17 +00:00
|
|
|
lpvAudioPtr2, dwAudioBytes2 );
|
|
|
|
|
2003-05-22 03:39:13 +00: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 00:01:17 +00:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if (This->dsound->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Unlock(This->dsound->device->hwbuf, lpvAudioPtr1,
|
2004-11-19 17:56:56 +00:00
|
|
|
dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2);
|
2003-05-22 03:39:13 +00:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Unlock failed\n");
|
2005-06-04 09:38:14 +00:00
|
|
|
} else if (This->dsound->device->hwi) {
|
|
|
|
This->dsound->device->read_position = (This->dsound->device->read_position +
|
|
|
|
(dwAudioBytes1 + dwAudioBytes2)) % This->dsound->device->buflen;
|
2003-02-15 00:01:17 +00:00
|
|
|
} else {
|
2003-03-04 02:12:34 +00:00
|
|
|
WARN("invalid call\n");
|
2004-11-19 17:56:56 +00:00
|
|
|
hres = DSERR_INVALIDCALL;
|
2003-02-15 00:01:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 17:56:56 +00:00
|
|
|
TRACE("returning %08lx\n", hres);
|
|
|
|
return hres;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetObjectInPath(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
REFGUID rguidObject,
|
|
|
|
DWORD dwIndex,
|
|
|
|
REFGUID rguidInterface,
|
|
|
|
LPVOID* ppObject )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
FIXME( "(%p,%s,%lu,%s,%p): stub\n", This, debugstr_guid(rguidObject),
|
2003-02-15 00:01:17 +00:00
|
|
|
dwIndex, debugstr_guid(rguidInterface), ppObject );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFXStatus(
|
2003-02-15 00:01:17 +00:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwFXCount,
|
|
|
|
LPDWORD pdwFXStatus )
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
FIXME( "(%p,%lu,%p): stub\n", This, dwFXCount, pdwFXStatus );
|
2002-06-13 19:15:06 +00:00
|
|
|
|
2003-02-15 00:01:17 +00:00
|
|
|
return DS_OK;
|
2002-06-13 19:15:06 +00:00
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IDirectSoundCaptureBuffer8Vtbl dscbvt =
|
2002-06-13 19:15:06 +00:00
|
|
|
{
|
2003-02-15 00:01:17 +00:00
|
|
|
/* 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 19:15:06 +00:00
|
|
|
};
|
2003-03-04 02:12:34 +00:00
|
|
|
|
2003-08-06 22:57:24 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundCapture ClassFactory
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2004-10-21 20:57:26 +00:00
|
|
|
DSCCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
2003-08-06 22:57:24 +00:00
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2003-08-06 22:57:24 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
DSCCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref - 1);
|
|
|
|
return ref;
|
2003-08-06 22:57:24 +00:00
|
|
|
}
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
static ULONG WINAPI
|
2003-08-06 22:57:24 +00:00
|
|
|
DSCCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2005-02-11 11:49:05 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %ld\n", This, ref + 1);
|
2003-08-06 22:57:24 +00:00
|
|
|
/* static class, won't be freed */
|
2005-02-11 11:49:05 +00:00
|
|
|
return ref;
|
2003-08-06 22:57:24 +00:00
|
|
|
}
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
static HRESULT WINAPI
|
2003-08-06 22:57:24 +00:00
|
|
|
DSCCF_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2003-08-06 22:57:24 +00:00
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
if (pOuter) {
|
|
|
|
WARN("aggregation not supported\n");
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
2003-08-06 22:57:24 +00:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
2005-06-04 09:38:14 +00:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) )
|
2005-06-05 17:44:30 +00:00
|
|
|
return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter);
|
2003-08-06 22:57:24 +00:00
|
|
|
|
|
|
|
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2004-10-21 20:57:26 +00:00
|
|
|
static HRESULT WINAPI
|
2003-08-06 22:57:24 +00:00
|
|
|
DSCCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2003-08-06 22:57:24 +00:00
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IClassFactoryVtbl DSCCF_Vtbl =
|
2003-08-06 22:57:24 +00:00
|
|
|
{
|
|
|
|
DSCCF_QueryInterface,
|
|
|
|
DSCCF_AddRef,
|
|
|
|
DSCCF_Release,
|
|
|
|
DSCCF_CreateInstance,
|
|
|
|
DSCCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
IClassFactoryImpl DSOUND_CAPTURE_CF = { &DSCCF_Vtbl, 1 };
|