From e801e83f4385b4c4652fa30b66af4b396e45c0da Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Sun, 14 Jul 2019 21:01:37 +0200 Subject: TTS: Restart spd connection on speak error. --- backends/text-to-speech/linux/linux-text-to-speech.cpp | 13 ++++++++++++- backends/text-to-speech/linux/linux-text-to-speech.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'backends/text-to-speech') diff --git a/backends/text-to-speech/linux/linux-text-to-speech.cpp b/backends/text-to-speech/linux/linux-text-to-speech.cpp index 110bb8396e..3445ca972a 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.cpp +++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp @@ -65,6 +65,10 @@ void speech_pause_callback(size_t msg_id, size_t client_id, SPDNotificationType LinuxTextToSpeechManager::LinuxTextToSpeechManager() : _speechState(READY) { + init(); +} + +void LinuxTextToSpeechManager::init() { _connection = spd_open("ScummVM", "main", NULL, SPD_MODE_THREADED); if (_connection == 0) { _speechState = BROKEN; @@ -103,7 +107,14 @@ bool LinuxTextToSpeechManager::say(Common::String str) { if (isSpeaking()) stop(); debug("say: %s", str.c_str()); - return spd_say(_connection, SPD_MESSAGE, str.c_str()) == -1; + if(spd_say(_connection, SPD_MESSAGE, str.c_str()) == -1) { + //restart the connection + if (_connection != 0) + spd_close(_connection); + init(); + return true; + } + return false; } diff --git a/backends/text-to-speech/linux/linux-text-to-speech.h b/backends/text-to-speech/linux/linux-text-to-speech.h index 41c4a64d28..d08da49425 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.h +++ b/backends/text-to-speech/linux/linux-text-to-speech.h @@ -66,6 +66,7 @@ public: void updateState(SpeechState state); private: + void init(); virtual void updateVoices(); void createVoice(int typeNumber, Common::TTSVoice::Gender, char *description); SpeechState _speechState; -- cgit v1.2.3