]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/fg_fx.cxx
Make the view-manager and sound-manager independent.
[flightgear.git] / src / Sound / fg_fx.cxx
index 390609567badda7c55f4d6d73ac342029e16cea2..b9cd492e4a6bf0d0c757bc60daa0dbb0de85c2cf 100644 (file)
@@ -53,7 +53,6 @@ FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
         _enabled->setBoolValue(fgGetBool("/sim/sound/effects/enabled"));
          _volume = _props->getNode("/sim/sound/aimodels/volume", true);
         _volume->setFloatValue(fgGetFloat("/sim/sound/effects/volume"));
-_volume->setFloatValue(0.1f);
     }
 
     _avionics_enabled = _props->getNode("sim/sound/avionics/enabled", true);
@@ -65,7 +64,7 @@ _volume->setFloatValue(0.1f);
     SGSampleGroup::_refname = refname;
     SGSampleGroup::_smgr->add(this, refname);
 
-    if (_avionics_enabled->getBoolValue())
+    if (!_is_aimodel)
     {
         _avionics = _smgr->find("avionics", true);
         _avionics->tie_to_listener();
@@ -94,6 +93,12 @@ FGFX::init()
     }
     
     SGPath path = globals->resolve_aircraft_path(path_str);
+    if (path.isNull())
+    {
+        SG_LOG(SG_SOUND, SG_ALERT,
+               "File not found: '" << path_str);
+        return;
+    }
     SG_LOG(SG_SOUND, SG_INFO, "Reading sound " << node->getName()
            << " from " << path.str());
 
@@ -107,7 +112,7 @@ FGFX::init()
     }
 
     node = root.getNode("fx");
-    if(node && !_is_aimodel) {
+    if(node) {
         for (int i = 0; i < node->nChildren(); ++i) {
             SGXmlSound *soundfx = new SGXmlSound();
   
@@ -138,23 +143,18 @@ FGFX::reinit()
 void
 FGFX::update (double dt)
 {
-    bool active = _avionics_ext->getBoolValue() ||
-                  _internal->getBoolValue();
-
-    if (_avionics_enabled->getBoolValue()) {
-        if (!_avionics) {
-            _avionics = _smgr->find("avionics", true);
-            _avionics->tie_to_listener();
+    if ( _enabled->getBoolValue() ) {
+        if ( _avionics_enabled->getBoolValue())
+        {
+            if (_avionics_ext->getBoolValue() || _internal->getBoolValue()) {
+                // avionics sound is enabled
+                _avionics->resume(); // no-op if already in resumed state
+                _avionics->set_volume( _avionics_volume->getFloatValue() );
+            }
+            else
+                _avionics->suspend();
         }
 
-        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() );
         resume();