]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATC.cxx
Daniyar ATADJANOV:
[flightgear.git] / src / ATC / ATC.cxx
index b95d0008563bb480e0c9ce714acfe989f66798f1..2bc321805619481bed8f0698fdeb42cdfd700693 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
 
 #include <simgear/sound/soundmgr_openal.hxx>
+#include <simgear/structure/exception.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
 #include "ATC.hxx"
-#include "ATCdisplay.hxx"
-#include "voice.hxx"
-
-#ifdef USE_FESTIVAL
-FGVoice *p_Voice = new FGVoice();
-#endif
 
 FGATC::FGATC() {
        freqClear = true;
@@ -113,8 +108,6 @@ void FGATC::Update(double dt) {
                if(_display) {
                        //Render(pending_transmission, ident, false);
                        Render(pending_transmission);
-                       // At the moment Render only works for ATIS
-                       //globals->get_ATC_display()->RegisterSingleMessage(pending_transmission);
                }
                // Run the callback regardless of whether on same freq as user or not.
                //cout << "_callback_code = " << _callback_code << '\n';
@@ -189,7 +182,6 @@ void FGATC::ImmediateTransmit(int callback_code) {
                //Render(pending_transmission, ident, false);
                Render(pending_transmission);
                // At the moment Render doesn't work except for ATIS
-               //globals->get_ATC_display()->RegisterSingleMessage(pending_transmission);
        }
        if(callback_code) {
                ProcessCallback(callback_code);
@@ -236,22 +228,20 @@ void FGATC::Render(string& msg, const string& refname, bool repeating) {
                int len;
                unsigned char* buf = _vPtr->WriteMessage((char*)msg.c_str(), len, _voice);
                if(_voice) {
-                       SGSoundSample *simple
-                            = new SGSoundSample(buf, len, 8000);
-                       // TODO - at the moment the volume is always set off comm1 
-                       // and can't be changed after the transmission has started.
-                       simple->set_volume(5.0 * fgGetDouble("/instrumentation/comm[0]/volume"));
-                       globals->get_soundmgr()->add(simple, refname);
-                       if(repeating) {
-                               globals->get_soundmgr()->play_looped(refname);
-#ifdef USE_FESTIVAL
-                               p_Voice->send_transcript( msg , refname, 1 );
-#endif
-                       } else {
-                               globals->get_soundmgr()->play_once(refname);
-#ifdef USE_FESTIVAL
-                               p_Voice->send_transcript( msg , refname, 0 );
-#endif
+                       try {
+                               SGSoundSample *simple
+                                                               = new SGSoundSample(buf, len, 8000);
+                               // TODO - at the moment the volume is always set off comm1 
+                               // and can't be changed after the transmission has started.
+                               simple->set_volume(5.0 * fgGetDouble("/instrumentation/comm[0]/volume"));
+                               globals->get_soundmgr()->add(simple, refname);
+                               if(repeating) {
+                                       globals->get_soundmgr()->play_looped(refname);
+                               } else {
+                                       globals->get_soundmgr()->play_once(refname);
+                               }
+                       } catch ( sg_io_exception &e ) {
+                               SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage());
                        }
                }
                delete[] buf;
@@ -264,17 +254,6 @@ void FGATC::Render(string& msg, const string& refname, bool repeating) {
                                msg[i] = ' ';
                        }
                }
-               if(repeating) {
-                       globals->get_ATC_display()->RegisterRepeatingMessage(msg);
-#ifdef USE_FESTIVAL
-                       p_Voice->send_transcript( msg , refname, 1 );
-#endif
-               } else {
-                       globals->get_ATC_display()->RegisterSingleMessage(msg);
-#ifdef USE_FESTIVAL
-                       p_Voice->send_transcript( msg, refname, 0 );
-#endif
-               }
        }
        _playing = true;        
 }
@@ -287,12 +266,7 @@ void FGATC::NoRender(const string& refname) {
 #ifdef ENABLE_AUDIO_SUPPORT            
                        globals->get_soundmgr()->stop(refname);
                        globals->get_soundmgr()->remove(refname);
-# ifdef USE_FESTIVAL
-                       p_Voice->send_transcript( "--", refname, 2);
-# endif
 #endif
-               } else {
-                       globals->get_ATC_display()->CancelRepeatingMessage();
                }
                _playing = false;
        }