]> git.mxchange.org Git - flightgear.git/commitdiff
Pigeon:
authorfrohlich <frohlich>
Sun, 23 Apr 2006 15:29:39 +0000 (15:29 +0000)
committerfrohlich <frohlich>
Sun, 23 Apr 2006 15:29:39 +0000 (15:29 +0000)
Avoid crashes if there is no sound device.

src/Instrumentation/mk_viii.cxx
src/Sound/fg_fx.cxx

index 942c679041bcd2cfd45b34bf428c6bc6a6867d15..08f6833d49c9a4aca7310c468f38445f3ee29865 100755 (executable)
@@ -2299,7 +2299,13 @@ MK_VIII::VoicePlayer::get_sample (const char *name)
   std::ostringstream refname;
   refname << mk->name << "[" << mk->num << "]" << "/" << name;
 
-  SGSoundSample *sample = globals->get_soundmgr()->find(refname.str());
+  SGSoundMgr *soundmgr = globals->get_soundmgr();
+  if (soundmgr->is_working() == false)
+    {
+      return NULL;
+    }
+
+  SGSoundSample *sample = soundmgr->find(refname.str());
   if (! sample)
     {
       SGPath sample_path(globals->get_fg_root());
@@ -2316,7 +2322,7 @@ MK_VIII::VoicePlayer::get_sample (const char *name)
          exit(1);
        }
 
-      globals->get_soundmgr()->add(sample, refname.str());
+      soundmgr->add(sample, refname.str());
       samples[refname.str()] = sample;
     }
 
index b04d9a46fc14ef90018b77778144bbebe2b29686..a7605934997b1612069d7c30da3215c051081773 100644 (file)
@@ -129,6 +129,10 @@ FGFX::update (double dt)
 {
     SGSoundMgr *smgr = globals->get_soundmgr();
 
+    if (smgr->is_working() == false) {
+        return;
+    }
+
     // command sound manger
     bool pause = _pause->getBoolValue();
     if ( pause != last_pause ) {
@@ -189,6 +193,9 @@ FGFX::play_message( SGSoundSample *_sample )
 void
 FGFX::play_message( const string path, const string fname )
 {
+    if (globals->get_soundmgr()->is_working() == false) {
+        return;
+    }
     SGSoundSample *sample;
     sample = new SGSoundSample( path.c_str(), fname.c_str() );
     play_message( sample );