From 1234f8e42fbcb5da16744deaa62c186778f14184 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Thu, 1 Aug 2019 23:34:58 +0200 Subject: TTS: Fix pause() and resume() on linux --- backends/text-to-speech/linux/linux-text-to-speech.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'backends') 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 c5ff8e0858..c63c4c7dc7 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.cpp +++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp @@ -51,7 +51,10 @@ void speech_end_callback(size_t msg_id, size_t client_id, SPDNotificationType st void speech_cancel_callback(size_t msg_id, size_t client_id, SPDNotificationType state){ LinuxTextToSpeechManager *manager = static_cast (g_system->getTextToSpeechManager()); - manager->updateState(LinuxTextToSpeechManager::READY); + if (manager->isSpeaking()) + manager->updateState(LinuxTextToSpeechManager::READY); + if (manager->isPaused()) + manager->updateState(LinuxTextToSpeechManager::PAUSED); } void speech_resume_callback(size_t msg_id, size_t client_id, SPDNotificationType state){ @@ -170,8 +173,14 @@ bool LinuxTextToSpeechManager::stop() { bool LinuxTextToSpeechManager::pause() { if (_speechState == READY || _speechState == PAUSED || _speechState == BROKEN) return true; + bool result = spd_pause_all(_connection) == -1; + if (result) + return true; + result = spd_stop(_connection) == -1; + if (result) + return true; _speechState = PAUSED; - return spd_pause(_connection) == -1; + return false; } bool LinuxTextToSpeechManager::resume() { -- cgit v1.2.3