1
0
Fork 0

Reset: fix a static in play-audio-sample

Had to add this to FGGlobals, since it needs to be cleaned up
alongside the sound manager (which ideally it would be owned by, 
but that's a change for another day)
This commit is contained in:
James Turner 2013-11-25 23:53:58 +00:00
parent 4dcd96c4af
commit 25bf3793bd
6 changed files with 30 additions and 11 deletions

View file

@ -1164,10 +1164,11 @@ do_play_audio_sample (const SGPropertyNode * arg)
float volume = arg->getFloatValue("volume"); float volume = arg->getFloatValue("volume");
// cout << "playing " << path << " / " << file << endl; // cout << "playing " << path << " / " << file << endl;
try { try {
static FGSampleQueue *queue = 0; FGSampleQueue *queue = globals->get_chatter_queue();
if ( !queue ) { if ( !queue ) {
queue = new FGSampleQueue(smgr, "chatter"); queue = new FGSampleQueue(smgr, "chatter");
queue->tie_to_listener(); queue->tie_to_listener();
globals->set_chatter_queue(queue);
} }
SGSoundSample *msg = new SGSoundSample(file.c_str(), path); SGSoundSample *msg = new SGSoundSample(file.c_str(), path);

View file

@ -982,6 +982,8 @@ void fgStartNewReset()
globals->set_renderer(NULL); globals->set_renderer(NULL);
globals->set_matlib(NULL); globals->set_matlib(NULL);
globals->set_chatter_queue(NULL);
simgear::SGModelLib::resetPropertyRoot(); simgear::SGModelLib::resetPropertyRoot();
globals->resetPropertyRoot(); globals->resetPropertyRoot();

View file

@ -53,6 +53,7 @@
#include <Navaids/navlist.hxx> #include <Navaids/navlist.hxx>
#include <Viewer/renderer.hxx> #include <Viewer/renderer.hxx>
#include <Viewer/viewmgr.hxx> #include <Viewer/viewmgr.hxx>
#include <Sound/sample_queue.hxx>
#include "globals.hxx" #include "globals.hxx"
#include "locale.hxx" #include "locale.hxx"
@ -151,7 +152,8 @@ FGGlobals::FGGlobals() :
initial_waypoints( NULL ), initial_waypoints( NULL ),
fontcache ( new FGFontCache ), fontcache ( new FGFontCache ),
channellist( NULL ), channellist( NULL ),
haveUserSettings(false) haveUserSettings(false),
_chatter_queue(NULL)
{ {
SGPropertyNode* root = new SGPropertyNode; SGPropertyNode* root = new SGPropertyNode;
props = SGPropertyNode_ptr(root); props = SGPropertyNode_ptr(root);
@ -210,6 +212,7 @@ FGGlobals::~FGGlobals()
// renderer touches subsystems during its destruction // renderer touches subsystems during its destruction
set_renderer(NULL); set_renderer(NULL);
_scenery.clear(); _scenery.clear();
_chatter_queue.clear();
delete subsystem_mgr; delete subsystem_mgr;
subsystem_mgr = NULL; // important so ::get_subsystem returns NULL subsystem_mgr = NULL; // important so ::get_subsystem returns NULL
@ -696,4 +699,14 @@ void FGGlobals::set_matlib( SGMaterialLib *m )
matlib = m; matlib = m;
} }
FGSampleQueue* FGGlobals::get_chatter_queue() const
{
return _chatter_queue;
}
void FGGlobals::set_chatter_queue(FGSampleQueue* queue)
{
_chatter_queue = queue;
}
// end of globals.cxx // end of globals.cxx

View file

@ -66,7 +66,7 @@ class FGViewMgr;
class FGViewer; class FGViewer;
class FGRenderer; class FGRenderer;
class FGFontCache; class FGFontCache;
class FGSampleQueue;
/** /**
* Bucket for subsystem pointers representing the sim's state. * Bucket for subsystem pointers representing the sim's state.
@ -161,6 +161,8 @@ private:
* helper to initialise standard properties on a new property tree * helper to initialise standard properties on a new property tree
*/ */
void initProperties(); void initProperties();
SGSharedPtr<FGSampleQueue> _chatter_queue;
public: public:
FGGlobals(); FGGlobals();
@ -341,6 +343,9 @@ public:
* Save user settings in autosave.xml * Save user settings in autosave.xml
*/ */
void saveUserSettings(); void saveUserSettings();
FGSampleQueue* get_chatter_queue() const;
void set_chatter_queue(FGSampleQueue* queue);
}; };

View file

@ -50,10 +50,6 @@ FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
FGSampleQueue::~FGSampleQueue () FGSampleQueue::~FGSampleQueue ()
{ {
while ( ! _messages.empty() ) {
delete _messages.front();
_messages.pop();
}
} }

View file

@ -91,6 +91,8 @@ void FGSoundManager::shutdown()
SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true); SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true);
scenery_loaded->removeChangeListener(_listener.get()); scenery_loaded->removeChangeListener(_listener.get());
stop();
SGSoundMgr::shutdown(); SGSoundMgr::shutdown();
} }