Changed: CListenerFMod inherits from NLMISC::CManualSingleton<CListenerFMod>

hg/feature/sound
kervala 15 years ago
parent 6dec8a3cf5
commit 161e40a3f2

@ -26,36 +26,23 @@ namespace NLSOUND
{
// ***************************************************************************
// The instance of the singleton
CListenerFMod *CListenerFMod::_Instance = NULL;
// ***************************************************************************
CListenerFMod::CListenerFMod() //: IListener()
: _Pos(CVector::Null), _Vel(CVector::Null), _Front(CVector::J), _Up(CVector::K)
{
if ( _Instance == NULL )
_RolloffFactor= 1.f;
_Pos= CVector::Null;
_Vel= CVector::Null;
_Front= CVector::J;
_Up= CVector::K;
if (CSoundDriverFMod::getInstance()->getOption(ISoundDriver::OptionManualRolloff))
{
_Instance = this;
_RolloffFactor= 1.f;
_Pos= CVector::Null;
_Vel= CVector::Null;
_Front= CVector::J;
_Up= CVector::K;
if (CSoundDriverFMod::getInstance()->getOption(ISoundDriver::OptionManualRolloff))
// Manual RollOff => disable API rollOff
if( CSoundDriverFMod::getInstance()->fmodOk() )
{
// Manual RollOff => disable API rollOff
if( CSoundDriverFMod::getInstance()->fmodOk() )
{
FSOUND_3D_SetRolloffFactor(0);
}
FSOUND_3D_SetRolloffFactor(0);
}
}
else
{
//nlerror( "Listener singleton instanciated twice" );
}
}
@ -65,7 +52,6 @@ CListenerFMod::~CListenerFMod()
//nldebug("Destroying FMod listener");
release();
_Instance = NULL;
}

@ -17,9 +17,11 @@
#ifndef NL_LISTENER_FMOD_H
#define NL_LISTENER_FMOD_H
#include <nel/sound/driver/listener.h>
#include "nel/sound/driver/listener.h"
#include "nel/misc/singleton.h"
namespace NLSOUND {
namespace NLSOUND
{
/**
@ -32,7 +34,7 @@ namespace NLSOUND {
* \author Nevrax France
* \date 2002
*/
class CListenerFMod : public IListener
class CListenerFMod : public IListener, public NLMISC::CManualSingleton<CListenerFMod>
{
friend class CSoundDriverFMod;
@ -44,9 +46,6 @@ public:
/// Deconstructor
virtual ~CListenerFMod();
/// Return the instance of the singleton
static CListenerFMod* instance() { return _Instance; }
/// \name Listener properties
//@{
@ -109,9 +108,6 @@ private:
/// Release all DirectSound resources
void release();
/// The instance of the singleton
static CListenerFMod *_Instance;
// Nel Basis
NLMISC::CVector _Pos;
NLMISC::CVector _Vel;

@ -149,9 +149,9 @@ CSoundDriverFMod::~CSoundDriverFMod()
// Assure that the listener has released all resources before closing down FMod
if (CListenerFMod::instance() != 0)
if (CListenerFMod::getInstance() != 0)
{
CListenerFMod::instance()->release();
CListenerFMod::getInstance()->release();
}
// Close FMod
@ -283,9 +283,9 @@ void CSoundDriverFMod::update()
IListener *CSoundDriverFMod::createListener()
{
if (CListenerFMod::instance() != NULL)
if (CListenerFMod::isInitialized())
{
return CListenerFMod::instance();
return CListenerFMod::getInstance();
}
if ( !_FModOk )
@ -353,7 +353,7 @@ void CSoundDriverFMod::commit3DChanges()
// We handle the volume of the source according to the distance
// ourselves. Call updateVolume() to, well..., update the volume
// according to, euh ..., the new distance!
CListenerFMod* listener = CListenerFMod::instance();
CListenerFMod* listener = CListenerFMod::getInstance();
if(listener)
{
const CVector &origin = listener->getPos();

@ -42,15 +42,14 @@ CSourceFMod::CSourceFMod( uint sourcename )
_PosRelative= false;
_Loop = false;
_Gain = 1.0f;
_Gain = NLSOUND_DEFAULT_GAIN;
_Alpha = 0.0;
_Pos= _Vel= CVector::Null;
_Front= CVector::J;
_MinDist= 1.f;
_MaxDist= FLT_MAX;
_MaxDist= numeric_limits<float>::max();
_Pitch= 1.0f;
_FModChannel= -1;
}
@ -180,7 +179,7 @@ bool CSourceFMod::play()
else
{
// manual rolloff => recompute according to position
CListenerFMod *listener = CListenerFMod::instance();
CListenerFMod *listener = CListenerFMod::getInstance();
if (listener) updateVolume(listener->getPos());
}
@ -510,7 +509,7 @@ void CSourceFMod::updateFModPos()
// If relative, must transform to absolute
if(_PosRelative)
{
CListenerFMod *lsr= CListenerFMod::instance();
CListenerFMod *lsr= CListenerFMod::getInstance();
if(lsr)
{
wpos= lsr->getPosMatrix() * wpos;

Loading…
Cancel
Save