2004-07-04 02:13:44 +02:00
|
|
|
/* DirectSound
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Rob Riggs
|
|
|
|
* Copyright 2000-2002 TransGaming Technologies, Inc.
|
|
|
|
* Copyright 2004 Robert Reif
|
|
|
|
*
|
|
|
|
* 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
|
2004-07-04 02:13:44 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-17 11:24:50 +02:00
|
|
|
#include "winuser.h"
|
2004-07-04 02:13:44 +02:00
|
|
|
#include "mmsystem.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "mmddk.h"
|
2007-11-05 23:23:11 +01:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "mmreg.h"
|
|
|
|
#include "ks.h"
|
|
|
|
#include "ksmedia.h"
|
2004-07-04 02:13:44 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
|
|
|
#include "dsdriver.h"
|
|
|
|
#include "dsound_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectSound COM components
|
|
|
|
*/
|
|
|
|
struct IDirectSound_IUnknown {
|
|
|
|
const IUnknownVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
LPDIRECTSOUND8 pds;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSound_IUnknown_Create(LPDIRECTSOUND8 pds, LPUNKNOWN * ppunk);
|
|
|
|
|
|
|
|
struct IDirectSound_IDirectSound {
|
|
|
|
const IDirectSoundVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
LPDIRECTSOUND8 pds;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSound_IDirectSound_Create(LPDIRECTSOUND8 pds, LPDIRECTSOUND * ppds);
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectSound8 COM components
|
|
|
|
*/
|
|
|
|
struct IDirectSound8_IUnknown {
|
|
|
|
const IUnknownVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
LPDIRECTSOUND8 pds;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSound8_IUnknown_Create(LPDIRECTSOUND8 pds, LPUNKNOWN * ppunk);
|
2004-07-04 02:13:44 +02:00
|
|
|
static ULONG WINAPI IDirectSound8_IUnknown_AddRef(LPUNKNOWN iface);
|
2006-08-02 13:26:14 +02:00
|
|
|
|
|
|
|
struct IDirectSound8_IDirectSound {
|
|
|
|
const IDirectSoundVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
LPDIRECTSOUND8 pds;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSound8_IDirectSound_Create(LPDIRECTSOUND8 pds, LPDIRECTSOUND * ppds);
|
2004-07-04 02:13:44 +02:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound_AddRef(LPDIRECTSOUND iface);
|
2006-08-02 13:26:14 +02:00
|
|
|
|
|
|
|
struct IDirectSound8_IDirectSound8 {
|
|
|
|
const IDirectSound8Vtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
LPDIRECTSOUND8 pds;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSound8_IDirectSound8_Create(LPDIRECTSOUND8 pds, LPDIRECTSOUND8 * ppds);
|
2004-07-04 02:13:44 +02:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound8_AddRef(LPDIRECTSOUND8 iface);
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectSound implementation structure
|
|
|
|
*/
|
|
|
|
struct IDirectSoundImpl
|
|
|
|
{
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
DirectSoundDevice *device;
|
|
|
|
LPUNKNOWN pUnknown;
|
|
|
|
LPDIRECTSOUND pDS;
|
|
|
|
LPDIRECTSOUND8 pDS8;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSoundImpl_Create(LPDIRECTSOUND8 * ppds);
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectSound_IUnknown_AddRef(LPUNKNOWN iface);
|
|
|
|
static ULONG WINAPI IDirectSound_IDirectSound_AddRef(LPDIRECTSOUND iface);
|
|
|
|
|
|
|
|
static HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device, LPDWORD pdwCertified);
|
|
|
|
|
2006-01-16 20:39:52 +01:00
|
|
|
const char * dumpCooperativeLevel(DWORD level)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
|
|
|
static char unknown[32];
|
|
|
|
#define LE(x) case x: return #x
|
|
|
|
switch (level) {
|
|
|
|
LE(DSSCL_NORMAL);
|
|
|
|
LE(DSSCL_PRIORITY);
|
|
|
|
LE(DSSCL_EXCLUSIVE);
|
|
|
|
LE(DSSCL_WRITEPRIMARY);
|
|
|
|
}
|
|
|
|
#undef LE
|
2006-11-12 14:40:35 +01:00
|
|
|
sprintf(unknown, "Unknown(%08x)", level);
|
2004-07-04 02:13:44 +02:00
|
|
|
return unknown;
|
|
|
|
}
|
|
|
|
|
2004-07-22 21:42:11 +02:00
|
|
|
static void _dump_DSCAPS(DWORD xmask) {
|
|
|
|
struct {
|
|
|
|
DWORD mask;
|
2005-07-15 11:58:36 +02:00
|
|
|
const char *name;
|
2004-07-22 21:42:11 +02:00
|
|
|
} flags[] = {
|
|
|
|
#define FE(x) { x, #x },
|
|
|
|
FE(DSCAPS_PRIMARYMONO)
|
|
|
|
FE(DSCAPS_PRIMARYSTEREO)
|
|
|
|
FE(DSCAPS_PRIMARY8BIT)
|
|
|
|
FE(DSCAPS_PRIMARY16BIT)
|
|
|
|
FE(DSCAPS_CONTINUOUSRATE)
|
|
|
|
FE(DSCAPS_EMULDRIVER)
|
|
|
|
FE(DSCAPS_CERTIFIED)
|
|
|
|
FE(DSCAPS_SECONDARYMONO)
|
|
|
|
FE(DSCAPS_SECONDARYSTEREO)
|
|
|
|
FE(DSCAPS_SECONDARY8BIT)
|
|
|
|
FE(DSCAPS_SECONDARY16BIT)
|
|
|
|
#undef FE
|
|
|
|
};
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int i;
|
2004-07-22 21:42:11 +02:00
|
|
|
|
|
|
|
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
|
|
|
|
if ((flags[i].mask & xmask) == flags[i].mask)
|
2007-03-28 17:30:16 +02:00
|
|
|
TRACE("%s ",flags[i].name);
|
2004-07-22 21:42:11 +02:00
|
|
|
}
|
|
|
|
|
2004-07-04 02:13:44 +02:00
|
|
|
static void _dump_DSBCAPS(DWORD xmask) {
|
|
|
|
struct {
|
|
|
|
DWORD mask;
|
2005-07-15 11:58:36 +02:00
|
|
|
const char *name;
|
2004-07-04 02:13:44 +02:00
|
|
|
} flags[] = {
|
|
|
|
#define FE(x) { x, #x },
|
|
|
|
FE(DSBCAPS_PRIMARYBUFFER)
|
|
|
|
FE(DSBCAPS_STATIC)
|
|
|
|
FE(DSBCAPS_LOCHARDWARE)
|
|
|
|
FE(DSBCAPS_LOCSOFTWARE)
|
|
|
|
FE(DSBCAPS_CTRL3D)
|
|
|
|
FE(DSBCAPS_CTRLFREQUENCY)
|
|
|
|
FE(DSBCAPS_CTRLPAN)
|
|
|
|
FE(DSBCAPS_CTRLVOLUME)
|
|
|
|
FE(DSBCAPS_CTRLPOSITIONNOTIFY)
|
|
|
|
FE(DSBCAPS_STICKYFOCUS)
|
|
|
|
FE(DSBCAPS_GLOBALFOCUS)
|
|
|
|
FE(DSBCAPS_GETCURRENTPOSITION2)
|
|
|
|
FE(DSBCAPS_MUTE3DATMAXDISTANCE)
|
|
|
|
#undef FE
|
|
|
|
};
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int i;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
|
|
|
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
|
|
|
|
if ((flags[i].mask & xmask) == flags[i].mask)
|
2007-03-28 17:30:16 +02:00
|
|
|
TRACE("%s ",flags[i].name);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundImpl_DirectSound
|
|
|
|
*/
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT DSOUND_QueryInterface(
|
2004-07-04 02:13:44 +02:00
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundImpl *This = (IDirectSoundImpl *)iface;
|
2004-07-04 02:13:44 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
if (!This->pUnknown) {
|
|
|
|
IDirectSound_IUnknown_Create(iface, &This->pUnknown);
|
|
|
|
if (!This->pUnknown) {
|
|
|
|
WARN("IDirectSound_IUnknown_Create() failed\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectSound_IUnknown_AddRef(This->pUnknown);
|
|
|
|
*ppobj = This->pUnknown;
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IDirectSound)) {
|
|
|
|
if (!This->pDS) {
|
|
|
|
IDirectSound_IDirectSound_Create(iface, &This->pDS);
|
|
|
|
if (!This->pDS) {
|
|
|
|
WARN("IDirectSound_IDirectSound_Create() failed\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectSound_IDirectSound_AddRef(This->pDS);
|
|
|
|
*ppobj = This->pDS;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
WARN("Unknown IID %s\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT DSOUND_QueryInterface8(
|
2004-07-04 02:13:44 +02:00
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundImpl *This = (IDirectSoundImpl *)iface;
|
2004-07-04 02:13:44 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
if (!This->pUnknown) {
|
|
|
|
IDirectSound8_IUnknown_Create(iface, &This->pUnknown);
|
|
|
|
if (!This->pUnknown) {
|
|
|
|
WARN("IDirectSound8_IUnknown_Create() failed\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectSound8_IUnknown_AddRef(This->pUnknown);
|
|
|
|
*ppobj = This->pUnknown;
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IDirectSound)) {
|
|
|
|
if (!This->pDS) {
|
|
|
|
IDirectSound8_IDirectSound_Create(iface, &This->pDS);
|
|
|
|
if (!This->pDS) {
|
|
|
|
WARN("IDirectSound8_IDirectSound_Create() failed\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectSound8_IDirectSound_AddRef(This->pDS);
|
|
|
|
*ppobj = This->pDS;
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IDirectSound8)) {
|
|
|
|
if (!This->pDS8) {
|
|
|
|
IDirectSound8_IDirectSound8_Create(iface, &This->pDS8);
|
|
|
|
if (!This->pDS8) {
|
|
|
|
WARN("IDirectSound8_IDirectSound8_Create() failed\n");
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectSound8_IDirectSound8_AddRef(This->pDS8);
|
|
|
|
*ppobj = This->pDS8;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
WARN("Unknown IID %s\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG IDirectSoundImpl_AddRef(
|
2004-07-04 02:13:44 +02:00
|
|
|
LPDIRECTSOUND8 iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundImpl *This = (IDirectSoundImpl *)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;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG IDirectSoundImpl_Release(
|
2004-07-04 02:13:44 +02:00
|
|
|
LPDIRECTSOUND8 iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundImpl *This = (IDirectSoundImpl *)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);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
if (!ref) {
|
2006-01-06 12:35:20 +01:00
|
|
|
if (This->device)
|
|
|
|
DirectSoundDevice_Release(This->device);
|
2004-07-04 02:13:44 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
2005-02-11 12:49:05 +01:00
|
|
|
TRACE("(%p) released\n", This);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSoundImpl_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 * ppDS)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl* pDS;
|
|
|
|
TRACE("(%p)\n",ppDS);
|
|
|
|
|
|
|
|
/* Allocate memory */
|
|
|
|
pDS = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundImpl));
|
|
|
|
if (pDS == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppDS = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDS->ref = 0;
|
|
|
|
pDS->device = NULL;
|
|
|
|
|
|
|
|
*ppDS = (LPDIRECTSOUND8)pDS;
|
|
|
|
|
|
|
|
return DS_OK;
|
2004-08-25 04:09:00 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound_IUnknown
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSound_IUnknown_QueryInterface(
|
|
|
|
LPUNKNOWN iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
2004-08-25 04:09:00 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return DSOUND_QueryInterface(This->pds, riid, ppobj);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound_IUnknown_AddRef(
|
|
|
|
LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound_IUnknown_Release(
|
|
|
|
LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (!ref) {
|
2007-11-11 16:00:41 +01:00
|
|
|
((IDirectSoundImpl*)This->pds)->pUnknown = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_Release(This->pds);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
2004-07-19 22:06:22 +02:00
|
|
|
}
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static const IUnknownVtbl DirectSound_Unknown_Vtbl =
|
|
|
|
{
|
|
|
|
IDirectSound_IUnknown_QueryInterface,
|
|
|
|
IDirectSound_IUnknown_AddRef,
|
|
|
|
IDirectSound_IUnknown_Release
|
|
|
|
};
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSound_IUnknown_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pds,
|
|
|
|
LPUNKNOWN * ppunk)
|
|
|
|
{
|
|
|
|
IDirectSound_IUnknown * pdsunk;
|
|
|
|
TRACE("(%p,%p)\n",pds,ppunk);
|
|
|
|
|
|
|
|
if (ppunk == NULL) {
|
|
|
|
ERR("invalid parameter: ppunk == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pds == NULL) {
|
|
|
|
ERR("invalid parameter: pds == NULL\n");
|
|
|
|
*ppunk = NULL;
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsunk = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsunk));
|
|
|
|
if (pdsunk == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppunk = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsunk->lpVtbl = &DirectSound_Unknown_Vtbl;
|
|
|
|
pdsunk->ref = 0;
|
|
|
|
pdsunk->pds = pds;
|
2004-08-25 04:09:00 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_AddRef(pds);
|
|
|
|
*ppunk = (LPUNKNOWN)pdsunk;
|
2004-08-25 04:09:00 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return DS_OK;
|
|
|
|
}
|
2004-08-25 04:09:00 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound_IDirectSound
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_QueryInterface(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return DSOUND_QueryInterface(This->pds, riid, ppobj);
|
|
|
|
}
|
2004-08-25 04:09:00 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound_IDirectSound_AddRef(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2004-08-25 04:09:00 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound_IDirectSound_Release(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (!ref) {
|
2007-11-11 16:00:41 +01:00
|
|
|
((IDirectSoundImpl*)This->pds)->pDS = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_Release(This->pds);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_CreateSoundBuffer(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPCDSBUFFERDESC dsbd,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb,
|
|
|
|
LPUNKNOWN lpunk)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
|
|
|
|
return DirectSoundDevice_CreateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,dsbd,ppdsb,lpunk,FALSE);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_GetCaps(
|
|
|
|
LPDIRECTSOUND iface,
|
2004-07-04 02:13:44 +02:00
|
|
|
LPDSCAPS lpDSCaps)
|
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
2004-07-04 02:13:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,lpDSCaps);
|
2006-01-17 16:10:15 +01:00
|
|
|
return DirectSoundDevice_GetCaps(((IDirectSoundImpl *)This->pds)->device, lpDSCaps);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_DuplicateSoundBuffer(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPDIRECTSOUNDBUFFER psb,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
|
|
|
|
return DirectSoundDevice_DuplicateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,psb,ppdsb);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_SetCooperativeLevel(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD level)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
|
|
|
|
return DirectSoundDevice_SetCooperativeLevel(((IDirectSoundImpl *)This->pds)->device, hwnd, level);
|
|
|
|
}
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_Compact(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return DirectSoundDevice_Compact(((IDirectSoundImpl *)This->pds)->device);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_GetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPDWORD lpdwSpeakerConfig)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
|
|
|
|
return DirectSoundDevice_GetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,lpdwSpeakerConfig);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_SetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
DWORD config)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,0x%08x)\n",This,config);
|
2006-01-17 16:10:15 +01:00
|
|
|
return DirectSoundDevice_SetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,config);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound_IDirectSound_Initialize(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPCGUID lpcGuid)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
|
|
|
|
TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
|
|
|
|
return DirectSoundDevice_Initialize(&((IDirectSoundImpl *)This->pds)->device,lpcGuid);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static const IDirectSoundVtbl DirectSound_DirectSound_Vtbl =
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound_QueryInterface,
|
|
|
|
IDirectSound_IDirectSound_AddRef,
|
|
|
|
IDirectSound_IDirectSound_Release,
|
|
|
|
IDirectSound_IDirectSound_CreateSoundBuffer,
|
|
|
|
IDirectSound_IDirectSound_GetCaps,
|
|
|
|
IDirectSound_IDirectSound_DuplicateSoundBuffer,
|
|
|
|
IDirectSound_IDirectSound_SetCooperativeLevel,
|
|
|
|
IDirectSound_IDirectSound_Compact,
|
|
|
|
IDirectSound_IDirectSound_GetSpeakerConfig,
|
|
|
|
IDirectSound_IDirectSound_SetSpeakerConfig,
|
|
|
|
IDirectSound_IDirectSound_Initialize
|
|
|
|
};
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSound_IDirectSound_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pds,
|
|
|
|
LPDIRECTSOUND * ppds)
|
|
|
|
{
|
|
|
|
IDirectSound_IDirectSound * pdsds;
|
|
|
|
TRACE("(%p,%p)\n",pds,ppds);
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (ppds == NULL) {
|
|
|
|
ERR("invalid parameter: ppds == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pds == NULL) {
|
|
|
|
ERR("invalid parameter: pds == NULL\n");
|
|
|
|
*ppds = NULL;
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsds));
|
|
|
|
if (pdsds == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppds = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsds->lpVtbl = &DirectSound_DirectSound_Vtbl;
|
|
|
|
pdsds->ref = 0;
|
|
|
|
pdsds->pds = pds;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_AddRef(pds);
|
|
|
|
*ppds = (LPDIRECTSOUND)pdsds;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return DS_OK;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound8_IUnknown
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSound8_IUnknown_QueryInterface(
|
|
|
|
LPUNKNOWN iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return DSOUND_QueryInterface8(This->pds, riid, ppobj);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IUnknown_AddRef(
|
|
|
|
LPUNKNOWN iface)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2004-07-30 20:42:23 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IUnknown_Release(
|
|
|
|
LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (!ref) {
|
2007-11-11 16:00:41 +01:00
|
|
|
((IDirectSoundImpl*)This->pds)->pUnknown = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_Release(This->pds);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
2004-07-30 20:42:23 +02:00
|
|
|
}
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static const IUnknownVtbl DirectSound8_Unknown_Vtbl =
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IUnknown_QueryInterface,
|
|
|
|
IDirectSound8_IUnknown_AddRef,
|
|
|
|
IDirectSound8_IUnknown_Release
|
|
|
|
};
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSound8_IUnknown_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pds,
|
|
|
|
LPUNKNOWN * ppunk)
|
|
|
|
{
|
|
|
|
IDirectSound8_IUnknown * pdsunk;
|
|
|
|
TRACE("(%p,%p)\n",pds,ppunk);
|
|
|
|
|
|
|
|
if (ppunk == NULL) {
|
|
|
|
ERR("invalid parameter: ppunk == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2004-07-19 22:06:22 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pds == NULL) {
|
|
|
|
ERR("invalid parameter: pds == NULL\n");
|
|
|
|
*ppunk = NULL;
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsunk = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsunk));
|
|
|
|
if (pdsunk == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppunk = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsunk->lpVtbl = &DirectSound8_Unknown_Vtbl;
|
|
|
|
pdsunk->ref = 0;
|
|
|
|
pdsunk->pds = pds;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_AddRef(pds);
|
|
|
|
*ppunk = (LPUNKNOWN)pdsunk;
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2004-07-04 02:13:44 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound8_IDirectSound
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_QueryInterface(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return DSOUND_QueryInterface8(This->pds, riid, ppobj);
|
|
|
|
}
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound_AddRef(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound_Release(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (!ref) {
|
2007-11-11 16:00:41 +01:00
|
|
|
((IDirectSoundImpl*)This->pds)->pDS = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_Release(This->pds);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
2005-05-31 11:31:37 +02:00
|
|
|
}
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_CreateSoundBuffer(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPCDSBUFFERDESC dsbd,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb,
|
|
|
|
LPUNKNOWN lpunk)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
|
|
|
|
return DirectSoundDevice_CreateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,dsbd,ppdsb,lpunk,TRUE);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_GetCaps(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPDSCAPS lpDSCaps)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p)\n",This,lpDSCaps);
|
|
|
|
return DirectSoundDevice_GetCaps(((IDirectSoundImpl *)This->pds)->device, lpDSCaps);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_DuplicateSoundBuffer(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPDIRECTSOUNDBUFFER psb,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
|
|
|
|
return DirectSoundDevice_DuplicateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,psb,ppdsb);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_SetCooperativeLevel(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD level)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
|
|
|
|
return DirectSoundDevice_SetCooperativeLevel(((IDirectSoundImpl *)This->pds)->device, hwnd, level);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_Compact(
|
|
|
|
LPDIRECTSOUND iface)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return DirectSoundDevice_Compact(((IDirectSoundImpl *)This->pds)->device);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_GetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPDWORD lpdwSpeakerConfig)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
|
|
|
|
return DirectSoundDevice_GetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,lpdwSpeakerConfig);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_SetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
DWORD config)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,0x%08x)\n",This,config);
|
2006-01-17 16:10:15 +01:00
|
|
|
return DirectSoundDevice_SetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,config);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound_Initialize(
|
|
|
|
LPDIRECTSOUND iface,
|
|
|
|
LPCGUID lpcGuid)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
|
|
|
|
return DirectSoundDevice_Initialize(&((IDirectSoundImpl *)This->pds)->device,lpcGuid);
|
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static const IDirectSoundVtbl DirectSound8_DirectSound_Vtbl =
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound_QueryInterface,
|
|
|
|
IDirectSound8_IDirectSound_AddRef,
|
|
|
|
IDirectSound8_IDirectSound_Release,
|
|
|
|
IDirectSound8_IDirectSound_CreateSoundBuffer,
|
|
|
|
IDirectSound8_IDirectSound_GetCaps,
|
|
|
|
IDirectSound8_IDirectSound_DuplicateSoundBuffer,
|
|
|
|
IDirectSound8_IDirectSound_SetCooperativeLevel,
|
|
|
|
IDirectSound8_IDirectSound_Compact,
|
|
|
|
IDirectSound8_IDirectSound_GetSpeakerConfig,
|
|
|
|
IDirectSound8_IDirectSound_SetSpeakerConfig,
|
|
|
|
IDirectSound8_IDirectSound_Initialize
|
|
|
|
};
|
2005-05-06 21:33:32 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSound8_IDirectSound_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pds,
|
|
|
|
LPDIRECTSOUND * ppds)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound * pdsds;
|
|
|
|
TRACE("(%p,%p)\n",pds,ppds);
|
2005-05-06 21:33:32 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (ppds == NULL) {
|
|
|
|
ERR("invalid parameter: ppds == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pds == NULL) {
|
|
|
|
ERR("invalid parameter: pds == NULL\n");
|
|
|
|
*ppds = NULL;
|
|
|
|
return DSERR_INVALIDPARAM;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsds));
|
|
|
|
if (pdsds == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppds = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsds->lpVtbl = &DirectSound8_DirectSound_Vtbl;
|
|
|
|
pdsds->ref = 0;
|
|
|
|
pdsds->pds = pds;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_AddRef(pds);
|
|
|
|
*ppds = (LPDIRECTSOUND)pdsds;
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2004-07-04 02:13:44 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound8_IDirectSound8
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_QueryInterface(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppobj)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return DSOUND_QueryInterface8(This->pds, riid, ppobj);
|
2005-05-31 11:31:37 +02:00
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound8_AddRef(
|
|
|
|
LPDIRECTSOUND8 iface)
|
2005-10-10 12:29:13 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2005-10-10 12:29:13 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static ULONG WINAPI IDirectSound8_IDirectSound8_Release(
|
|
|
|
LPDIRECTSOUND8 iface)
|
2005-05-31 11:31:37 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2005-10-10 12:29:13 +02:00
|
|
|
if (!ref) {
|
2007-11-11 16:00:41 +01:00
|
|
|
((IDirectSoundImpl*)This->pds)->pDS8 = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSoundImpl_Release(This->pds);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2005-10-10 12:29:13 +02:00
|
|
|
return ref;
|
2005-05-31 11:31:37 +02:00
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_CreateSoundBuffer(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPCDSBUFFERDESC dsbd,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb,
|
|
|
|
LPUNKNOWN lpunk)
|
2005-05-31 11:31:37 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
|
|
|
|
return DirectSoundDevice_CreateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,dsbd,ppdsb,lpunk,TRUE);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_GetCaps(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPDSCAPS lpDSCaps)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
|
|
|
|
TRACE("(%p,%p)\n",This,lpDSCaps);
|
|
|
|
return DirectSoundDevice_GetCaps(((IDirectSoundImpl *)This->pds)->device, lpDSCaps);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_DuplicateSoundBuffer(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPDIRECTSOUNDBUFFER psb,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
|
|
|
|
return DirectSoundDevice_DuplicateSoundBuffer(((IDirectSoundImpl *)This->pds)->device,psb,ppdsb);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2005-05-31 11:31:37 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_SetCooperativeLevel(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD level)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
|
|
|
|
return DirectSoundDevice_SetCooperativeLevel(((IDirectSoundImpl *)This->pds)->device, hwnd, level);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_Compact(
|
|
|
|
LPDIRECTSOUND8 iface)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return DirectSoundDevice_Compact(((IDirectSoundImpl *)This->pds)->device);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_GetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPDWORD lpdwSpeakerConfig)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
|
|
|
|
return DirectSoundDevice_GetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,lpdwSpeakerConfig);
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_SetSpeakerConfig(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
DWORD config)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,0x%08x)\n",This,config);
|
2006-01-17 16:10:15 +01:00
|
|
|
return DirectSoundDevice_SetSpeakerConfig(((IDirectSoundImpl *)This->pds)->device,config);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_Initialize(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPCGUID lpcGuid)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
|
|
|
|
return DirectSoundDevice_Initialize(&((IDirectSoundImpl *)This->pds)->device,lpcGuid);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static HRESULT WINAPI IDirectSound8_IDirectSound8_VerifyCertification(
|
|
|
|
LPDIRECTSOUND8 iface,
|
|
|
|
LPDWORD pdwCertified)
|
|
|
|
{
|
|
|
|
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
|
|
|
|
TRACE("(%p, %p)\n", This, pdwCertified);
|
|
|
|
return DirectSoundDevice_VerifyCertification(((IDirectSoundImpl *)This->pds)->device,pdwCertified);
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
static const IDirectSound8Vtbl DirectSound8_DirectSound8_Vtbl =
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8_QueryInterface,
|
|
|
|
IDirectSound8_IDirectSound8_AddRef,
|
|
|
|
IDirectSound8_IDirectSound8_Release,
|
|
|
|
IDirectSound8_IDirectSound8_CreateSoundBuffer,
|
|
|
|
IDirectSound8_IDirectSound8_GetCaps,
|
|
|
|
IDirectSound8_IDirectSound8_DuplicateSoundBuffer,
|
|
|
|
IDirectSound8_IDirectSound8_SetCooperativeLevel,
|
|
|
|
IDirectSound8_IDirectSound8_Compact,
|
|
|
|
IDirectSound8_IDirectSound8_GetSpeakerConfig,
|
|
|
|
IDirectSound8_IDirectSound8_SetSpeakerConfig,
|
|
|
|
IDirectSound8_IDirectSound8_Initialize,
|
|
|
|
IDirectSound8_IDirectSound8_VerifyCertification
|
2004-07-04 02:13:44 +02:00
|
|
|
};
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSound8_IDirectSound8_Create(
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pds,
|
|
|
|
LPDIRECTSOUND8 * ppds)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
IDirectSound8_IDirectSound8 * pdsds;
|
2004-07-04 02:13:44 +02:00
|
|
|
TRACE("(%p,%p)\n",pds,ppds);
|
|
|
|
|
|
|
|
if (ppds == NULL) {
|
2004-07-09 21:25:39 +02:00
|
|
|
ERR("invalid parameter: ppds == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pds == NULL) {
|
2004-07-09 21:25:39 +02:00
|
|
|
ERR("invalid parameter: pds == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
*ppds = NULL;
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdsds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsds));
|
|
|
|
if (pdsds == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppds = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
pdsds->lpVtbl = &DirectSound8_DirectSound8_Vtbl;
|
2004-07-04 02:13:44 +02:00
|
|
|
pdsds->ref = 0;
|
|
|
|
pdsds->pds = pds;
|
|
|
|
|
|
|
|
IDirectSoundImpl_AddRef(pds);
|
2006-01-17 16:10:15 +01:00
|
|
|
*ppds = (LPDIRECTSOUND8)pdsds;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DSOUND_Create(
|
2006-08-18 07:13:31 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPDIRECTSOUND *ppDS)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pDS;
|
|
|
|
HRESULT hr;
|
2006-08-18 07:13:31 +02:00
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
|
|
|
|
|
|
|
|
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
|
|
|
!IsEqualIID(riid, &IID_IDirectSound)) {
|
|
|
|
*ppDS = 0;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* Get dsound configuration */
|
|
|
|
setup_dsound_options();
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
hr = IDirectSoundImpl_Create(&pDS);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSound_IDirectSound_Create(pDS, ppDS);
|
|
|
|
if (*ppDS)
|
|
|
|
IDirectSound_IDirectSound_AddRef(*ppDS);
|
|
|
|
else {
|
|
|
|
WARN("IDirectSound_IDirectSound_Create failed\n");
|
|
|
|
IDirectSound8_Release(pDS);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WARN("IDirectSoundImpl_Create failed\n");
|
|
|
|
*ppDS = 0;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2006-01-17 16:10:15 +01:00
|
|
|
|
|
|
|
return hr;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundCreate (DSOUND.1)
|
|
|
|
*
|
|
|
|
* Creates and initializes a DirectSound interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpcGUID [I] Address of the GUID that identifies the sound device.
|
|
|
|
* ppDS [O] Address of a variable to receive the interface pointer.
|
|
|
|
* pUnkOuter [I] Must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
|
|
|
|
* DSERR_NODRIVER, DSERR_OUTOFMEMORY
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DirectSoundCreate(
|
|
|
|
LPCGUID lpcGUID,
|
|
|
|
LPDIRECTSOUND *ppDS,
|
|
|
|
IUnknown *pUnkOuter)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hr;
|
|
|
|
LPDIRECTSOUND pDS;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (ppDS == NULL) {
|
|
|
|
WARN("invalid parameter: ppDS == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pUnkOuter != NULL) {
|
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
|
|
|
*ppDS = 0;
|
|
|
|
return DSERR_INVALIDPARAM;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-08-18 07:13:31 +02:00
|
|
|
hr = DSOUND_Create(&IID_IDirectSound, &pDS);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSound_Initialize(pDS, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
if (hr != DSERR_ALREADYINITIALIZED) {
|
|
|
|
IDirectSound_Release(pDS);
|
|
|
|
pDS = 0;
|
|
|
|
} else
|
|
|
|
hr = DS_OK;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
*ppDS = pDS;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return hr;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DSOUND_Create8(
|
2006-08-18 07:13:31 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPDIRECTSOUND8 *ppDS)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
LPDIRECTSOUND8 pDS;
|
|
|
|
HRESULT hr;
|
2006-08-18 07:13:31 +02:00
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
|
|
|
|
|
|
|
|
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
2007-05-23 13:38:30 +02:00
|
|
|
!IsEqualIID(riid, &IID_IDirectSound) &&
|
2006-08-18 07:13:31 +02:00
|
|
|
!IsEqualIID(riid, &IID_IDirectSound8)) {
|
|
|
|
*ppDS = 0;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* Get dsound configuration */
|
|
|
|
setup_dsound_options();
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
hr = IDirectSoundImpl_Create(&pDS);
|
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSound8_IDirectSound8_Create(pDS, ppDS);
|
|
|
|
if (*ppDS)
|
|
|
|
IDirectSound8_IDirectSound8_AddRef(*ppDS);
|
|
|
|
else {
|
|
|
|
WARN("IDirectSound8_IDirectSound8_Create failed\n");
|
|
|
|
IDirectSound8_Release(pDS);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WARN("IDirectSoundImpl_Create failed\n");
|
|
|
|
*ppDS = 0;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return hr;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* DirectSoundCreate8 (DSOUND.11)
|
|
|
|
*
|
|
|
|
* Creates and initializes a DirectSound8 interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpcGUID [I] Address of the GUID that identifies the sound device.
|
|
|
|
* ppDS [O] Address of a variable to receive the interface pointer.
|
|
|
|
* pUnkOuter [I] Must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: DS_OK
|
|
|
|
* Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
|
|
|
|
* DSERR_NODRIVER, DSERR_OUTOFMEMORY
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DirectSoundCreate8(
|
|
|
|
LPCGUID lpcGUID,
|
|
|
|
LPDIRECTSOUND8 *ppDS,
|
|
|
|
IUnknown *pUnkOuter)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hr;
|
|
|
|
LPDIRECTSOUND8 pDS;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (ppDS == NULL) {
|
|
|
|
WARN("invalid parameter: ppDS == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (pUnkOuter != NULL) {
|
|
|
|
WARN("invalid parameter: pUnkOuter != NULL\n");
|
|
|
|
*ppDS = 0;
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-08-18 07:13:31 +02:00
|
|
|
hr = DSOUND_Create8(&IID_IDirectSound8, &pDS);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (hr == DS_OK) {
|
|
|
|
hr = IDirectSound8_Initialize(pDS, lpcGUID);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
if (hr != DSERR_ALREADYINITIALIZED) {
|
|
|
|
IDirectSound8_Release(pDS);
|
|
|
|
pDS = 0;
|
|
|
|
} else
|
|
|
|
hr = DS_OK;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
*ppDS = pDS;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return hr;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2006-01-17 16:10:15 +01:00
|
|
|
* DirectSoundDevice
|
2004-07-04 02:13:44 +02:00
|
|
|
*/
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
DirectSoundDevice * device;
|
|
|
|
TRACE("(%p)\n", ppDevice);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* Allocate memory */
|
|
|
|
device = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DirectSoundDevice));
|
|
|
|
if (device == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
device->ref = 1;
|
|
|
|
device->priolevel = DSSCL_NORMAL;
|
|
|
|
device->state = STATE_STOPPED;
|
|
|
|
device->speaker_config = DSSPEAKER_STEREO | (DSSPEAKER_GEOMETRY_NARROW << 16);
|
|
|
|
|
|
|
|
/* 3D listener initial parameters */
|
|
|
|
device->ds3dl.dwSize = sizeof(DS3DLISTENER);
|
|
|
|
device->ds3dl.vPosition.x = 0.0;
|
|
|
|
device->ds3dl.vPosition.y = 0.0;
|
|
|
|
device->ds3dl.vPosition.z = 0.0;
|
|
|
|
device->ds3dl.vVelocity.x = 0.0;
|
|
|
|
device->ds3dl.vVelocity.y = 0.0;
|
|
|
|
device->ds3dl.vVelocity.z = 0.0;
|
|
|
|
device->ds3dl.vOrientFront.x = 0.0;
|
|
|
|
device->ds3dl.vOrientFront.y = 0.0;
|
|
|
|
device->ds3dl.vOrientFront.z = 1.0;
|
|
|
|
device->ds3dl.vOrientTop.x = 0.0;
|
|
|
|
device->ds3dl.vOrientTop.y = 1.0;
|
|
|
|
device->ds3dl.vOrientTop.z = 0.0;
|
|
|
|
device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
|
|
|
|
device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
|
|
|
|
device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
|
|
|
|
|
2007-10-11 22:08:17 +02:00
|
|
|
device->prebuf = ds_snd_queue_max;
|
|
|
|
device->guid = GUID_NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
|
|
|
|
/* Set default wave format (may need it for waveOutOpen) */
|
|
|
|
device->pwfx = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEFORMATEX));
|
|
|
|
if (device->pwfx == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
HeapFree(GetProcessHeap(),0,device);
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* We rely on the sound driver to return the actual sound format of
|
|
|
|
* the device if it does not support 22050x8x2 and is given the
|
|
|
|
* WAVE_DIRECTSOUND flag.
|
|
|
|
*/
|
|
|
|
device->pwfx->wFormatTag = WAVE_FORMAT_PCM;
|
2006-04-06 02:48:44 +02:00
|
|
|
device->pwfx->nSamplesPerSec = ds_default_sample_rate;
|
|
|
|
device->pwfx->wBitsPerSample = ds_default_bits_per_sample;
|
2006-01-17 16:10:15 +01:00
|
|
|
device->pwfx->nChannels = 2;
|
|
|
|
device->pwfx->nBlockAlign = device->pwfx->wBitsPerSample * device->pwfx->nChannels / 8;
|
|
|
|
device->pwfx->nAvgBytesPerSec = device->pwfx->nSamplesPerSec * device->pwfx->nBlockAlign;
|
|
|
|
device->pwfx->cbSize = 0;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
InitializeCriticalSection(&(device->mixlock));
|
2007-03-10 22:08:28 +01:00
|
|
|
device->mixlock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DirectSoundDevice.mixlock");
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
RtlInitializeResource(&(device->buffer_list_lock));
|
|
|
|
|
|
|
|
*ppDevice = device;
|
|
|
|
|
|
|
|
return DS_OK;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static ULONG DirectSoundDevice_AddRef(DirectSoundDevice * device)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&(device->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", device, ref - 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
return ref;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref = InterlockedDecrement(&(device->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %u\n", device, ref + 1);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (!ref) {
|
|
|
|
int i;
|
|
|
|
timeKillEvent(device->timerID);
|
|
|
|
timeEndPeriod(DS_TIME_RES);
|
|
|
|
|
2007-06-13 14:12:07 +02:00
|
|
|
/* The kill event should have allowed the timer process to expire
|
2006-01-17 16:10:15 +01:00
|
|
|
* but try to grab the lock just in case. Can't hold lock because
|
|
|
|
* IDirectSoundBufferImpl_Destroy also grabs the lock */
|
|
|
|
RtlAcquireResourceShared(&(device->buffer_list_lock), TRUE);
|
|
|
|
RtlReleaseResource(&(device->buffer_list_lock));
|
|
|
|
|
|
|
|
/* It is allowed to release this object even when buffers are playing */
|
|
|
|
if (device->buffers) {
|
|
|
|
WARN("%d secondary buffers not released\n", device->nrofbuffers);
|
|
|
|
for( i=0;i<device->nrofbuffers;i++)
|
|
|
|
IDirectSoundBufferImpl_Destroy(device->buffers[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device->primary) {
|
|
|
|
WARN("primary buffer not released\n");
|
|
|
|
IDirectSoundBuffer8_Release((LPDIRECTSOUNDBUFFER8)device->primary);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DSOUND_PrimaryDestroy(device);
|
|
|
|
if (hr != DS_OK)
|
|
|
|
WARN("DSOUND_PrimaryDestroy failed\n");
|
|
|
|
|
|
|
|
if (device->driver)
|
|
|
|
IDsDriver_Close(device->driver);
|
|
|
|
|
|
|
|
if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
|
|
|
|
waveOutClose(device->hwo);
|
|
|
|
|
|
|
|
if (device->driver)
|
|
|
|
IDsDriver_Release(device->driver);
|
|
|
|
|
|
|
|
DSOUND_renderer[device->drvdesc.dnDevNode] = NULL;
|
|
|
|
|
2007-11-07 20:32:22 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, device->tmp_buffer);
|
|
|
|
HeapFree(GetProcessHeap(), 0, device->mix_buffer);
|
2008-06-20 14:49:15 +02:00
|
|
|
if (device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)
|
|
|
|
HeapFree(GetProcessHeap(), 0, device->buffer);
|
2006-01-17 16:10:15 +01:00
|
|
|
RtlDeleteResource(&device->buffer_list_lock);
|
|
|
|
device->mixlock.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&device->mixlock);
|
|
|
|
HeapFree(GetProcessHeap(),0,device);
|
|
|
|
TRACE("(%p) released\n", device);
|
|
|
|
}
|
|
|
|
return ref;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_GetCaps(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
LPDSCAPS lpDSCaps)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%p,%p)\n",device,lpDSCaps);
|
|
|
|
|
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDSCaps == NULL) {
|
|
|
|
WARN("invalid parameter: lpDSCaps = NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if there is enough room */
|
|
|
|
if (lpDSCaps->dwSize < sizeof(*lpDSCaps)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: lpDSCaps->dwSize = %d\n", lpDSCaps->dwSize);
|
2006-01-17 16:10:15 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpDSCaps->dwFlags = device->drvcaps.dwFlags;
|
|
|
|
if (TRACE_ON(dsound)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(flags=0x%08x:\n",lpDSCaps->dwFlags);
|
2006-01-17 16:10:15 +01:00
|
|
|
_dump_DSCAPS(lpDSCaps->dwFlags);
|
2007-12-12 08:56:13 +01:00
|
|
|
TRACE(")\n");
|
2006-01-17 16:10:15 +01:00
|
|
|
}
|
|
|
|
lpDSCaps->dwMinSecondarySampleRate = device->drvcaps.dwMinSecondarySampleRate;
|
|
|
|
lpDSCaps->dwMaxSecondarySampleRate = device->drvcaps.dwMaxSecondarySampleRate;
|
|
|
|
lpDSCaps->dwPrimaryBuffers = device->drvcaps.dwPrimaryBuffers;
|
|
|
|
lpDSCaps->dwMaxHwMixingAllBuffers = device->drvcaps.dwMaxHwMixingAllBuffers;
|
|
|
|
lpDSCaps->dwMaxHwMixingStaticBuffers = device->drvcaps.dwMaxHwMixingStaticBuffers;
|
|
|
|
lpDSCaps->dwMaxHwMixingStreamingBuffers = device->drvcaps.dwMaxHwMixingStreamingBuffers;
|
|
|
|
lpDSCaps->dwFreeHwMixingAllBuffers = device->drvcaps.dwFreeHwMixingAllBuffers;
|
|
|
|
lpDSCaps->dwFreeHwMixingStaticBuffers = device->drvcaps.dwFreeHwMixingStaticBuffers;
|
|
|
|
lpDSCaps->dwFreeHwMixingStreamingBuffers = device->drvcaps.dwFreeHwMixingStreamingBuffers;
|
|
|
|
lpDSCaps->dwMaxHw3DAllBuffers = device->drvcaps.dwMaxHw3DAllBuffers;
|
|
|
|
lpDSCaps->dwMaxHw3DStaticBuffers = device->drvcaps.dwMaxHw3DStaticBuffers;
|
|
|
|
lpDSCaps->dwMaxHw3DStreamingBuffers = device->drvcaps.dwMaxHw3DStreamingBuffers;
|
|
|
|
lpDSCaps->dwFreeHw3DAllBuffers = device->drvcaps.dwFreeHw3DAllBuffers;
|
|
|
|
lpDSCaps->dwFreeHw3DStaticBuffers = device->drvcaps.dwFreeHw3DStaticBuffers;
|
|
|
|
lpDSCaps->dwFreeHw3DStreamingBuffers = device->drvcaps.dwFreeHw3DStreamingBuffers;
|
|
|
|
lpDSCaps->dwTotalHwMemBytes = device->drvcaps.dwTotalHwMemBytes;
|
|
|
|
lpDSCaps->dwFreeHwMemBytes = device->drvcaps.dwFreeHwMemBytes;
|
|
|
|
lpDSCaps->dwMaxContigFreeHwMemBytes = device->drvcaps.dwMaxContigFreeHwMemBytes;
|
|
|
|
|
|
|
|
/* driver doesn't have these */
|
|
|
|
lpDSCaps->dwUnlockTransferRateHwBuffers = 4096; /* But we have none... */
|
|
|
|
lpDSCaps->dwPlayCpuOverheadSwBuffers = 1; /* 1% */
|
|
|
|
|
|
|
|
return DS_OK;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcGUID)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hr = DS_OK;
|
|
|
|
unsigned wod, wodn;
|
|
|
|
BOOLEAN found = FALSE;
|
|
|
|
GUID devGUID;
|
|
|
|
DirectSoundDevice * device = *ppDevice;
|
|
|
|
TRACE("(%p,%s)\n",ppDevice,debugstr_guid(lpcGUID));
|
|
|
|
|
|
|
|
if (*ppDevice != NULL) {
|
|
|
|
WARN("already initialized\n");
|
|
|
|
return DSERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default device? */
|
|
|
|
if (!lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL))
|
|
|
|
lpcGUID = &DSDEVID_DefaultPlayback;
|
|
|
|
|
|
|
|
if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) {
|
|
|
|
WARN("invalid parameter: lpcGUID\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enumerate WINMM audio devices and find the one we want */
|
|
|
|
wodn = waveOutGetNumDevs();
|
|
|
|
if (!wodn) {
|
|
|
|
WARN("no driver\n");
|
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (wod=0; wod<wodn; wod++) {
|
|
|
|
if (IsEqualGUID( &devGUID, &DSOUND_renderer_guids[wod])) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found == FALSE) {
|
|
|
|
WARN("No device found matching given ID!\n");
|
|
|
|
return DSERR_NODRIVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DSOUND_renderer[wod]) {
|
|
|
|
if (IsEqualGUID(&devGUID, &DSOUND_renderer[wod]->guid)) {
|
|
|
|
device = DSOUND_renderer[wod];
|
|
|
|
DirectSoundDevice_AddRef(device);
|
|
|
|
*ppDevice = device;
|
|
|
|
return DS_OK;
|
|
|
|
} else {
|
|
|
|
ERR("device GUID doesn't match\n");
|
|
|
|
hr = DSERR_GENERIC;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hr = DirectSoundDevice_Create(&device);
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
WARN("DirectSoundDevice_Create failed\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppDevice = device;
|
|
|
|
device->guid = devGUID;
|
2007-08-03 22:15:50 +02:00
|
|
|
device->driver = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
|
|
|
|
device->drvdesc.dnDevNode = wod;
|
2007-08-27 17:07:14 +02:00
|
|
|
hr = DSOUND_ReopenDevice(device, FALSE);
|
|
|
|
if (FAILED(hr))
|
2006-01-17 16:10:15 +01:00
|
|
|
{
|
2007-08-27 17:07:14 +02:00
|
|
|
WARN("DSOUND_ReopenDevice failed: %08x\n", hr);
|
|
|
|
return hr;
|
2006-01-17 16:10:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device->driver) {
|
|
|
|
/* the driver is now open, so it's now allowed to call GetCaps */
|
|
|
|
hr = IDsDriver_GetCaps(device->driver,&(device->drvcaps));
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
WARN("IDsDriver_GetCaps failed\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WAVEOUTCAPSA woc;
|
|
|
|
hr = mmErr(waveOutGetDevCapsA(device->drvdesc.dnDevNode, &woc, sizeof(woc)));
|
|
|
|
if (hr != DS_OK) {
|
|
|
|
WARN("waveOutGetDevCaps failed\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ZeroMemory(&device->drvcaps, sizeof(device->drvcaps));
|
|
|
|
if ((woc.dwFormats & WAVE_FORMAT_1M08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_2M08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_4M08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_48M08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_96M08)) {
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARY8BIT;
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARYMONO;
|
|
|
|
}
|
|
|
|
if ((woc.dwFormats & WAVE_FORMAT_1M16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_2M16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_4M16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_48M16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_96M16)) {
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARY16BIT;
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARYMONO;
|
|
|
|
}
|
|
|
|
if ((woc.dwFormats & WAVE_FORMAT_1S08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_2S08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_4S08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_48S08) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_96S08)) {
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARY8BIT;
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARYSTEREO;
|
|
|
|
}
|
|
|
|
if ((woc.dwFormats & WAVE_FORMAT_1S16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_2S16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_4S16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_48S16) ||
|
|
|
|
(woc.dwFormats & WAVE_FORMAT_96S16)) {
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARY16BIT;
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_PRIMARYSTEREO;
|
|
|
|
}
|
|
|
|
if (ds_emuldriver)
|
|
|
|
device->drvcaps.dwFlags |= DSCAPS_EMULDRIVER;
|
|
|
|
device->drvcaps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
|
|
|
|
device->drvcaps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
|
|
|
|
device->drvcaps.dwPrimaryBuffers = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DSOUND_PrimaryCreate(device);
|
|
|
|
if (hr == DS_OK) {
|
2007-08-04 10:41:59 +02:00
|
|
|
UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id;
|
|
|
|
TIMECAPS time;
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
DSOUND_renderer[device->drvdesc.dnDevNode] = device;
|
2007-08-04 10:41:59 +02:00
|
|
|
timeGetDevCaps(&time, sizeof(TIMECAPS));
|
|
|
|
TRACE("Minimum timer resolution: %u, max timer: %u\n", time.wPeriodMin, time.wPeriodMax);
|
|
|
|
if (triggertime < time.wPeriodMin)
|
|
|
|
triggertime = time.wPeriodMin;
|
|
|
|
if (res < time.wPeriodMin)
|
|
|
|
res = time.wPeriodMin;
|
|
|
|
if (timeBeginPeriod(res) == TIMERR_NOCANDO)
|
|
|
|
WARN("Could not set minimum resolution, don't expect sound\n");
|
|
|
|
id = timeSetEvent(triggertime, res, DSOUND_timer, (DWORD_PTR)device, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
|
|
|
|
if (!id)
|
|
|
|
{
|
|
|
|
WARN("Timer not created! Retrying without TIME_KILL_SYNCHRONOUS\n");
|
|
|
|
id = timeSetEvent(triggertime, res, DSOUND_timer, (DWORD_PTR)device, TIME_PERIODIC);
|
|
|
|
if (!id) ERR("Could not create timer, sound playback will not occur\n");
|
|
|
|
}
|
|
|
|
DSOUND_renderer[device->drvdesc.dnDevNode]->timerID = id;
|
2006-01-17 16:10:15 +01:00
|
|
|
} else {
|
|
|
|
WARN("DSOUND_PrimaryCreate failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_CreateSoundBuffer(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
LPCDSBUFFERDESC dsbd,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb,
|
|
|
|
LPUNKNOWN lpunk,
|
|
|
|
BOOL from8)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hres = DS_OK;
|
|
|
|
TRACE("(%p,%p,%p,%p)\n",device,dsbd,ppdsb,lpunk);
|
|
|
|
|
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dsbd == NULL) {
|
|
|
|
WARN("invalid parameter: dsbd == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dsbd->dwSize != sizeof(DSBUFFERDESC) &&
|
|
|
|
dsbd->dwSize != sizeof(DSBUFFERDESC1)) {
|
|
|
|
WARN("invalid parameter: dsbd\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppdsb == NULL) {
|
|
|
|
WARN("invalid parameter: ppdsb == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2007-11-05 23:23:11 +01:00
|
|
|
*ppdsb = NULL;
|
2006-01-17 16:10:15 +01:00
|
|
|
|
|
|
|
if (TRACE_ON(dsound)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(structsize=%d)\n",dsbd->dwSize);
|
|
|
|
TRACE("(flags=0x%08x:\n",dsbd->dwFlags);
|
2006-01-17 16:10:15 +01:00
|
|
|
_dump_DSBCAPS(dsbd->dwFlags);
|
2007-12-12 08:56:13 +01:00
|
|
|
TRACE(")\n");
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(bufferbytes=%d)\n",dsbd->dwBufferBytes);
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(lpwfxFormat=%p)\n",dsbd->lpwfxFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) {
|
|
|
|
if (dsbd->lpwfxFormat != NULL) {
|
|
|
|
WARN("invalid parameter: dsbd->lpwfxFormat must be NULL for "
|
|
|
|
"primary buffer\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device->primary) {
|
|
|
|
WARN("Primary Buffer already created\n");
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(device->primary));
|
|
|
|
*ppdsb = (LPDIRECTSOUNDBUFFER)(device->primary);
|
|
|
|
} else {
|
|
|
|
device->dsbd = *dsbd;
|
2007-08-21 21:01:53 +02:00
|
|
|
device->dsbd.dwFlags &= ~(DSBCAPS_LOCHARDWARE | DSBCAPS_LOCSOFTWARE);
|
|
|
|
if (device->hwbuf)
|
|
|
|
device->dsbd.dwFlags |= DSBCAPS_LOCHARDWARE;
|
|
|
|
else device->dsbd.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
2007-12-31 22:38:23 +01:00
|
|
|
hres = PrimaryBufferImpl_Create(device, &(device->primary), &(device->dsbd));
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device->primary) {
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(device->primary));
|
|
|
|
*ppdsb = (LPDIRECTSOUNDBUFFER)(device->primary);
|
|
|
|
} else
|
|
|
|
WARN("PrimaryBufferImpl_Create failed\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
IDirectSoundBufferImpl * dsb;
|
2007-11-05 23:23:11 +01:00
|
|
|
WAVEFORMATEXTENSIBLE *pwfxe;
|
2006-01-17 16:10:15 +01:00
|
|
|
|
|
|
|
if (dsbd->lpwfxFormat == NULL) {
|
|
|
|
WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
|
|
|
|
"secondary buffer\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2007-11-05 23:23:11 +01:00
|
|
|
pwfxe = (WAVEFORMATEXTENSIBLE*)dsbd->lpwfxFormat;
|
|
|
|
|
|
|
|
if (pwfxe->Format.wBitsPerSample != 16 && pwfxe->Format.wBitsPerSample != 8 && pwfxe->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE)
|
|
|
|
{
|
|
|
|
WARN("wBitsPerSample=%d needs a WAVEFORMATEXTENSIBLE\n", dsbd->lpwfxFormat->wBitsPerSample);
|
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
if (pwfxe->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
|
|
|
{
|
|
|
|
if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
|
|
|
|
{
|
2007-12-07 18:49:18 +01:00
|
|
|
WARN("Too small a cbSize %u\n", pwfxe->Format.cbSize);
|
2007-11-05 23:23:11 +01:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pwfxe->Format.cbSize > (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
|
|
|
|
{
|
2007-12-07 18:49:18 +01:00
|
|
|
WARN("Too big a cbSize %u\n", pwfxe->Format.cbSize);
|
2007-11-05 23:23:11 +01:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))
|
|
|
|
{
|
|
|
|
if (!IsEqualGUID(&pwfxe->SubFormat, &GUID_NULL))
|
|
|
|
FIXME("SubFormat %s not supported right now.\n", debugstr_guid(&pwfxe->SubFormat));
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
if (pwfxe->Samples.wValidBitsPerSample > dsbd->lpwfxFormat->wBitsPerSample)
|
|
|
|
{
|
|
|
|
WARN("Samples.wValidBitsPerSample(%d) > Format.wBitsPerSample (%d)\n", pwfxe->Samples.wValidBitsPerSample, pwfxe->Format.wBitsPerSample);
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
if (pwfxe->Samples.wValidBitsPerSample && pwfxe->Samples.wValidBitsPerSample < dsbd->lpwfxFormat->wBitsPerSample)
|
|
|
|
{
|
|
|
|
FIXME("Non-packed formats not supported right now: %d/%d\n", pwfxe->Samples.wValidBitsPerSample, dsbd->lpwfxFormat->wBitsPerSample);
|
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
}
|
2006-01-17 16:10:15 +01:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
|
|
|
|
"bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
|
2006-01-17 16:10:15 +01:00
|
|
|
dsbd->lpwfxFormat->wFormatTag, dsbd->lpwfxFormat->nChannels,
|
|
|
|
dsbd->lpwfxFormat->nSamplesPerSec,
|
|
|
|
dsbd->lpwfxFormat->nAvgBytesPerSec,
|
|
|
|
dsbd->lpwfxFormat->nBlockAlign,
|
|
|
|
dsbd->lpwfxFormat->wBitsPerSample, dsbd->lpwfxFormat->cbSize);
|
|
|
|
|
|
|
|
if (from8 && (dsbd->dwFlags & DSBCAPS_CTRL3D) && (dsbd->lpwfxFormat->nChannels != 1)) {
|
|
|
|
WARN("invalid parameter: 3D buffer format must be mono\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2007-12-31 22:38:23 +01:00
|
|
|
hres = IDirectSoundBufferImpl_Create(device, &dsb, dsbd);
|
2006-01-17 16:10:15 +01:00
|
|
|
if (dsb) {
|
|
|
|
hres = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl**)ppdsb);
|
|
|
|
if (*ppdsb) {
|
|
|
|
dsb->secondary = (SecondaryBufferImpl*)*ppdsb;
|
2007-12-31 22:38:23 +01:00
|
|
|
IDirectSoundBuffer_AddRef(*ppdsb);
|
2006-01-17 16:10:15 +01:00
|
|
|
} else
|
|
|
|
WARN("SecondaryBufferImpl_Create failed\n");
|
|
|
|
} else
|
|
|
|
WARN("IDirectSoundBufferImpl_Create failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_DuplicateSoundBuffer(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
LPDIRECTSOUNDBUFFER psb,
|
|
|
|
LPLPDIRECTSOUNDBUFFER ppdsb)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT hres = DS_OK;
|
|
|
|
IDirectSoundBufferImpl* dsb;
|
|
|
|
TRACE("(%p,%p,%p)\n",device,psb,ppdsb);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (psb == NULL) {
|
|
|
|
WARN("invalid parameter: psb == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (ppdsb == NULL) {
|
|
|
|
WARN("invalid parameter: ppdsb == NULL\n");
|
2004-07-04 02:13:44 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* make sure we have a secondary buffer */
|
|
|
|
if ((PrimaryBufferImpl *)psb == device->primary) {
|
|
|
|
WARN("trying to duplicate primary buffer\n");
|
|
|
|
*ppdsb = NULL;
|
|
|
|
return DSERR_INVALIDCALL;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
/* duplicate the actual buffer implementation */
|
|
|
|
hres = IDirectSoundBufferImpl_Duplicate(device, &dsb,
|
|
|
|
((SecondaryBufferImpl *)psb)->dsb);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (hres == DS_OK) {
|
|
|
|
/* create a new secondary buffer using the new implementation */
|
|
|
|
hres = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl**)ppdsb);
|
|
|
|
if (*ppdsb) {
|
|
|
|
dsb->secondary = (SecondaryBufferImpl*)*ppdsb;
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)*ppdsb);
|
|
|
|
} else {
|
|
|
|
WARN("SecondaryBufferImpl_Create failed\n");
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)dsb);
|
|
|
|
IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER8)dsb);
|
|
|
|
}
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return hres;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_SetCooperativeLevel(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD level)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%p,%p,%s)\n",device,hwnd,dumpCooperativeLevel(level));
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (level==DSSCL_PRIORITY || level==DSSCL_EXCLUSIVE) {
|
|
|
|
WARN("level=%s not fully supported\n",
|
|
|
|
level==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2004-07-09 21:25:39 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
device->priolevel = level;
|
|
|
|
return DS_OK;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_Compact(
|
|
|
|
DirectSoundDevice * device)
|
2004-07-19 22:06:22 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%p)\n", device);
|
2005-05-06 21:33:32 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2007-05-14 20:32:19 +02:00
|
|
|
if (device->priolevel < DSSCL_PRIORITY) {
|
2006-01-17 16:10:15 +01:00
|
|
|
WARN("incorrect priority level\n");
|
|
|
|
return DSERR_PRIOLEVELNEEDED;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return DS_OK;
|
2004-07-19 22:06:22 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_GetSpeakerConfig(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
LPDWORD lpdwSpeakerConfig)
|
2004-07-04 02:13:44 +02:00
|
|
|
{
|
2006-01-17 16:10:15 +01:00
|
|
|
TRACE("(%p, %p)\n", device, lpdwSpeakerConfig);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
|
|
|
}
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (lpdwSpeakerConfig == NULL) {
|
|
|
|
WARN("invalid parameter: lpdwSpeakerConfig == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2004-07-09 21:25:39 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
WARN("not fully functional\n");
|
|
|
|
*lpdwSpeakerConfig = device->speaker_config;
|
|
|
|
return DS_OK;
|
2004-07-04 02:13:44 +02:00
|
|
|
}
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
HRESULT DirectSoundDevice_SetSpeakerConfig(
|
|
|
|
DirectSoundDevice * device,
|
|
|
|
DWORD config)
|
2004-07-19 22:06:22 +02:00
|
|
|
{
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,0x%08x)\n",device,config);
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
device->speaker_config = config;
|
|
|
|
WARN("not fully functional\n");
|
|
|
|
return DS_OK;
|
|
|
|
}
|
2005-05-06 21:33:32 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT DirectSoundDevice_VerifyCertification(
|
2006-01-17 16:10:15 +01:00
|
|
|
DirectSoundDevice * device,
|
|
|
|
LPDWORD pdwCertified)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n",device,pdwCertified);
|
|
|
|
|
|
|
|
if (device == NULL) {
|
|
|
|
WARN("not initialized\n");
|
|
|
|
return DSERR_UNINITIALIZED;
|
2005-05-06 21:33:32 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
if (device->drvcaps.dwFlags & DSCAPS_CERTIFIED)
|
|
|
|
*pdwCertified = DS_CERTIFIED;
|
|
|
|
else
|
|
|
|
*pdwCertified = DS_UNCERTIFIED;
|
2004-07-19 22:06:22 +02:00
|
|
|
|
2006-01-17 16:10:15 +01:00
|
|
|
return DS_OK;
|
2004-07-19 22:06:22 +02:00
|
|
|
}
|
2004-09-07 21:32:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add secondary buffer to buffer list.
|
|
|
|
* Gets exclusive access to buffer for writing.
|
|
|
|
*/
|
2006-01-14 17:06:52 +01:00
|
|
|
HRESULT DirectSoundDevice_AddBuffer(
|
2006-01-06 12:35:20 +01:00
|
|
|
DirectSoundDevice * device,
|
2004-09-07 21:32:21 +02:00
|
|
|
IDirectSoundBufferImpl * pDSB)
|
|
|
|
{
|
|
|
|
IDirectSoundBufferImpl **newbuffers;
|
|
|
|
HRESULT hr = DS_OK;
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("(%p, %p)\n", device, pDSB);
|
2004-09-07 21:32:21 +02:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
|
2004-09-07 21:32:21 +02:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
if (device->buffers)
|
|
|
|
newbuffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
|
2004-09-07 21:32:21 +02:00
|
|
|
else
|
2006-01-06 12:35:20 +01:00
|
|
|
newbuffers = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
|
2004-09-07 21:32:21 +02:00
|
|
|
|
|
|
|
if (newbuffers) {
|
2006-01-06 12:35:20 +01:00
|
|
|
device->buffers = newbuffers;
|
|
|
|
device->buffers[device->nrofbuffers] = pDSB;
|
|
|
|
device->nrofbuffers++;
|
|
|
|
TRACE("buffer count is now %d\n", device->nrofbuffers);
|
2004-09-07 21:32:21 +02:00
|
|
|
} else {
|
2006-01-06 12:35:20 +01:00
|
|
|
ERR("out of memory for buffer list! Current buffer count is %d\n", device->nrofbuffers);
|
2004-09-07 21:32:21 +02:00
|
|
|
hr = DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
RtlReleaseResource(&(device->buffer_list_lock));
|
2004-09-07 21:32:21 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove secondary buffer from buffer list.
|
|
|
|
* Gets exclusive access to buffer for writing.
|
|
|
|
*/
|
2006-01-14 17:06:52 +01:00
|
|
|
HRESULT DirectSoundDevice_RemoveBuffer(
|
2006-01-06 12:35:20 +01:00
|
|
|
DirectSoundDevice * device,
|
2004-09-07 21:32:21 +02:00
|
|
|
IDirectSoundBufferImpl * pDSB)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
HRESULT hr = DS_OK;
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("(%p, %p)\n", device, pDSB);
|
2004-09-07 21:32:21 +02:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
|
2004-09-07 21:32:21 +02:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
for (i = 0; i < device->nrofbuffers; i++)
|
|
|
|
if (device->buffers[i] == pDSB)
|
2004-09-07 21:32:21 +02:00
|
|
|
break;
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
if (i < device->nrofbuffers) {
|
2004-09-07 21:32:21 +02:00
|
|
|
/* Put the last buffer of the list in the (now empty) position */
|
2006-01-06 12:35:20 +01:00
|
|
|
device->buffers[i] = device->buffers[device->nrofbuffers - 1];
|
|
|
|
device->nrofbuffers--;
|
|
|
|
device->buffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(LPDIRECTSOUNDBUFFER8)*device->nrofbuffers);
|
|
|
|
TRACE("buffer count is now %d\n", device->nrofbuffers);
|
2004-09-07 21:32:21 +02:00
|
|
|
}
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
if (device->nrofbuffers == 0) {
|
|
|
|
HeapFree(GetProcessHeap(),0,device->buffers);
|
|
|
|
device->buffers = NULL;
|
2004-09-07 21:32:21 +02:00
|
|
|
}
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
RtlReleaseResource(&(device->buffer_list_lock));
|
2004-09-07 21:32:21 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|