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:
parent
4dcd96c4af
commit
25bf3793bd
6 changed files with 30 additions and 11 deletions
|
@ -1164,10 +1164,11 @@ do_play_audio_sample (const SGPropertyNode * arg)
|
|||
float volume = arg->getFloatValue("volume");
|
||||
// cout << "playing " << path << " / " << file << endl;
|
||||
try {
|
||||
static FGSampleQueue *queue = 0;
|
||||
FGSampleQueue *queue = globals->get_chatter_queue();
|
||||
if ( !queue ) {
|
||||
queue = new FGSampleQueue(smgr, "chatter");
|
||||
queue->tie_to_listener();
|
||||
queue = new FGSampleQueue(smgr, "chatter");
|
||||
queue->tie_to_listener();
|
||||
globals->set_chatter_queue(queue);
|
||||
}
|
||||
|
||||
SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
|
||||
|
|
|
@ -982,6 +982,8 @@ void fgStartNewReset()
|
|||
|
||||
globals->set_renderer(NULL);
|
||||
globals->set_matlib(NULL);
|
||||
globals->set_chatter_queue(NULL);
|
||||
|
||||
simgear::SGModelLib::resetPropertyRoot();
|
||||
|
||||
globals->resetPropertyRoot();
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <Navaids/navlist.hxx>
|
||||
#include <Viewer/renderer.hxx>
|
||||
#include <Viewer/viewmgr.hxx>
|
||||
#include <Sound/sample_queue.hxx>
|
||||
|
||||
#include "globals.hxx"
|
||||
#include "locale.hxx"
|
||||
|
@ -151,7 +152,8 @@ FGGlobals::FGGlobals() :
|
|||
initial_waypoints( NULL ),
|
||||
fontcache ( new FGFontCache ),
|
||||
channellist( NULL ),
|
||||
haveUserSettings(false)
|
||||
haveUserSettings(false),
|
||||
_chatter_queue(NULL)
|
||||
{
|
||||
SGPropertyNode* root = new SGPropertyNode;
|
||||
props = SGPropertyNode_ptr(root);
|
||||
|
@ -210,6 +212,7 @@ FGGlobals::~FGGlobals()
|
|||
// renderer touches subsystems during its destruction
|
||||
set_renderer(NULL);
|
||||
_scenery.clear();
|
||||
_chatter_queue.clear();
|
||||
|
||||
delete subsystem_mgr;
|
||||
subsystem_mgr = NULL; // important so ::get_subsystem returns NULL
|
||||
|
@ -696,4 +699,14 @@ void FGGlobals::set_matlib( SGMaterialLib *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
|
||||
|
|
|
@ -66,7 +66,7 @@ class FGViewMgr;
|
|||
class FGViewer;
|
||||
class FGRenderer;
|
||||
class FGFontCache;
|
||||
|
||||
class FGSampleQueue;
|
||||
|
||||
/**
|
||||
* Bucket for subsystem pointers representing the sim's state.
|
||||
|
@ -161,6 +161,8 @@ private:
|
|||
* helper to initialise standard properties on a new property tree
|
||||
*/
|
||||
void initProperties();
|
||||
|
||||
SGSharedPtr<FGSampleQueue> _chatter_queue;
|
||||
public:
|
||||
|
||||
FGGlobals();
|
||||
|
@ -341,6 +343,9 @@ public:
|
|||
* Save user settings in autosave.xml
|
||||
*/
|
||||
void saveUserSettings();
|
||||
|
||||
FGSampleQueue* get_chatter_queue() const;
|
||||
void set_chatter_queue(FGSampleQueue* queue);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,10 +50,6 @@ FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
|
|||
|
||||
FGSampleQueue::~FGSampleQueue ()
|
||||
{
|
||||
while ( ! _messages.empty() ) {
|
||||
delete _messages.front();
|
||||
_messages.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -91,6 +91,8 @@ void FGSoundManager::shutdown()
|
|||
SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true);
|
||||
scenery_loaded->removeChangeListener(_listener.get());
|
||||
|
||||
stop();
|
||||
|
||||
SGSoundMgr::shutdown();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue