dsound: Merge IDirectSound3DListener into the primary buffer object.

oldstable
Michael Stefaniuc 2012-01-16 00:13:31 +01:00 committed by Alexandre Julliard
parent 044edbb625
commit 37df4671cb
3 changed files with 115 additions and 187 deletions

View File

@ -49,7 +49,6 @@ typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl; typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl; typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl; typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl; typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl; typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
typedef struct DirectSoundDevice DirectSoundDevice; typedef struct DirectSoundDevice DirectSoundDevice;
@ -105,7 +104,6 @@ struct DirectSoundDevice
normfunc normfunction; normfunc normfunction;
/* DirectSound3DListener fields */ /* DirectSound3DListener fields */
IDirectSound3DListenerImpl* listener;
DS3DLISTENER ds3dl; DS3DLISTENER ds3dl;
BOOL ds3dl_need_recalc; BOOL ds3dl_need_recalc;
@ -167,8 +165,9 @@ HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
struct IDirectSoundBufferImpl struct IDirectSoundBufferImpl
{ {
IDirectSoundBuffer8 IDirectSoundBuffer8_iface; IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
IDirectSound3DListener IDirectSound3DListener_iface; /* only primary buffer */
LONG numIfaces; /* "in use interfaces" refcount */ LONG numIfaces; /* "in use interfaces" refcount */
LONG ref; LONG ref, ref3D;
/* IDirectSoundBufferImpl fields */ /* IDirectSoundBufferImpl fields */
DirectSoundDevice* device; DirectSoundDevice* device;
RTL_RWLOCK lock; RTL_RWLOCK lock;
@ -213,6 +212,7 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
IDirectSoundBufferImpl **ppdsb, IDirectSoundBufferImpl **ppdsb,
IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN; IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN; void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
* DirectSoundCaptureDevice implementation structure * DirectSoundCaptureDevice implementation structure
@ -259,22 +259,6 @@ struct IDirectSoundCaptureBufferImpl
int nrofnotifies; int nrofnotifies;
}; };
/*****************************************************************************
* IDirectSound3DListener implementation structure
*/
struct IDirectSound3DListenerImpl
{
/* IUnknown fields */
const IDirectSound3DListenerVtbl *lpVtbl;
LONG ref;
/* IDirectSound3DListenerImpl fields */
DirectSoundDevice* device;
};
HRESULT IDirectSound3DListenerImpl_Create(
DirectSoundDevice *device,
IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
* IKsBufferPropertySet implementation structure * IKsBufferPropertySet implementation structure
*/ */

View File

@ -1123,7 +1123,7 @@ static HRESULT WINAPI PrimaryBufferImpl_QueryInterface(IDirectSoundBuffer *iface
void **ppobj) void **ppobj)
{ {
IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
DirectSoundDevice *device = This->device;
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
if (ppobj == NULL) { if (ppobj == NULL) {
@ -1159,18 +1159,11 @@ static HRESULT WINAPI PrimaryBufferImpl_QueryInterface(IDirectSoundBuffer *iface
} }
if ( IsEqualGUID( &IID_IDirectSound3DListener, riid ) ) { if ( IsEqualGUID( &IID_IDirectSound3DListener, riid ) ) {
if (!device->listener) *ppobj = &This->IDirectSound3DListener_iface;
IDirectSound3DListenerImpl_Create(device, &device->listener); IDirectSound3DListener_AddRef(&This->IDirectSound3DListener_iface);
if (device->listener) {
*ppobj = device->listener;
IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)*ppobj);
return S_OK; return S_OK;
} }
WARN("IID_IDirectSound3DListener failed\n");
return E_NOINTERFACE;
}
if ( IsEqualGUID( &IID_IKsPropertySet, riid ) ) { if ( IsEqualGUID( &IID_IKsPropertySet, riid ) ) {
FIXME("app requested IKsPropertySet on primary buffer\n"); FIXME("app requested IKsPropertySet on primary buffer\n");
return E_NOINTERFACE; return E_NOINTERFACE;
@ -1226,11 +1219,32 @@ HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl *
} }
dsb->ref = 1; dsb->ref = 1;
dsb->ref3D = 0;
dsb->numIfaces = 1; dsb->numIfaces = 1;
dsb->device = device; dsb->device = device;
dsb->IDirectSoundBuffer8_iface.lpVtbl = (IDirectSoundBuffer8Vtbl *)&dspbvt; dsb->IDirectSoundBuffer8_iface.lpVtbl = (IDirectSoundBuffer8Vtbl *)&dspbvt;
dsb->IDirectSound3DListener_iface.lpVtbl = &ds3dlvt;
dsb->dsbd = *dsbd; dsb->dsbd = *dsbd;
/* IDirectSound3DListener */
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;
device->ds3dl_need_recalc = TRUE;
TRACE("Created primary buffer at %p\n", dsb); TRACE("Created primary buffer at %p\n", dsb);
TRACE("(formattag=0x%04x,chans=%d,samplerate=%d," TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
"bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n", "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",

View File

@ -302,7 +302,7 @@ static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl *dsb)
DSOUND_Calc3DBuffer(dsb); DSOUND_Calc3DBuffer(dsb);
} }
static void DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl) static void DSOUND_ChangeListener(IDirectSoundBufferImpl *ds3dl)
{ {
int i; int i;
TRACE("(%p)\n",ds3dl); TRACE("(%p)\n",ds3dl);
@ -732,74 +732,55 @@ HRESULT IDirectSound3DBufferImpl_Destroy(
/******************************************************************************* /*******************************************************************************
* IDirectSound3DListener * IDirectSound3DListener
*/ */
static inline IDirectSoundBufferImpl *impl_from_IDirectSound3DListener(IDirectSound3DListener *iface)
{
return CONTAINING_RECORD(iface, IDirectSoundBufferImpl, IDirectSound3DListener_iface);
}
/* IUnknown methods */ /* IUnknown methods */
static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface( static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, REFIID riid, LPVOID *ppobj) REFIID riid, void **ppobj)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
if (ppobj == NULL) { return IDirectSoundBuffer_QueryInterface(&This->IDirectSoundBuffer8_iface, riid, ppobj);
WARN("invalid parameter\n");
return E_INVALIDARG;
} }
*ppobj = NULL; /* assume failure */ static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(IDirectSound3DListener *iface)
if ( IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDirectSound3DListener ) ) {
IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)This);
*ppobj = This;
return S_OK;
}
if ( IsEqualGUID(riid, &IID_IDirectSoundBuffer) ) {
*ppobj = &This->device->primary->IDirectSoundBuffer8_iface;
IDirectSoundBuffer8_AddRef(&This->device->primary->IDirectSoundBuffer8_iface);
return S_OK;
}
FIXME( "Unknown IID %s\n", debugstr_guid( riid ) );
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
ULONG ref = InterlockedIncrement(&(This->ref)); ULONG ref = InterlockedIncrement(&This->ref3D);
TRACE("(%p) ref was %d\n", This, ref - 1); TRACE("(%p) ref was %d\n", This, ref - 1);
if(ref == 1) if(ref == 1)
InterlockedIncrement(&This->device->primary->numIfaces); InterlockedIncrement(&This->numIfaces);
return ref; return ref;
} }
static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER iface) static ULONG WINAPI IDirectSound3DListenerImpl_Release(IDirectSound3DListener *iface)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
ULONG ref = InterlockedDecrement(&(This->ref)); ULONG ref = InterlockedDecrement(&This->ref3D);
TRACE("(%p) ref was %d\n", This, ref + 1); TRACE("(%p) ref was %d\n", This, ref + 1);
if (!ref) { if (!ref && !InterlockedDecrement(&This->numIfaces))
This->device->listener = 0; primarybuffer_destroy(This);
if (!InterlockedDecrement(&This->device->primary->numIfaces))
primarybuffer_destroy(This->device->primary);
HeapFree(GetProcessHeap(), 0, This);
TRACE("(%p) released\n", This);
}
return ref; return ref;
} }
/* IDirectSound3DListener methods */ /* IDirectSound3DListener methods */
static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter( static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, DS3DLISTENER *lpDS3DL)
LPDS3DLISTENER lpDS3DL)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("(%p,%p)\n",This,lpDS3DL); TRACE("(%p,%p)\n",This,lpDS3DL);
if (lpDS3DL == NULL) { if (lpDS3DL == NULL) {
@ -817,32 +798,31 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE *lpfDistanceFactor)
LPD3DVALUE lpfDistanceFactor)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: Distance Factor = %f\n", This->device->ds3dl.flDistanceFactor); TRACE("returning: Distance Factor = %f\n", This->device->ds3dl.flDistanceFactor);
*lpfDistanceFactor = This->device->ds3dl.flDistanceFactor; *lpfDistanceFactor = This->device->ds3dl.flDistanceFactor;
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE *lpfDopplerFactor)
LPD3DVALUE lpfDopplerFactor)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: Doppler Factor = %f\n", This->device->ds3dl.flDopplerFactor); TRACE("returning: Doppler Factor = %f\n", This->device->ds3dl.flDopplerFactor);
*lpfDopplerFactor = This->device->ds3dl.flDopplerFactor; *lpfDopplerFactor = This->device->ds3dl.flDopplerFactor;
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation( static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVECTOR *lpvOrientFront, D3DVECTOR *lpvOrientTop)
LPD3DVECTOR lpvOrientFront,
LPD3DVECTOR lpvOrientTop)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->device->ds3dl.vOrientFront.x, TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->device->ds3dl.vOrientFront.x,
This->device->ds3dl.vOrientFront.y, This->device->ds3dl.vOrientFront.z, This->device->ds3dl.vOrientTop.x, This->device->ds3dl.vOrientTop.y, This->device->ds3dl.vOrientFront.y, This->device->ds3dl.vOrientFront.z, This->device->ds3dl.vOrientTop.x, This->device->ds3dl.vOrientTop.y,
This->device->ds3dl.vOrientTop.z); This->device->ds3dl.vOrientTop.z);
@ -851,42 +831,41 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition( static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVECTOR *lpvPosition)
LPD3DVECTOR lpvPosition)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: Position vector = (%f,%f,%f)\n", This->device->ds3dl.vPosition.x, This->device->ds3dl.vPosition.y, This->device->ds3dl.vPosition.z); TRACE("returning: Position vector = (%f,%f,%f)\n", This->device->ds3dl.vPosition.x, This->device->ds3dl.vPosition.y, This->device->ds3dl.vPosition.z);
*lpvPosition = This->device->ds3dl.vPosition; *lpvPosition = This->device->ds3dl.vPosition;
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE *lpfRolloffFactor)
LPD3DVALUE lpfRolloffFactor)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: RolloffFactor = %f\n", This->device->ds3dl.flRolloffFactor); TRACE("returning: RolloffFactor = %f\n", This->device->ds3dl.flRolloffFactor);
*lpfRolloffFactor = This->device->ds3dl.flRolloffFactor; *lpfRolloffFactor = This->device->ds3dl.flRolloffFactor;
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity( static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVECTOR *lpvVelocity)
LPD3DVECTOR lpvVelocity)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->device->ds3dl.vVelocity.x, This->device->ds3dl.vVelocity.y, This->device->ds3dl.vVelocity.z); TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->device->ds3dl.vVelocity.x, This->device->ds3dl.vVelocity.y, This->device->ds3dl.vVelocity.z);
*lpvVelocity = This->device->ds3dl.vVelocity; *lpvVelocity = This->device->ds3dl.vVelocity;
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters( static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, const DS3DLISTENER *lpcDS3DL, DWORD dwApply)
LPCDS3DLISTENER lpcDS3DL,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: all parameters; dwApply = %d\n", dwApply); TRACE("setting: all parameters; dwApply = %d\n", dwApply);
This->device->ds3dl = *lpcDS3DL; This->device->ds3dl = *lpcDS3DL;
if (dwApply == DS3D_IMMEDIATE) if (dwApply == DS3D_IMMEDIATE)
@ -898,12 +877,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE fDistanceFactor, DWORD dwApply)
D3DVALUE fDistanceFactor,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Distance Factor = %f; dwApply = %d\n", fDistanceFactor, dwApply); TRACE("setting: Distance Factor = %f; dwApply = %d\n", fDistanceFactor, dwApply);
This->device->ds3dl.flDistanceFactor = fDistanceFactor; This->device->ds3dl.flDistanceFactor = fDistanceFactor;
if (dwApply == DS3D_IMMEDIATE) if (dwApply == DS3D_IMMEDIATE)
@ -915,12 +893,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE fDopplerFactor, DWORD dwApply)
D3DVALUE fDopplerFactor,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Doppler Factor = %f; dwApply = %d\n", fDopplerFactor, dwApply); TRACE("setting: Doppler Factor = %f; dwApply = %d\n", fDopplerFactor, dwApply);
This->device->ds3dl.flDopplerFactor = fDopplerFactor; This->device->ds3dl.flDopplerFactor = fDopplerFactor;
if (dwApply == DS3D_IMMEDIATE) if (dwApply == DS3D_IMMEDIATE)
@ -932,13 +909,12 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation( static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, D3DVALUE xTop, D3DVALUE yTop,
D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, D3DVALUE zTop, DWORD dwApply)
D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %d\n", TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %d\n",
xFront, yFront, zFront, xTop, yTop, zTop, dwApply); xFront, yFront, zFront, xTop, yTop, zTop, dwApply);
This->device->ds3dl.vOrientFront.x = xFront; This->device->ds3dl.vOrientFront.x = xFront;
@ -956,12 +932,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition( static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
D3DVALUE x, D3DVALUE y, D3DVALUE z,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply); TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
This->device->ds3dl.vPosition.x = x; This->device->ds3dl.vPosition.x = x;
This->device->ds3dl.vPosition.y = y; This->device->ds3dl.vPosition.y = y;
@ -975,12 +950,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor( static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE fRolloffFactor, DWORD dwApply)
D3DVALUE fRolloffFactor,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Rolloff Factor = %f; dwApply = %d\n", fRolloffFactor, dwApply); TRACE("setting: Rolloff Factor = %f; dwApply = %d\n", fRolloffFactor, dwApply);
This->device->ds3dl.flRolloffFactor = fRolloffFactor; This->device->ds3dl.flRolloffFactor = fRolloffFactor;
if (dwApply == DS3D_IMMEDIATE) if (dwApply == DS3D_IMMEDIATE)
@ -992,12 +966,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity( static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(IDirectSound3DListener *iface,
LPDIRECTSOUND3DLISTENER iface, D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
D3DVALUE x, D3DVALUE y, D3DVALUE z,
DWORD dwApply)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply); TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
This->device->ds3dl.vVelocity.x = x; This->device->ds3dl.vVelocity.x = x;
This->device->ds3dl.vVelocity.y = y; This->device->ds3dl.vVelocity.y = y;
@ -1011,16 +984,16 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSound3DListenerImpl_CommitDeferredSettings( static HRESULT WINAPI IDirectSound3DListenerImpl_CommitDeferredSettings(IDirectSound3DListener *iface)
LPDIRECTSOUND3DLISTENER iface)
{ {
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface; IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("\n"); TRACE("\n");
DSOUND_ChangeListener(This); DSOUND_ChangeListener(This);
return DS_OK; return DS_OK;
} }
static const IDirectSound3DListenerVtbl ds3dlvt = const IDirectSound3DListenerVtbl ds3dlvt =
{ {
/* IUnknown methods */ /* IUnknown methods */
IDirectSound3DListenerImpl_QueryInterface, IDirectSound3DListenerImpl_QueryInterface,
@ -1043,46 +1016,3 @@ static const IDirectSound3DListenerVtbl ds3dlvt =
IDirectSound3DListenerImpl_SetVelocity, IDirectSound3DListenerImpl_SetVelocity,
IDirectSound3DListenerImpl_CommitDeferredSettings, IDirectSound3DListenerImpl_CommitDeferredSettings,
}; };
HRESULT IDirectSound3DListenerImpl_Create(
DirectSoundDevice * device,
IDirectSound3DListenerImpl ** ppdsl)
{
IDirectSound3DListenerImpl *pdsl;
TRACE("(%p,%p)\n",device,ppdsl);
pdsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*pdsl));
if (pdsl == NULL) {
WARN("out of memory\n");
*ppdsl = 0;
return DSERR_OUTOFMEMORY;
}
pdsl->ref = 0;
pdsl->lpVtbl = &ds3dlvt;
pdsl->device = device;
pdsl->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
pdsl->device->ds3dl.vPosition.x = 0.0;
pdsl->device->ds3dl.vPosition.y = 0.0;
pdsl->device->ds3dl.vPosition.z = 0.0;
pdsl->device->ds3dl.vVelocity.x = 0.0;
pdsl->device->ds3dl.vVelocity.y = 0.0;
pdsl->device->ds3dl.vVelocity.z = 0.0;
pdsl->device->ds3dl.vOrientFront.x = 0.0;
pdsl->device->ds3dl.vOrientFront.y = 0.0;
pdsl->device->ds3dl.vOrientFront.z = 1.0;
pdsl->device->ds3dl.vOrientTop.x = 0.0;
pdsl->device->ds3dl.vOrientTop.y = 1.0;
pdsl->device->ds3dl.vOrientTop.z = 0.0;
pdsl->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
pdsl->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
pdsl->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
pdsl->device->ds3dl_need_recalc = TRUE;
*ppdsl = pdsl;
return S_OK;
}