]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/fg_fx.cxx
allow sound effects in the configuration file to be added to the 'avionics' sample...
[flightgear.git] / src / Sound / fg_fx.cxx
index 6e06fa403830ef91b14ff2d93e903bff41a76400..abf3a2678668dbb997b896c3010f629b5266e15d 100644 (file)
 #include <simgear/sound/xmlsound.hxx>
 
 FGFX::FGFX ( SGSoundMgr *smgr, const string &refname ) :
-    last_pause( true ),
+    last_pause( false ),
     last_volume( 0.0 ),
     _pause( fgGetNode("/sim/sound/pause") ),
     _volume( fgGetNode("/sim/sound/volume") )
 {
     SGSampleGroup::_smgr = smgr;
+    SGSampleGroup::_refname = refname;
     SGSampleGroup::_smgr->add(this, refname);
-    SGSampleGroup::_active = _smgr->is_working();
+    _avionics = _smgr->find("avionics", true);
 }
 
 
@@ -91,7 +92,7 @@ FGFX::init()
   
             try {
                 sound->init(globals->get_props(), node->getChild(i), this,
-                            globals->get_fg_root());
+                            _avionics, globals->get_fg_root());
   
                 _sound.push_back(sound);
             } catch ( sg_exception &e ) {
@@ -114,7 +115,6 @@ FGFX::reinit()
 void
 FGFX::update (double dt)
 {
-    // command sound manger
     bool new_pause = _pause->getBoolValue();
     if ( new_pause != last_pause ) {
         if ( new_pause ) {
@@ -125,20 +125,20 @@ FGFX::update (double dt)
         last_pause = new_pause;
     }
 
-    double volume = _volume->getDoubleValue();
-    if ( volume != last_volume ) {
-        set_volume( volume );        
-        last_volume = volume;
-    }
-
     if ( !new_pause ) {
+        double volume = _volume->getDoubleValue();
+        if ( volume != last_volume ) {
+            set_volume( volume );        
+            last_volume = volume;
+        }
+
         // update sound effects if not paused
         for ( unsigned int i = 0; i < _sound.size(); i++ ) {
             _sound[i]->update(dt);
         }
-    }
 
-    SGSampleGroup::update(dt);
+        SGSampleGroup::update(dt);
+    }
 }
 
 // end of fg_fx.cxx