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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* TODO:
|
2003-03-04 03:12:34 +01:00
|
|
|
* Implement FX support.
|
2005-06-04 11:38:14 +02:00
|
|
|
* Implement both IDirectSoundCaptureBuffer and IDirectSoundCaptureBuffer8
|
|
|
|
* Make DirectSoundCaptureCreate and DirectSoundCaptureCreate8 behave differently
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-01-24 14:31:27 +01:00
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-17 11:24:50 +02:00
|
|
|
#include "winuser.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmsystem.h"
|
2003-02-15 01:01:17 +01:00
|
|
|
#include "mmddk.h"
|
|
|
|
#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);
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectSoundCaptureNotify implementation structure
|
|
|
|
*/
|
|
|
|
struct IDirectSoundCaptureNotifyImpl
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
|
|
|
const IDirectSoundNotifyVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
IDirectSoundCaptureBufferImpl* dscb;
|
|
|
|
};
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundCaptureNotify
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (This->dscb == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2006-08-02 13:26:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
return IDirectSoundCaptureBuffer_QueryInterface((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb, riid, ppobj);
|
|
|
|
}
|
2006-08-02 13:26:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
|
|
|
return ref;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-06-10 11:57:48 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (!ref) {
|
|
|
|
if (This->dscb->hwnotify)
|
|
|
|
IDsDriverNotify_Release(This->dscb->hwnotify);
|
|
|
|
This->dscb->notify=NULL;
|
|
|
|
IDirectSoundCaptureBuffer_Release((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
2003-11-14 22:03:24 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,
|
|
|
|
DWORD howmuch,
|
|
|
|
LPCDSBPOSITIONNOTIFY notify)
|
2005-06-04 11:38:14 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
|
|
|
|
TRACE("(%p,0x%08x,%p)\n",This,howmuch,notify);
|
2006-08-18 07:13:31 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (howmuch > 0 && notify == NULL) {
|
|
|
|
WARN("invalid parameter: notify == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2006-08-18 07:13:31 +02:00
|
|
|
}
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (TRACE_ON(dsound)) {
|
|
|
|
unsigned int i;
|
|
|
|
for (i=0;i<howmuch;i++)
|
|
|
|
TRACE("notify at %d to %p\n",
|
|
|
|
notify[i].dwOffset,notify[i].hEventNotify);
|
|
|
|
}
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01: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;
|
|
|
|
} else if (howmuch > 0) {
|
|
|
|
/* Make an internal copy of the caller-supplied array.
|
|
|
|
* Replace the existing copy if one is already present. */
|
|
|
|
if (This->dscb->notifies)
|
|
|
|
This->dscb->notifies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
This->dscb->notifies, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
else
|
|
|
|
This->dscb->notifies = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
|
|
|
|
if (This->dscb->notifies == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
CopyMemory(This->dscb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
This->dscb->nrofnotifies = howmuch;
|
2005-06-04 11:38:14 +02:00
|
|
|
} else {
|
2009-12-02 12:12:37 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->dscb->notifies);
|
|
|
|
This->dscb->notifies = NULL;
|
|
|
|
This->dscb->nrofnotifies = 0;
|
2005-06-04 11:38:14 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
return S_OK;
|
2005-06-04 11:38:14 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static const IDirectSoundNotifyVtbl dscnvt =
|
2005-06-04 11:38:14 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureNotifyImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureNotifyImpl_AddRef,
|
|
|
|
IDirectSoundCaptureNotifyImpl_Release,
|
|
|
|
IDirectSoundCaptureNotifyImpl_SetNotificationPositions,
|
|
|
|
};
|
2006-08-18 07:13:31 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT IDirectSoundCaptureNotifyImpl_Create(
|
|
|
|
IDirectSoundCaptureBufferImpl *dscb,
|
|
|
|
IDirectSoundCaptureNotifyImpl **pdscn)
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureNotifyImpl * dscn;
|
|
|
|
TRACE("(%p,%p)\n",dscb,pdscn);
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
dscn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dscn));
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (dscn == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2005-06-04 11:38:14 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
dscn->ref = 0;
|
|
|
|
dscn->lpVtbl = &dscnvt;
|
|
|
|
dscn->dscb = dscb;
|
|
|
|
dscb->notify = dscn;
|
|
|
|
IDirectSoundCaptureBuffer_AddRef((LPDIRECTSOUNDCAPTUREBUFFER)dscb);
|
|
|
|
|
|
|
|
*pdscn = dscn;
|
|
|
|
return DS_OK;
|
2005-06-04 11:38:14 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
|
|
|
|
static const char * const captureStateString[] = {
|
|
|
|
"STATE_STOPPED",
|
|
|
|
"STATE_STARTING",
|
|
|
|
"STATE_CAPTURING",
|
|
|
|
"STATE_STOPPING"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundCaptureBuffer
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
HRESULT hres;
|
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
2005-06-04 11:38:14 +02:00
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*ppobj = NULL;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
|
|
|
|
if (!This->notify)
|
|
|
|
hres = IDirectSoundCaptureNotifyImpl_Create(This, &This->notify);
|
|
|
|
if (This->notify) {
|
|
|
|
IDirectSoundNotify_AddRef((LPDIRECTSOUNDNOTIFY)This->notify);
|
|
|
|
if (This->device->hwbuf && !This->hwnotify) {
|
|
|
|
hres = IDsCaptureDriverBuffer_QueryInterface(This->device->hwbuf,
|
|
|
|
&IID_IDsDriverNotify, (LPVOID*)&(This->hwnotify));
|
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriverBuffer_QueryInterface failed\n");
|
|
|
|
IDirectSoundNotify_Release((LPDIRECTSOUNDNOTIFY)This->notify);
|
|
|
|
*ppobj = 0;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*ppobj = This->notify;
|
|
|
|
return DS_OK;
|
|
|
|
}
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
WARN("IID_IDirectSoundNotify\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-06-04 11:38:14 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundCaptureBuffer, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirectSoundCaptureBuffer8, riid ) ) {
|
|
|
|
IDirectSoundCaptureBuffer8_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return NO_ERROR;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
FIXME("(%p,%s,%p) unsupported GUID\n", This, debugstr_guid(riid), ppobj);
|
2005-06-05 19:44:30 +02:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2005-02-11 12:49:05 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2005-02-11 12:49:05 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
if (!ref) {
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("deleting object\n");
|
|
|
|
if (This->device->state == STATE_CAPTURING)
|
|
|
|
This->device->state = STATE_STOPPING;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0, This->pdscbd);
|
|
|
|
|
|
|
|
if (This->device->hwi) {
|
|
|
|
waveInReset(This->device->hwi);
|
|
|
|
waveInClose(This->device->hwi);
|
|
|
|
HeapFree(GetProcessHeap(),0, This->device->pwave);
|
|
|
|
This->device->pwave = 0;
|
|
|
|
This->device->hwi = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->device->hwbuf)
|
|
|
|
IDsCaptureDriverBuffer_Release(This->device->hwbuf);
|
|
|
|
|
|
|
|
/* remove from DirectSoundCaptureDevice */
|
|
|
|
This->device->capture_buffer = NULL;
|
|
|
|
|
|
|
|
if (This->notify)
|
|
|
|
IDirectSoundNotify_Release((LPDIRECTSOUNDNOTIFY)This->notify);
|
|
|
|
|
|
|
|
/* If driver manages its own buffer, IDsCaptureDriverBuffer_Release
|
|
|
|
should have freed the buffer. Prevent freeing it again in
|
|
|
|
IDirectSoundCaptureBufferImpl_Create */
|
|
|
|
if (!(This->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY))
|
|
|
|
This->device->buffer = NULL;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->notifies);
|
2003-02-15 01:01:17 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("(%p) released\n", This);
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCaps(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDSCBCAPS lpDSCBCaps )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
TRACE( "(%p,%p)\n", This, lpDSCBCaps );
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpDSCBCaps == NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCBCaps == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpDSCBCaps->dwSize < sizeof(DSCBCAPS)) {
|
|
|
|
WARN("invalid parameter: lpDSCBCaps->dwSize = %d\n", lpDSCBCaps->dwSize);
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
lpDSCBCaps->dwSize = sizeof(DSCBCAPS);
|
|
|
|
lpDSCBCaps->dwFlags = This->flags;
|
|
|
|
lpDSCBCaps->dwBufferBytes = This->pdscbd->dwBufferBytes;
|
|
|
|
lpDSCBCaps->dwReserved = 0;
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("returning DS_OK\n");
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCurrentPosition(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwCapturePosition,
|
|
|
|
LPDWORD lpdwReadPosition )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
HRESULT hres = DS_OK;
|
|
|
|
TRACE( "(%p,%p,%p)\n", This, lpdwCapturePosition, lpdwReadPosition );
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-06-05 19:44:30 +02:00
|
|
|
if (This->device == NULL) {
|
2009-12-02 12:12:37 +01:00
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_GetPosition(This->device->hwbuf, lpdwCapturePosition, lpdwReadPosition );
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_GetPosition failed\n");
|
|
|
|
} else if (This->device->hwi) {
|
|
|
|
DWORD pos;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
EnterCriticalSection(&This->device->lock);
|
|
|
|
pos = (DWORD_PTR)This->device->pwave[This->device->index].lpData - (DWORD_PTR)This->device->buffer;
|
|
|
|
if (lpdwCapturePosition)
|
|
|
|
*lpdwCapturePosition = (This->device->pwave[This->device->index].dwBufferLength + pos) % This->device->buflen;
|
|
|
|
if (lpdwReadPosition)
|
|
|
|
*lpdwReadPosition = pos;
|
|
|
|
LeaveCriticalSection(&This->device->lock);
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
} else {
|
|
|
|
WARN("no driver\n");
|
|
|
|
hres = DSERR_NODRIVER;
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("cappos=%d readpos=%d\n", (lpdwCapturePosition?*lpdwCapturePosition:-1), (lpdwReadPosition?*lpdwReadPosition:-1));
|
|
|
|
TRACE("returning %08x\n", hres);
|
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFormat(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPWAVEFORMATEX lpwfxFormat,
|
|
|
|
DWORD dwSizeAllocated,
|
|
|
|
LPDWORD lpdwSizeWritten )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
HRESULT hres = DS_OK;
|
|
|
|
TRACE( "(%p,%p,0x%08x,%p)\n", This, lpwfxFormat, dwSizeAllocated,
|
|
|
|
lpdwSizeWritten );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (dwSizeAllocated > (sizeof(WAVEFORMATEX) + This->device->pwfx->cbSize))
|
|
|
|
dwSizeAllocated = sizeof(WAVEFORMATEX) + This->device->pwfx->cbSize;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpwfxFormat) { /* NULL is valid (just want size) */
|
|
|
|
CopyMemory(lpwfxFormat, This->device->pwfx, dwSizeAllocated);
|
|
|
|
if (lpdwSizeWritten)
|
|
|
|
*lpdwSizeWritten = dwSizeAllocated;
|
|
|
|
} else {
|
|
|
|
if (lpdwSizeWritten)
|
|
|
|
*lpdwSizeWritten = sizeof(WAVEFORMATEX) + This->device->pwfx->cbSize;
|
|
|
|
else {
|
|
|
|
TRACE("invalid parameter: lpdwSizeWritten = NULL\n");
|
|
|
|
hres = DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("returning %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_GetStatus(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDWORD lpdwStatus )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
TRACE( "(%p, %p), thread is %04x\n", This, lpdwStatus, GetCurrentThreadId() );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpdwStatus == NULL) {
|
|
|
|
WARN("invalid parameter: lpdwStatus == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*lpdwStatus = 0;
|
|
|
|
EnterCriticalSection(&(This->device->lock));
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("old This->device->state=%s, old lpdwStatus=%08x\n",
|
|
|
|
captureStateString[This->device->state],*lpdwStatus);
|
|
|
|
if ((This->device->state == STATE_STARTING) ||
|
|
|
|
(This->device->state == STATE_CAPTURING)) {
|
|
|
|
*lpdwStatus |= DSCBSTATUS_CAPTURING;
|
|
|
|
if (This->flags & DSCBSTART_LOOPING)
|
|
|
|
*lpdwStatus |= DSCBSTATUS_LOOPING;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("new This->device->state=%s, new lpdwStatus=%08x\n",
|
|
|
|
captureStateString[This->device->state],*lpdwStatus);
|
|
|
|
LeaveCriticalSection(&(This->device->lock));
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("status=%x\n", *lpdwStatus);
|
|
|
|
TRACE("returning DS_OK\n");
|
|
|
|
return DS_OK;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Initialize(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
LPDIRECTSOUNDCAPTURE lpDSC,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBDesc )
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
FIXME( "(%p,%p,%p): stub\n", This, lpDSC, lpcDSCBDesc );
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
return DS_OK;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureBufferImpl_Lock(
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
|
|
|
DWORD dwReadCusor,
|
|
|
|
DWORD dwReadBytes,
|
|
|
|
LPVOID* lplpvAudioPtr1,
|
|
|
|
LPDWORD lpdwAudioBytes1,
|
|
|
|
LPVOID* lplpvAudioPtr2,
|
|
|
|
LPDWORD lpdwAudioBytes2,
|
|
|
|
DWORD dwFlags )
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
HRESULT hres = DS_OK;
|
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
TRACE( "(%p,%08u,%08u,%p,%p,%p,%p,0x%08x) at %d\n", This, dwReadCusor,
|
|
|
|
dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2,
|
|
|
|
lpdwAudioBytes2, dwFlags, GetTickCount() );
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lplpvAudioPtr1 == NULL) {
|
|
|
|
WARN("invalid parameter: lplpvAudioPtr1 == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpdwAudioBytes1 == NULL) {
|
|
|
|
WARN("invalid parameter: lpdwAudioBytes1 == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
EnterCriticalSection(&(This->device->lock));
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Lock(This->device->hwbuf, lplpvAudioPtr1,
|
|
|
|
lpdwAudioBytes1, lplpvAudioPtr2,
|
|
|
|
lpdwAudioBytes2, dwReadCusor,
|
|
|
|
dwReadBytes, dwFlags);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Lock failed\n");
|
|
|
|
} else if (This->device->hwi) {
|
|
|
|
*lplpvAudioPtr1 = This->device->buffer + dwReadCusor;
|
|
|
|
if ( (dwReadCusor + dwReadBytes) > This->device->buflen) {
|
|
|
|
*lpdwAudioBytes1 = This->device->buflen - dwReadCusor;
|
|
|
|
if (lplpvAudioPtr2)
|
|
|
|
*lplpvAudioPtr2 = This->device->buffer;
|
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = dwReadBytes - *lpdwAudioBytes1;
|
|
|
|
} else {
|
|
|
|
*lpdwAudioBytes1 = dwReadBytes;
|
|
|
|
if (lplpvAudioPtr2)
|
|
|
|
*lplpvAudioPtr2 = 0;
|
|
|
|
if (lpdwAudioBytes2)
|
|
|
|
*lpdwAudioBytes2 = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TRACE("invalid call\n");
|
|
|
|
hres = DSERR_INVALIDCALL; /* DSERR_NODRIVER ? */
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
LeaveCriticalSection(&(This->device->lock));
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("returning %08x\n", hres);
|
|
|
|
return hres;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
static HRESULT WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_Start(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
2009-12-02 12:12:37 +01:00
|
|
|
DWORD dwFlags )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE( "(%p,0x%08x)\n", This, dwFlags );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-08-07 00:57:24 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if ( (This->device->driver == 0) && (This->device->hwi == 0) ) {
|
|
|
|
WARN("no driver\n");
|
|
|
|
return DSERR_NODRIVER;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
EnterCriticalSection(&(This->device->lock));
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
This->flags = dwFlags;
|
|
|
|
TRACE("old This->state=%s\n",captureStateString[This->device->state]);
|
|
|
|
if (This->device->state == STATE_STOPPED)
|
|
|
|
This->device->state = STATE_STARTING;
|
|
|
|
else if (This->device->state == STATE_STOPPING)
|
|
|
|
This->device->state = STATE_CAPTURING;
|
|
|
|
TRACE("new This->device->state=%s\n",captureStateString[This->device->state]);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
LeaveCriticalSection(&(This->device->lock));
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Start(This->device->hwbuf, dwFlags);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Start failed\n");
|
|
|
|
} else if (This->device->hwi) {
|
|
|
|
DirectSoundCaptureDevice *device = This->device;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (device->buffer) {
|
|
|
|
int c;
|
|
|
|
DWORD blocksize = DSOUND_fraglen(device->pwfx->nSamplesPerSec, device->pwfx->nBlockAlign);
|
|
|
|
device->nrofpwaves = device->buflen / blocksize + !!(device->buflen % blocksize);
|
|
|
|
TRACE("nrofpwaves=%d\n", device->nrofpwaves);
|
2004-08-16 21:59:37 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/* prepare headers */
|
|
|
|
if (device->pwave)
|
|
|
|
device->pwave = HeapReAlloc(GetProcessHeap(), 0,device->pwave, device->nrofpwaves*sizeof(WAVEHDR));
|
|
|
|
else
|
|
|
|
device->pwave = HeapAlloc(GetProcessHeap(), 0, device->nrofpwaves*sizeof(WAVEHDR));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
for (c = 0; c < device->nrofpwaves; ++c) {
|
|
|
|
device->pwave[c].lpData = (char *)device->buffer + c * blocksize;
|
|
|
|
if (c + 1 == device->nrofpwaves)
|
|
|
|
device->pwave[c].dwBufferLength = device->buflen - c * blocksize;
|
|
|
|
else
|
|
|
|
device->pwave[c].dwBufferLength = blocksize;
|
|
|
|
device->pwave[c].dwBytesRecorded = 0;
|
|
|
|
device->pwave[c].dwUser = (DWORD_PTR)device;
|
|
|
|
device->pwave[c].dwFlags = 0;
|
|
|
|
device->pwave[c].dwLoops = 0;
|
|
|
|
hres = mmErr(waveInPrepareHeader(device->hwi, &(device->pwave[c]),sizeof(WAVEHDR)));
|
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("waveInPrepareHeader failed\n");
|
|
|
|
while (c--)
|
|
|
|
waveInUnprepareHeader(device->hwi, &(device->pwave[c]),sizeof(WAVEHDR));
|
|
|
|
break;
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
hres = mmErr(waveInAddBuffer(device->hwi, &(device->pwave[c]), sizeof(WAVEHDR)));
|
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("waveInAddBuffer failed\n");
|
|
|
|
while (c--)
|
|
|
|
waveInUnprepareHeader(device->hwi, &(device->pwave[c]),sizeof(WAVEHDR));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
FillMemory(device->buffer, device->buflen, (device->pwfx->wBitsPerSample == 8) ? 128 : 0);
|
|
|
|
}
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
device->index = 0;
|
2004-10-21 22:57:26 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (hres == DS_OK) {
|
|
|
|
/* start filling the first buffer */
|
|
|
|
hres = mmErr(waveInStart(device->hwi));
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("waveInStart failed\n");
|
|
|
|
}
|
2008-05-30 09:34:45 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("calling waveInClose because of error\n");
|
|
|
|
waveInClose(device->hwi);
|
|
|
|
device->hwi = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WARN("no driver\n");
|
|
|
|
hres = DSERR_NODRIVER;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2009-12-02 12:12:37 +01:00
|
|
|
|
|
|
|
TRACE("returning %08x\n", hres);
|
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE( "(%p)\n", This );
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("invalid parameter: This->device == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
EnterCriticalSection(&(This->device->lock));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("old This->device->state=%s\n",captureStateString[This->device->state]);
|
|
|
|
if (This->device->state == STATE_CAPTURING)
|
|
|
|
This->device->state = STATE_STOPPING;
|
|
|
|
else if (This->device->state == STATE_STARTING)
|
|
|
|
This->device->state = STATE_STOPPED;
|
|
|
|
TRACE("new This->device->state=%s\n",captureStateString[This->device->state]);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
LeaveCriticalSection(&(This->device->lock));
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (This->device->driver) {
|
2009-12-02 12:12:37 +01:00
|
|
|
hres = IDsCaptureDriverBuffer_Stop(This->device->hwbuf);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Stop() failed\n");
|
2006-01-05 13:37:15 +01:00
|
|
|
} else if (This->device->hwi) {
|
2009-12-02 12:12:37 +01:00
|
|
|
hres = mmErr(waveInReset(This->device->hwi));
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("waveInReset() failed\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
} else {
|
2009-12-02 12:12:37 +01:00
|
|
|
WARN("no driver\n");
|
2004-11-19 18:56:56 +01:00
|
|
|
hres = DSERR_NODRIVER;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2004-10-21 22:57:26 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("returning %08x\n", hres);
|
2004-11-19 18:56:56 +01:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_Unlock(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
2009-12-02 12:12:37 +01:00
|
|
|
LPVOID lpvAudioPtr1,
|
|
|
|
DWORD dwAudioBytes1,
|
|
|
|
LPVOID lpvAudioPtr2,
|
|
|
|
DWORD dwAudioBytes2 )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2004-11-19 18:56:56 +01:00
|
|
|
HRESULT hres = DS_OK;
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
|
|
|
TRACE( "(%p,%p,%08u,%p,%08u)\n", This, lpvAudioPtr1, dwAudioBytes1,
|
|
|
|
lpvAudioPtr2, dwAudioBytes2 );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (lpvAudioPtr1 == NULL) {
|
|
|
|
WARN("invalid parameter: lpvAudioPtr1 == NULL\n");
|
2003-02-15 01:01:17 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device->driver) {
|
|
|
|
hres = IDsCaptureDriverBuffer_Unlock(This->device->hwbuf, lpvAudioPtr1,
|
|
|
|
dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsCaptureDriverBuffer_Unlock failed\n");
|
|
|
|
} else if (!This->device->hwi) {
|
|
|
|
WARN("invalid call\n");
|
|
|
|
hres = DSERR_INVALIDCALL;
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("returning %08x\n", hres);
|
2004-11-19 18:56:56 +01:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_GetObjectInPath(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
2009-12-02 12:12:37 +01:00
|
|
|
REFGUID rguidObject,
|
|
|
|
DWORD dwIndex,
|
|
|
|
REFGUID rguidInterface,
|
|
|
|
LPVOID* ppObject )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
FIXME( "(%p,%s,%u,%s,%p): stub\n", This, debugstr_guid(rguidObject),
|
|
|
|
dwIndex, debugstr_guid(rguidInterface), ppObject );
|
2003-02-15 01:01:17 +01:00
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureBufferImpl_GetFXStatus(
|
2003-02-15 01:01:17 +01:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER8 iface,
|
2009-12-02 12:12:37 +01:00
|
|
|
DWORD dwFXCount,
|
|
|
|
LPDWORD pdwFXStatus )
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
FIXME( "(%p,%u,%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
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static const IDirectSoundCaptureBuffer8Vtbl dscbvt =
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureBufferImpl_AddRef,
|
|
|
|
IDirectSoundCaptureBufferImpl_Release,
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/* IDirectSoundCaptureBuffer methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCaps,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetCurrentPosition,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFormat,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetStatus,
|
|
|
|
IDirectSoundCaptureBufferImpl_Initialize,
|
|
|
|
IDirectSoundCaptureBufferImpl_Lock,
|
|
|
|
IDirectSoundCaptureBufferImpl_Start,
|
|
|
|
IDirectSoundCaptureBufferImpl_Stop,
|
|
|
|
IDirectSoundCaptureBufferImpl_Unlock,
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/* IDirectSoundCaptureBuffer methods */
|
|
|
|
IDirectSoundCaptureBufferImpl_GetObjectInPath,
|
|
|
|
IDirectSoundCaptureBufferImpl_GetFXStatus
|
|
|
|
};
|
2003-05-22 05:39:13 +02:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static void capture_CheckNotify(IDirectSoundCaptureBufferImpl *This, DWORD from, DWORD len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < This->nrofnotifies; ++i) {
|
|
|
|
LPDSBPOSITIONNOTIFY event = This->notifies + i;
|
|
|
|
DWORD offset = event->dwOffset;
|
|
|
|
TRACE("checking %d, position %d, event = %p\n", i, offset, event->hEventNotify);
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (offset == DSBPN_OFFSETSTOP) {
|
|
|
|
if (!from && !len) {
|
|
|
|
SetEvent(event->hEventNotify);
|
|
|
|
TRACE("signalled event %p (%d)\n", event->hEventNotify, i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else return;
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (offset >= from && offset < (from + len))
|
|
|
|
{
|
|
|
|
TRACE("signalled event %p (%d)\n", event->hEventNotify, i);
|
|
|
|
SetEvent(event->hEventNotify);
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static void CALLBACK
|
|
|
|
DSOUND_capture_callback(HWAVEIN hwi, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1,
|
|
|
|
DWORD_PTR dw2)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice * This = (DirectSoundCaptureDevice*)dwUser;
|
|
|
|
IDirectSoundCaptureBufferImpl * Moi = This->capture_buffer;
|
|
|
|
TRACE("(%p,%08x(%s),%08lx,%08lx,%08lx) entering at %d\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
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (msg == MM_WIM_DATA) {
|
|
|
|
EnterCriticalSection( &(This->lock) );
|
|
|
|
TRACE("DirectSoundCapture msg=MM_WIM_DATA, old This->state=%s, old This->index=%d\n",
|
|
|
|
captureStateString[This->state],This->index);
|
|
|
|
if (This->state != STATE_STOPPED) {
|
|
|
|
int index = This->index;
|
|
|
|
if (This->state == STATE_STARTING)
|
|
|
|
This->state = STATE_CAPTURING;
|
|
|
|
capture_CheckNotify(Moi, (DWORD_PTR)This->pwave[index].lpData - (DWORD_PTR)This->buffer, This->pwave[index].dwBufferLength);
|
|
|
|
This->index = (This->index + 1) % This->nrofpwaves;
|
|
|
|
if ( (This->index == 0) && !(This->capture_buffer->flags & DSCBSTART_LOOPING) ) {
|
|
|
|
TRACE("end of buffer\n");
|
|
|
|
This->state = STATE_STOPPED;
|
|
|
|
capture_CheckNotify(Moi, 0, 0);
|
|
|
|
} else {
|
|
|
|
if (This->state == STATE_CAPTURING) {
|
|
|
|
waveInUnprepareHeader(hwi, &(This->pwave[index]), sizeof(WAVEHDR));
|
|
|
|
waveInPrepareHeader(hwi, &(This->pwave[index]), sizeof(WAVEHDR));
|
|
|
|
waveInAddBuffer(hwi, &(This->pwave[index]), sizeof(WAVEHDR));
|
|
|
|
} else if (This->state == STATE_STOPPING) {
|
|
|
|
TRACE("stopping\n");
|
|
|
|
This->state = STATE_STOPPED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("DirectSoundCapture new This->state=%s, new This->index=%d\n",
|
|
|
|
captureStateString[This->state],This->index);
|
|
|
|
LeaveCriticalSection( &(This->lock) );
|
2003-02-15 01:01:17 +01:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
TRACE("completed\n");
|
|
|
|
}
|
2003-03-04 03:12:34 +01:00
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static HRESULT IDirectSoundCaptureBufferImpl_Create(
|
2006-01-05 13:37:15 +01:00
|
|
|
DirectSoundCaptureDevice *device,
|
|
|
|
IDirectSoundCaptureBufferImpl ** ppobj,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc)
|
2006-01-04 14:49:34 +01:00
|
|
|
{
|
|
|
|
LPWAVEFORMATEX wfex;
|
2006-01-05 13:37:15 +01:00
|
|
|
TRACE( "(%p,%p,%p)\n", device, ppobj, lpcDSCBufferDesc);
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter: ppobj == NULL\n");
|
2006-01-04 14:49:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (!device) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_UNINITIALIZED;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (lpcDSCBufferDesc == NULL) {
|
|
|
|
WARN("invalid parameter: lpcDSCBufferDesc == NULL\n");
|
|
|
|
*ppobj = NULL;
|
2006-01-04 14:49:34 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ((lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC)) &&
|
|
|
|
(lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC1))) ||
|
|
|
|
(lpcDSCBufferDesc->dwBufferBytes == 0) ||
|
2009-10-04 14:30:50 +02:00
|
|
|
(lpcDSCBufferDesc->lpwfxFormat == NULL) ) { /* FIXME: DSERR_BADFORMAT ? */
|
2006-01-04 14:49:34 +01:00
|
|
|
WARN("invalid lpcDSCBufferDesc\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
wfex = lpcDSCBufferDesc->lpwfxFormat;
|
|
|
|
|
2009-10-04 14:30:50 +02:00
|
|
|
TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
|
|
|
|
"bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
|
|
|
|
wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
|
|
|
|
wfex->nAvgBytesPerSec, wfex->nBlockAlign,
|
|
|
|
wfex->wBitsPerSample, wfex->cbSize);
|
|
|
|
|
2009-10-04 08:05:20 +02:00
|
|
|
device->pwfx = DSOUND_CopyFormat(wfex);
|
|
|
|
if ( device->pwfx == NULL ) {
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(IDirectSoundCaptureBufferImpl));
|
|
|
|
|
|
|
|
if ( *ppobj == NULL ) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
} else {
|
|
|
|
HRESULT err = DS_OK;
|
|
|
|
LPBYTE newbuf;
|
|
|
|
DWORD buflen;
|
2007-12-31 22:38:23 +01:00
|
|
|
IDirectSoundCaptureBufferImpl *This = *ppobj;
|
2006-01-04 14:49:34 +01:00
|
|
|
|
|
|
|
This->ref = 1;
|
2006-01-05 13:37:15 +01:00
|
|
|
This->device = device;
|
|
|
|
This->device->capture_buffer = This;
|
2006-01-04 14:49:34 +01:00
|
|
|
This->notify = NULL;
|
|
|
|
This->nrofnotifies = 0;
|
|
|
|
This->hwnotify = NULL;
|
|
|
|
|
|
|
|
This->pdscbd = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
lpcDSCBufferDesc->dwSize);
|
|
|
|
if (This->pdscbd)
|
|
|
|
CopyMemory(This->pdscbd, lpcDSCBufferDesc, lpcDSCBufferDesc->dwSize);
|
|
|
|
else {
|
|
|
|
WARN("no memory\n");
|
2006-01-05 13:37:15 +01:00
|
|
|
This->device->capture_buffer = 0;
|
2006-01-04 14:49:34 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->lpVtbl = &dscbvt;
|
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (device->driver) {
|
|
|
|
if (This->device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
|
2006-01-04 14:49:34 +01:00
|
|
|
FIXME("DSDDESC_DOMMSYSTEMOPEN not supported\n");
|
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (This->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
|
2006-01-04 14:49:34 +01:00
|
|
|
/* allocate buffer from system memory */
|
|
|
|
buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer);
|
2006-01-05 13:37:15 +01:00
|
|
|
if (device->buffer)
|
|
|
|
newbuf = HeapReAlloc(GetProcessHeap(),0,device->buffer,buflen);
|
2006-01-04 14:49:34 +01: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 {
|
2006-01-05 13:37:15 +01:00
|
|
|
device->buffer = newbuf;
|
|
|
|
device->buflen = buflen;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* let driver allocate memory */
|
2006-01-05 13:37:15 +01:00
|
|
|
device->buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2006-01-04 14:49:34 +01:00
|
|
|
/* FIXME: */
|
2006-01-05 13:37:15 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, device->buffer);
|
|
|
|
device->buffer = NULL;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
err = IDsCaptureDriver_CreateCaptureBuffer(device->driver,
|
|
|
|
device->pwfx,0,0,&(device->buflen),&(device->buffer),(LPVOID*)&(device->hwbuf));
|
2006-01-04 14:49:34 +01:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n");
|
2006-01-05 13:37:15 +01:00
|
|
|
This->device->capture_buffer = 0;
|
2006-01-04 14:49:34 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DWORD flags = CALLBACK_FUNCTION;
|
2006-01-05 13:37:15 +01:00
|
|
|
err = mmErr(waveInOpen(&(device->hwi),
|
|
|
|
device->drvdesc.dnDevNode, device->pwfx,
|
2009-02-11 23:17:12 +01:00
|
|
|
(DWORD_PTR)DSOUND_capture_callback, (DWORD_PTR)device, flags));
|
2006-01-04 14:49:34 +01:00
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("waveInOpen failed\n");
|
2006-01-05 13:37:15 +01:00
|
|
|
This->device->capture_buffer = 0;
|
2006-01-04 14:49:34 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
*ppobj = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
buflen = lpcDSCBufferDesc->dwBufferBytes;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer);
|
2006-01-05 13:37:15 +01:00
|
|
|
if (device->buffer)
|
|
|
|
newbuf = HeapReAlloc(GetProcessHeap(),0,device->buffer,buflen);
|
2006-01-04 14:49:34 +01: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 {
|
2006-01-05 13:37:15 +01:00
|
|
|
device->buffer = newbuf;
|
|
|
|
device->buflen = buflen;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("returning DS_OK\n");
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
|
2006-01-04 14:49:34 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundCaptureDevice
|
|
|
|
*/
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
|
|
|
|
|
|
|
|
static HRESULT DirectSoundCaptureDevice_Create(
|
|
|
|
DirectSoundCaptureDevice ** ppDevice)
|
2006-01-05 13:37:15 +01:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice * device;
|
|
|
|
TRACE("(%p)\n", ppDevice);
|
2006-01-05 13:37:15 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/* Allocate memory */
|
|
|
|
device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DirectSoundCaptureDevice));
|
2006-01-05 13:37:15 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2006-01-05 13:37:15 +01:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
device->ref = 1;
|
|
|
|
device->state = STATE_STOPPED;
|
2006-01-05 13:37:15 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
InitializeCriticalSection( &(device->lock) );
|
|
|
|
device->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DirectSoundCaptureDevice.lock");
|
2006-01-05 13:37:15 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*ppDevice = device;
|
2006-01-05 13:37:15 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static ULONG DirectSoundCaptureDevice_Release(
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice * device)
|
|
|
|
{
|
|
|
|
ULONG ref = InterlockedDecrement(&(device->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", device, ref + 1);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, device->pwfx);
|
|
|
|
device->lock.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection( &(device->lock) );
|
|
|
|
DSOUND_capture[device->drvdesc.dnDevNode] = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, device);
|
|
|
|
TRACE("(%p) released\n", device);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static HRESULT DirectSoundCaptureDevice_Initialize(
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice ** ppDevice,
|
|
|
|
LPCGUID lpcGUID)
|
|
|
|
{
|
|
|
|
HRESULT err = DSERR_INVALIDPARAM;
|
|
|
|
unsigned wid, widn;
|
|
|
|
BOOLEAN found = FALSE;
|
|
|
|
GUID devGUID;
|
|
|
|
DirectSoundCaptureDevice *device = *ppDevice;
|
|
|
|
TRACE("(%p, %s)\n", ppDevice, debugstr_guid(lpcGUID));
|
|
|
|
|
|
|
|
/* Default device? */
|
|
|
|
if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) )
|
|
|
|
lpcGUID = &DSDEVID_DefaultCapture;
|
|
|
|
|
|
|
|
if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) {
|
|
|
|
WARN("invalid parameter: lpcGUID\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
widn = waveInGetNumDevs();
|
|
|
|
if (!widn) {
|
|
|
|
WARN("no audio devices found\n");
|
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
2010-01-05 22:20:52 +01:00
|
|
|
/* enumerate WINMM audio devices and find the one we want */
|
|
|
|
for (wid=0; wid<widn; wid++) {
|
|
|
|
if (IsEqualGUID( &devGUID, &DSOUND_capture_guids[wid]) ) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-12-02 12:12:37 +01:00
|
|
|
|
|
|
|
if (found == FALSE) {
|
|
|
|
WARN("No device found matching given ID!\n");
|
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DSOUND_capture[wid]) {
|
2006-01-05 13:37:15 +01:00
|
|
|
WARN("already in use\n");
|
|
|
|
return DSERR_ALLOCATED;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = DirectSoundCaptureDevice_Create(&(device));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("DirectSoundCaptureDevice_Create failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppDevice = device;
|
|
|
|
device->guid = devGUID;
|
|
|
|
|
2007-08-04 11:11:17 +02:00
|
|
|
/* Disable the direct sound driver to force emulation if requested. */
|
|
|
|
device->driver = NULL;
|
2007-08-07 11:00:17 +02:00
|
|
|
if (ds_hw_accel != DS_HW_ACCEL_EMULATION)
|
2007-08-04 11:11:17 +02:00
|
|
|
{
|
2009-01-28 01:07:25 +01:00
|
|
|
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDIFACE,(DWORD_PTR)&device->driver,0));
|
2007-08-04 11:11:17 +02:00
|
|
|
if ( (err != DS_OK) && (err != DSERR_UNSUPPORTED) ) {
|
|
|
|
WARN("waveInMessage failed; err=%x\n",err);
|
|
|
|
return err;
|
|
|
|
}
|
2006-01-05 13:37:15 +01:00
|
|
|
}
|
|
|
|
err = DS_OK;
|
|
|
|
|
|
|
|
/* Get driver description */
|
|
|
|
if (device->driver) {
|
|
|
|
TRACE("using DirectSound driver\n");
|
|
|
|
err = IDsCaptureDriver_GetDriverDesc(device->driver, &(device->drvdesc));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetDriverDesc failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TRACE("using WINMM\n");
|
|
|
|
/* if no DirectSound interface available, use WINMM API instead */
|
|
|
|
device->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN |
|
|
|
|
DSDDESC_DOMMSYSTEMSETFORMAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
device->drvdesc.dnDevNode = wid;
|
|
|
|
|
|
|
|
/* open the DirectSound driver if available */
|
|
|
|
if (device->driver && (err == DS_OK))
|
|
|
|
err = IDsCaptureDriver_Open(device->driver);
|
|
|
|
|
|
|
|
if (err == DS_OK) {
|
|
|
|
*ppDevice = device;
|
|
|
|
|
|
|
|
/* the driver is now open, so it's now allowed to call GetCaps */
|
|
|
|
if (device->driver) {
|
|
|
|
device->drvcaps.dwSize = sizeof(device->drvcaps);
|
|
|
|
err = IDsCaptureDriver_GetCaps(device->driver,&(device->drvcaps));
|
|
|
|
if (err != DS_OK) {
|
|
|
|
WARN("IDsCaptureDriver_GetCaps failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else /*if (device->hwi)*/ {
|
|
|
|
WAVEINCAPSA wic;
|
|
|
|
err = mmErr(waveInGetDevCapsA((UINT)device->drvdesc.dnDevNode, &wic, sizeof(wic)));
|
|
|
|
|
|
|
|
if (err == DS_OK) {
|
|
|
|
device->drvcaps.dwFlags = 0;
|
|
|
|
lstrcpynA(device->drvdesc.szDrvname, wic.szPname,
|
|
|
|
sizeof(device->drvdesc.szDrvname));
|
|
|
|
|
|
|
|
device->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER;
|
|
|
|
device->drvcaps.dwFormats = wic.dwFormats;
|
|
|
|
device->drvcaps.dwChannels = wic.wChannels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectSoundCapture implementation structure
|
|
|
|
*/
|
|
|
|
struct IDirectSoundCaptureImpl
|
2006-01-04 14:49:34 +01:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
/* IUnknown fields */
|
|
|
|
const IDirectSoundCaptureVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
DirectSoundCaptureDevice *device;
|
|
|
|
};
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* IDirectSoundCaptureImpl
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppobj )
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*ppobj = NULL;
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01: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;
|
|
|
|
}
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
|
|
|
return ref;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
static ULONG WINAPI
|
|
|
|
IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
|
2006-01-04 14:49:34 +01:00
|
|
|
{
|
2009-12-02 12:12:37 +01:00
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2006-01-05 13:37:15 +01:00
|
|
|
if (!ref) {
|
2009-12-02 12:12:37 +01:00
|
|
|
if (This->device)
|
|
|
|
DirectSoundCaptureDevice_Release(This->device);
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
|
2009-12-02 12:12:37 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCDSCBUFFERDESC lpcDSCBufferDesc,
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
|
|
|
|
LPUNKNOWN pUnk )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
|
|
|
|
TRACE( "(%p,%p,%p,%p)\n",iface,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
|
|
|
|
|
|
|
|
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");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: We can only have one buffer so what do we do here? */
|
|
|
|
if (This->device->capture_buffer) {
|
2010-01-12 11:28:33 +01:00
|
|
|
WARN("invalid parameter: already has buffer\n");
|
2009-12-02 12:12:37 +01:00
|
|
|
return DSERR_INVALIDPARAM; /* DSERR_GENERIC ? */
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectSoundCaptureBufferImpl_Create(This->device,
|
|
|
|
(IDirectSoundCaptureBufferImpl **)lplpDSCaptureBuffer, lpcDSCBufferDesc);
|
|
|
|
|
|
|
|
if (hr != DS_OK)
|
|
|
|
WARN("IDirectSoundCaptureBufferImpl_Create failed\n");
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
|
2009-12-02 12:12:37 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPDSCCAPS lpDSCCaps )
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
|
|
|
|
|
|
|
if (This->device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCCaps== NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCCaps->dwSize < sizeof(*lpDSCCaps)) {
|
|
|
|
WARN("invalid parameter: lpDSCCaps->dwSize = %d\n", lpDSCCaps->dwSize);
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags;
|
|
|
|
lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats;
|
|
|
|
lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels;
|
|
|
|
|
|
|
|
TRACE("(flags=0x%08x,format=0x%08x,channels=%d)\n",lpDSCCaps->dwFlags,
|
|
|
|
lpDSCCaps->dwFormats, lpDSCCaps->dwChannels);
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-02 12:12:47 +01:00
|
|
|
static HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
|
2009-12-02 12:12:37 +01:00
|
|
|
LPDIRECTSOUNDCAPTURE iface,
|
|
|
|
LPCGUID lpcGUID )
|
|
|
|
{
|
|
|
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
|
|
|
TRACE("(%p,%s)\n", This, debugstr_guid(lpcGUID));
|
|
|
|
|
|
|
|
if (This->device != NULL) {
|
|
|
|
WARN("already initialized\n");
|
|
|
|
return DSERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
return DirectSoundCaptureDevice_Initialize(&This->device, lpcGUID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDirectSoundCaptureVtbl dscvt =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSoundCaptureImpl_QueryInterface,
|
|
|
|
IDirectSoundCaptureImpl_AddRef,
|
|
|
|
IDirectSoundCaptureImpl_Release,
|
|
|
|
|
|
|
|
/* IDirectSoundCapture methods */
|
|
|
|
IDirectSoundCaptureImpl_CreateCaptureBuffer,
|
|
|
|
IDirectSoundCaptureImpl_GetCaps,
|
|
|
|
IDirectSoundCaptureImpl_Initialize
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT 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 DSOUND_CaptureCreate(
|
|
|
|
REFIID riid,
|
|
|
|
LPDIRECTSOUNDCAPTURE *ppDSC)
|
|
|
|
{
|
|
|
|
LPDIRECTSOUNDCAPTURE pDSC;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC);
|
|
|
|
|
|
|
|
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
|
|
|
!IsEqualIID(riid, &IID_IDirectSoundCapture)) {
|
|
|
|
*ppDSC = 0;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 DSOUND_CaptureCreate8(
|
|
|
|
REFIID riid,
|
|
|
|
LPDIRECTSOUNDCAPTURE8 *ppDSC8)
|
|
|
|
{
|
|
|
|
LPDIRECTSOUNDCAPTURE8 pDSC8;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC8);
|
|
|
|
|
|
|
|
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
|
|
|
!IsEqualIID(riid, &IID_IDirectSoundCapture8)) {
|
|
|
|
*ppDSC8 = 0;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* DirectSoundCaptureCreate [DSOUND.6]
|
|
|
|
*
|
|
|
|
* 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 DirectSoundCaptureCreate(
|
|
|
|
LPCGUID lpcGUID,
|
|
|
|
LPDIRECTSOUNDCAPTURE *ppDSC,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pUnkOuter) {
|
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
|
|
|
*ppDSC = NULL;
|
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DSOUND_CaptureCreate(&IID_IDirectSoundCapture, &pDSC);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSoundCapture_Initialize(pDSC, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
IDirectSoundCapture_Release(pDSC);
|
|
|
|
pDSC = 0;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
2009-12-02 12:12:37 +01:00
|
|
|
}
|
2006-01-04 14:49:34 +01:00
|
|
|
|
2009-12-02 12:12:37 +01:00
|
|
|
*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");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|
2009-12-02 12:12:37 +01:00
|
|
|
|
|
|
|
if (pUnkOuter) {
|
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
|
|
|
*ppDSC8 = NULL;
|
|
|
|
return DSERR_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, &pDSC8);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSoundCapture_Initialize(pDSC8, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
IDirectSoundCapture_Release(pDSC8);
|
|
|
|
pDSC8 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppDSC8 = pDSC8;
|
|
|
|
|
|
|
|
return hr;
|
2006-01-04 14:49:34 +01:00
|
|
|
}
|