diff --git a/code/nel/src/sound/driver/fmod/listener_fmod.cpp b/code/nel/src/sound/driver/fmod/listener_fmod.cpp index 3c315041a..0900e4491 100644 --- a/code/nel/src/sound/driver/fmod/listener_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/listener_fmod.cpp @@ -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; } diff --git a/code/nel/src/sound/driver/fmod/listener_fmod.h b/code/nel/src/sound/driver/fmod/listener_fmod.h index 1e8028f3b..134c63c66 100644 --- a/code/nel/src/sound/driver/fmod/listener_fmod.h +++ b/code/nel/src/sound/driver/fmod/listener_fmod.h @@ -17,9 +17,11 @@ #ifndef NL_LISTENER_FMOD_H #define NL_LISTENER_FMOD_H -#include +#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 { 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; diff --git a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp index 60c8bab75..fd491b0af 100644 --- a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp @@ -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(); diff --git a/code/nel/src/sound/driver/fmod/source_fmod.cpp b/code/nel/src/sound/driver/fmod/source_fmod.cpp index 1167afb0d..2ae9a0ea1 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/source_fmod.cpp @@ -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::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;