diff --git a/src/Sound/soundmanager.cxx b/src/Sound/soundmanager.cxx index 9ae7e3aed..a4c197ce9 100644 --- a/src/Sound/soundmanager.cxx +++ b/src/Sound/soundmanager.cxx @@ -17,6 +17,10 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "soundmanager.hxx" @@ -50,8 +54,6 @@ FGSoundManager::FGSoundManager() _enabled(false), _listener(new Listener(this)) { - SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true); - scenery_loaded->addChangeListener(_listener); } FGSoundManager::~FGSoundManager() @@ -78,9 +80,20 @@ void FGSoundManager::init() _viewYoffset = _currentView->getNode("y-offset-m", true); _viewZoffset = _currentView->getNode("z-offset-m", true); + SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true); + scenery_loaded->addChangeListener(_listener.get()); + reinit(); } +void FGSoundManager::shutdown() +{ + SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true); + scenery_loaded->removeChangeListener(_listener.get()); + + SGSoundMgr::shutdown(); +} + void FGSoundManager::reinit() { _is_initialized = false; diff --git a/src/Sound/soundmanager.hxx b/src/Sound/soundmanager.hxx index af7f19bc7..7bec8b8f5 100644 --- a/src/Sound/soundmanager.hxx +++ b/src/Sound/soundmanager.hxx @@ -20,10 +20,7 @@ #ifndef __FG_SOUNDMGR_HXX #define __FG_SOUNDMGR_HXX 1 -#ifdef HAVE_CONFIG_H -# include -#endif - +#include #include #include #include @@ -36,9 +33,10 @@ class FGSoundManager : public SGSoundMgr { public: FGSoundManager(); - ~FGSoundManager(); + virtual ~FGSoundManager(); void init(void); + virtual void shutdown(); void update(double dt); void reinit(void); @@ -54,7 +52,7 @@ private: SGPropertyNode_ptr _viewPosLon, _viewPosLat, _viewPosElev; SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS; SGPropertyNode_ptr _viewXoffset, _viewYoffset, _viewZoffset; - Listener* _listener; + std::auto_ptr _listener; }; #else #include "Main/fg_props.hxx"