Fixes so that FG will still run when there is no sound device (or
when it couldn't open the sound device/find a sound device that it can
use).

    It would be, IMHO, good, if we're not creating the sound manager, and
the FGFX and FGVoiceMgr if either we couldn't find a sound device we
could use or we want to disable sound completely.


Pigeon.

Index: src/Sound/fg_fx.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Sound/fg_fx.cxx,v
retrieving revision 1.19
diff -u -r1.19 fg_fx.cxx
--- src/Sound/fg_fx.cxx 21 Feb 2006 01:20:04 -0000      1.19
+++ src/Sound/fg_fx.cxx 23 Apr 2006 11:47:17 -0000
@@ -129,6 +129,10 @@
 {
     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 @@
 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 );
Index: src/Instrumentation/mk_viii.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/mk_viii.cxx,v
retrieving revision 1.3
diff -u -r1.3 mk_viii.cxx
--- src/Instrumentation/mk_viii.cxx     10 Mar 2006 21:26:44 -0000      1.3
+++ src/Instrumentation/mk_viii.cxx     23 Apr 2006 11:47:27 -0000
@@ -2299,7 +2299,13 @@
   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 @@
          exit(1);
        }
 
-      globals->get_soundmgr()->add(sample, refname.str());
+      soundmgr->add(sample, refname.str());
       samples[refname.str()] = sample;
     }
 

Reply via email to