]> git.mxchange.org Git - flightgear.git/commitdiff
sound: fix sound-buffer-in-use issue
authorThorstenB <brehmt@gmail.com>
Sun, 4 Dec 2011 16:18:02 +0000 (17:18 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 4 Dec 2011 16:18:02 +0000 (17:18 +0100)
FGFX objects must be dereferenced early enough, and sound manager must be
removed late enough - otherwise openal complains about resources being
still in use when tryin to remove buffers.
Also: do not create FGFX objects for AI/MP aircraft, when AI sound is
disabled.

src/AIModel/AIBase.cxx
src/Main/globals.cxx
src/Model/acmodel.cxx

index 95d023296daeead9e0194f595f86300ecad6dd70..230837621f32712504766c46d63a61255cdd315b 100644 (file)
@@ -228,7 +228,7 @@ void FGAIBase::update(double dt) {
                             pitch*speed );
         _fx->set_velocity( velocity );
     }
-    else if (_aimodel)
+    else if ((_aimodel)&&(fgGetBool("/sim/sound/aimodels/enabled",false)))
     {
         string fxpath = _aimodel->get_sound_path();
         if (fxpath != "")
@@ -492,6 +492,8 @@ void FGAIBase::unbind() {
 
     props->setBoolValue("/sim/controls/radar/", true);
 
+    // drop reference to sound effects now
+    _fx = 0;
 }
 
 double FGAIBase::UpdateRadar(FGAIManager* manager) {
index 00dd943dc49378181e4ab2fd40686ab26d14b173..4eb26f21f7ec3296239bf04c745bb846a9620b88 100644 (file)
@@ -171,7 +171,8 @@ FGGlobals::~FGGlobals()
         ai->unbind();
         delete ai;
     }
-    
+    SGSubsystem* sound = subsystem_mgr->remove("sound");
+
     subsystem_mgr->shutdown();
     subsystem_mgr->unbind();
     delete subsystem_mgr;
@@ -205,6 +206,7 @@ FGGlobals::~FGGlobals()
     delete tacanlist;
     delete carrierlist;
     delete channellist;
+    delete sound;
 }
 
 
index 3c9faaf23d44456970714636869dbd9b1acf3222..3b0658b0a7173f82051da959778c729358c30a89 100644 (file)
@@ -91,6 +91,9 @@ FGAircraftModel::reinit()
 void
 FGAircraftModel::deinit()
 {
+  // drop reference
+  _fx = 0;
+
   if (!_aircraft) {
     return;
   }