]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a number of small bugs; eg test if SoundMgr::load fails and return false in that...
authorehofman <ehofman>
Mon, 19 Oct 2009 10:41:17 +0000 (10:41 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 19 Oct 2009 22:00:08 +0000 (00:00 +0200)
src/ATCDCL/ATCVoice.cxx
src/Sound/fg_fx.cxx
src/Sound/sample_queue.cxx

index 023dde22cb72b71c13a3049d752be32cf39dae55..bcd48f54ad18f168c1cd79ba7926d1311afc523b 100644 (file)
@@ -74,7 +74,8 @@ bool FGATCVoice::LoadVoice(const string& voice) {
        int format, freq;
         SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
        void *data;
-       smgr->load(full_path, &data, &format, &rawDataSize, &freq);
+        if (!smgr->load(full_path, &data, &format, &rawDataSize, &freq))
+            return false;
        rawSoundData = (char*)data;
 #ifdef VOICE_TEST
        cout << "ATCVoice:  format: " << format
index 8bc493bfae15d61a230eb83b7fa6c874750e7543..4d879bff26d90ef4a441dfb72cfb371d81624aef 100644 (file)
@@ -39,7 +39,7 @@
 #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") )
@@ -114,7 +114,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 +124,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
index d032a8d904b8f4b2aabf95daafcbf31a3b0c9f11..f09870947b95d725037c3be2566f4e6f47e5aa61 100644 (file)
@@ -37,7 +37,7 @@
 #include <simgear/sound/sample_openal.hxx>
 
 FGSampleQueue::FGSampleQueue ( 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") )
@@ -59,6 +59,7 @@ FGSampleQueue::~FGSampleQueue ()
 void
 FGSampleQueue::update (double dt)
 {
+return;
     // command sound manger
     bool new_pause = _pause->getBoolValue();
     if ( new_pause != last_pause ) {
@@ -70,34 +71,36 @@ FGSampleQueue::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;
+        }
 
-    // process mesage queue
-    const string msgid = "Sequential Audio Message";
-    bool now_playing = false;
-    if ( exists( msgid ) ) {
-        now_playing = is_playing( msgid );
-        if ( !now_playing ) {
-            // current message finished, stop and remove
-            stop( msgid );   // removes source
-            remove( msgid ); // removes buffer
+        // process mesage queue
+        const string msgid = "Sequential Audio Message";
+        bool now_playing = false;
+        if ( exists( msgid ) ) {
+            now_playing = is_playing( msgid );
+            if ( !now_playing ) {
+                // current message finished, stop and remove
+                stop( msgid );   // removes source
+                remove( msgid ); // removes buffer
+            }
         }
-    }
 
-    if ( !now_playing ) {
-        // message queue idle, add next sound if we have one
-        if ( _messages.size() > 0 ) {
-            SGSampleGroup::add( _messages.front(), msgid );
-            _messages.pop();
-            play_once( msgid );
+        if ( !now_playing ) {
+            // message queue idle, add next sound if we have one
+            if ( _messages.size() > 0 ) {
+                SGSampleGroup::add( _messages.front(), msgid );
+                _messages.pop();
+                play_once( msgid );
+            }
         }
-    }
 
-    SGSampleGroup::update(dt);
+        SGSampleGroup::update(dt);
+    }
 }
 
 // end of _samplequeue.cxx