]> git.mxchange.org Git - flightgear.git/commitdiff
- reduce timeout
authormfranz <mfranz>
Fri, 31 Mar 2006 10:12:00 +0000 (10:12 +0000)
committermfranz <mfranz>
Fri, 31 Mar 2006 10:12:00 +0000 (10:12 +0000)
- stop trying to connect after first failed attempt

src/Sound/voice.cxx
src/Sound/voice.hxx

index ae23ae88b7738cad042b0525d21eea406d0d57a4..de77cbdf157872aa3654017ff8c63fae1e33a2fd 100644 (file)
@@ -63,8 +63,12 @@ void FGVoiceMgr::init()
 
        SGPropertyNode *base = fgGetNode(VOICE, true);
        vector<SGPropertyNode_ptr> voices = base->getChildren("voice");
-       for (unsigned int i = 0; i < voices.size(); i++)
-               _voices.push_back(new FGVoice(this, voices[i]));
+       try {
+               for (unsigned int i = 0; i < voices.size(); i++)
+                       _voices.push_back(new FGVoice(this, voices[i]));
+       } catch (const string& s) {
+               SG_LOG(SG_IO, SG_ALERT, "VOICE: " << s);
+       }
 
 #if defined(ENABLE_THREADS)
        _thread->start(1);
@@ -105,28 +109,20 @@ FGVoiceMgr::FGVoice::FGVoice(FGVoiceMgr *mgr, const SGPropertyNode_ptr node) :
        const string &port = _mgr->_port;
 
        _sock = new SGSocket(host, port, "tcp");
-       _sock->set_timeout(10000);
-       _connected = _sock->open(SG_IO_OUT);
-       if (!_connected) {
-               SG_LOG(SG_IO, SG_ALERT, "VOICE: no connection to `"
-                               << host << ':' << port << '\'');
-               return;
-       }
+       _sock->set_timeout(6000);
+       if (!_sock->open(SG_IO_OUT))
+               throw string("no connection to `") + host + ':' + port + '\'';
 
        if (_festival) {
                _sock->writestring("(SayText \"\")\015\012");
                char buf[4];
                int len = _sock->read(buf, 3);
-               if (len != 3 || buf[0] != 'L' || buf[1] != 'P') {
-                       SG_LOG(SG_IO, SG_ALERT, "VOICE: unexpected or no response from `"
-                                       << host << ':' << port << "'. Either it's not " << endl
-                                       << "       Festival listening, or Festival couldn't open a "
-                                       "sound device.");
-                       _connected = false;
-                       return;
-               }
-
-               SG_LOG(SG_IO, SG_BULK, "VOICE: connection to Festival server on `"
+               if (len != 3 || buf[0] != 'L' || buf[1] != 'P')
+                       throw string("unexpected or no response from `") + host + ':' + port
+                                       + "'. Either it's not\n       Festival listening,"
+                                       " or Festival couldn't open a sound device.";
+
+               SG_LOG(SG_IO, SG_INFO, "VOICE: connection to Festival server on `"
                                << host << ':' << port << "' established");
 
                setVolume(_volume = _volumeNode->getDoubleValue());
@@ -175,7 +171,7 @@ bool FGVoiceMgr::FGVoice::speak(void)
 
 void FGVoiceMgr::FGVoice::update(void)
 {
-       if (_connected && _festival) {
+       if (_festival) {
                double d;
                d = _volumeNode->getDoubleValue();
                if (d != _volume)
index ae899476e31b6e92b6a0e03e8136833b0d0e37b4..b059df179bfae43242289f9a8a321ba1d5adc65a 100644 (file)
@@ -104,7 +104,6 @@ public:
 private:
        class FGVoiceListener;
        SGSocket *_sock;
-       bool _connected;
        double _volume;
        double _pitch;
        double _speed;