CVS: source/src/ATCDCL ATCmgr.cxx,1.3,1.4

Erik Hofman <[email protected]> Sat, 10 Apr 2010 03:42:17 -0500
Newsgroups gmane.games.flightgear.cvc
Message-ID <[email protected]>
Update of /var/cvs/FlightGear-0.9/source/src/ATCDCL
In directory baron.flightgear.org:/tmp/cvs-serv8556

Modified Files:
	ATCmgr.cxx 
Log Message:
Delay loading of the voice file since the sound manager might not be initialized (at all).

Index: ATCmgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/ATCDCL/ATCmgr.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ATCmgr.cxx	29 Dec 2009 09:37:19 -0000	1.3
+++ ATCmgr.cxx	10 Apr 2010 08:42:08 -0000	1.4
@@ -59,6 +59,12 @@
 FGATCMgr::FGATCMgr() :
     initDone(false),
     atc_list(new atc_list_type),
+#ifdef ENABLE_AUDIO_SUPPORT
+    voiceOK(false),
+    voice(true),
+#else
+    voice(false),
+#endif
     last_in_range(false)
 {
 }
@@ -89,30 +95,6 @@
         // Is this still true after the reorganization of the event managar??
         // -EMH-
     
-#ifdef ENABLE_AUDIO_SUPPORT 
-    // Load all available voices.
-    // For now we'll do one hardwired one
-    
-    v1 = new FGATCVoice;
-    try {
-        voiceOK = v1->LoadVoice("default");
-        voice = true;
-    } catch ( sg_io_exception & e) {
-        voiceOK  = false;
-        SG_LOG(SG_ATC, SG_ALERT, "Unable to load default voice : " << e.getFormattedMessage().c_str());
-        voice = false;
-        delete v1;
-        v1 = 0;
-    }
-    
-    /* I've loaded the voice even if /sim/sound/pause is true
-    *  since I know no way of forcing load of the voice if the user
-    *  subsequently switches /sim/sound/audible to true.
-        *  (which is the right thing to do -- CLO) :-) */
-#else
-    voice = false;
-#endif
-
     // Initialise the ATC Dialogs
     //cout << "Initing Transmissions..." << endl;
     SG_LOG(SG_ATC, SG_INFO, "  ATC Transmissions");
@@ -421,6 +403,31 @@
     if(voice) {
         switch(type) {
         case ATIS: case AWOS:
+#ifdef ENABLE_AUDIO_SUPPORT
+            // Delayed loading fo all available voices, needed because the
+            // soundmanager might not be initialized (at all) at this point.
+            // For now we'll do one hardwired one
+
+            /* I've loaded the voice even if /sim/sound/pause is true
+             *  since I know no way of forcing load of the voice if the user
+             *  subsequently switches /sim/sound/audible to true.
+             *  (which is the right thing to do -- CLO) :-)
+             */
+            if (!voiceOK && fgGetBool("/sim/sound/working")) {
+                v1 = new FGATCVoice;
+                try {
+                    voiceOK = v1->LoadVoice("default");
+                    voice = voiceOK;
+                } catch ( sg_io_exception & e) {
+                    voiceOK  = false;
+                    SG_LOG(SG_ATC, SG_ALERT, "Unable to load default voice : "
+                                            << e.getFormattedMessage().c_str());
+                    voice = false;
+                    delete v1;
+                    v1 = 0;
+                }
+            }
+#endif
             if(voiceOK) {
                 return(v1);
             }


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev