]> git.mxchange.org Git - flightgear.git/commitdiff
Reset: fix a static in play-audio-sample
authorJames Turner <zakalawe@mac.com>
Mon, 25 Nov 2013 23:53:58 +0000 (23:53 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 25 Nov 2013 23:53:58 +0000 (23:53 +0000)
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)

src/Main/fg_commands.cxx
src/Main/fg_init.cxx
src/Main/globals.cxx
src/Main/globals.hxx
src/Sound/sample_queue.cxx
src/Sound/soundmanager.cxx

index 6ae72a99622eb6ee7a6f4f6a7e057a3007673119..4c0f580b0d87051c9efe8a2927cc25835ea0a2d5 100644 (file)
@@ -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);
index e9748c28cf5f610f8ebb1452ba2c02b8a98fa16a..ba816d21f94abd64d23e94b8cc7e374d52c9eb7f 100644 (file)
@@ -982,8 +982,10 @@ void fgStartNewReset()
     
     globals->set_renderer(NULL);
     globals->set_matlib(NULL);
-    simgear::SGModelLib::resetPropertyRoot();
+    globals->set_chatter_queue(NULL);
     
+    simgear::SGModelLib::resetPropertyRoot();
+        
     globals->resetPropertyRoot();
     globals->restoreInitialState();
     
index 51125d8717f12e139bdd42c8c435e2689d899eae..acfb0d6299576f48cfd8e5f85f5fc2a724d17b02 100644 (file)
@@ -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,7 +212,8 @@ 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
index 09275daae10ebd108c6d9bf110f3239b3bff79cc..3f8ae0689d738933c8d0c97d37d1bcb8e5db2dfb 100644 (file)
@@ -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);
 };
 
 
index e3aaae9f9712fdf2c6d7d0eccf3607443b16942c..f6a1a49b51dd33856572c4754f0ed9ccb1c4edf0 100644 (file)
@@ -50,10 +50,6 @@ FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
 
 FGSampleQueue::~FGSampleQueue ()
 {
-    while ( ! _messages.empty() ) {
-        delete _messages.front();
-        _messages.pop();
-    }
 }
 
 
index a4c197ce9c8da8ad5177005459af9aba99aa2192..012642f669ddddb5dacd35ff74723b1f7f773dbc 100644 (file)
@@ -91,6 +91,8 @@ void FGSoundManager::shutdown()
     SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true);
     scenery_loaded->removeChangeListener(_listener.get());
     
+    stop();
+    
     SGSoundMgr::shutdown();
 }