]> git.mxchange.org Git - flightgear.git/commitdiff
Postpone initialization of the avionics soundgroup until avionics are enabled. This...
authorErik Hofman <erik@ehofman.com>
Sun, 20 Nov 2011 14:31:58 +0000 (15:31 +0100)
committerErik Hofman <erik@ehofman.com>
Sun, 20 Nov 2011 14:31:58 +0000 (15:31 +0100)
src/AIModel/AIBase.cxx
src/Sound/fg_fx.cxx

index d8c87f90fe2202f46433ff032ccf5265f57faaab..2d7edd550f9addc07353f74e159afcda3c341709 100644 (file)
@@ -314,7 +314,7 @@ bool FGAIBase::init(bool search_in_AI_path) {
 
         // Get the sound-path tag from the configuration file and store it
         // in the property tree.
-        string fxpath = props->getStringValue("/sim/sound/path");
+        string fxpath = props->getStringValue("sim/sound/path");
         if ( !fxpath.empty() )
         {
             props->setStringValue("sim/sound/path", fxpath.c_str());
index eac5179baf844ea9d6ee20459d31a749e2a0e50a..7aad56b0b533d5d7137be1cbd08a07cf2bc464a1 100644 (file)
@@ -54,8 +54,12 @@ FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
     SGSampleGroup::_smgr = smgr;
     SGSampleGroup::_refname = refname;
     SGSampleGroup::_smgr->add(this, refname);
-    _avionics = _smgr->find("avionics", true);
-    _avionics->tie_to_listener();
+
+    if (_avionics_enabled->getBoolValue())
+    {
+        _avionics = _smgr->find("avionics", true);
+        _avionics->tie_to_listener();
+    }
 }
 
 
@@ -128,11 +132,18 @@ FGFX::update (double dt)
     bool active = _avionics_ext->getBoolValue() ||
                   _internal->getBoolValue();
 
-    if ( active && _avionics_enabled->getBoolValue() ) {
-        _avionics->resume(); // no-op if already in resumed state
-    } else
-        _avionics->suspend();
-    _avionics->set_volume( _avionics_volume->getFloatValue() );
+    if (_avionics_enabled->getBoolValue()) {
+        if (!_avionics) {
+            _avionics = _smgr->find("avionics", true);
+            _avionics->tie_to_listener();
+        }
+
+        if ( active )
+            _avionics->resume(); // no-op if already in resumed state
+        else
+            _avionics->suspend();
+        _avionics->set_volume( _avionics_volume->getFloatValue() );
+    }
 
     if ( _enabled->getBoolValue() ) {
         set_volume( _volume->getDoubleValue() );