]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/fg_fx.cxx
Fix shared library build for metar executable
[flightgear.git] / src / Sound / fg_fx.cxx
index eac5179baf844ea9d6ee20459d31a749e2a0e50a..c8c6b49f383173f27de8d02005c6e0ab30cea742 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();
+    }
 }
 
 
@@ -75,7 +79,7 @@ FGFX::init()
 
     string path_str = node->getStringValue("path");
     if (path_str.empty()) {
-        SG_LOG(SG_SOUND, SG_ALERT, "No path in /sim/sound/path");
+        SG_LOG(SG_SOUND, SG_ALERT, "No path in sim/sound/path");
         return;
     }
     
@@ -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() );