1
0
Fork 0

Reset: sound manager can be shutdown cleanly

This commit is contained in:
James Turner 2013-11-05 05:32:14 +00:00
parent 9a77efacd9
commit 6eb4e833ae
2 changed files with 19 additions and 8 deletions

View file

@ -17,6 +17,10 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/sound/soundmgr_openal.hxx>
#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;

View file

@ -20,10 +20,7 @@
#ifndef __FG_SOUNDMGR_HXX
#define __FG_SOUNDMGR_HXX 1
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <memory>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/sound/soundmgr_openal.hxx>
@ -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> _listener;
};
#else
#include "Main/fg_props.hxx"