diff options
| author | Jaromir Wysoglad | 2019-07-22 17:19:52 -0700 |
|---|---|---|
| committer | Filippos Karapetis | 2019-09-01 22:47:55 +0300 |
| commit | 063107083340c9572250c75347ff4b7880a1770b (patch) | |
| tree | c4a1f3ca03647c119ba5536142c1abe0dd7d28bf | |
| parent | e4363ba2292cb2e1c1a02e7dcdb1914f469efe0b (diff) | |
| download | scummvm-rg350-063107083340c9572250c75347ff4b7880a1770b.tar.gz scummvm-rg350-063107083340c9572250c75347ff4b7880a1770b.tar.bz2 scummvm-rg350-063107083340c9572250c75347ff4b7880a1770b.zip | |
TTS: Fix state switching on windows
Voice is changed when changing language on windows, so when poping
state, the voice, that should get set has to be saved before
changing the language.
The speech shouldn't continue when changing state, so it is stopped
in pushState and popState.
| -rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.cpp | 1 | ||||
| -rw-r--r-- | common/text-to-speech.cpp | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/backends/text-to-speech/windows/windows-text-to-speech.cpp b/backends/text-to-speech/windows/windows-text-to-speech.cpp index 58389e5141..d102300028 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.cpp +++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp @@ -181,6 +181,7 @@ void WindowsTextToSpeechManager::setVoice(unsigned index) { if(_speechState == BROKEN || _speechState == NO_VOICE) return; _voice->SetVoice((ISpObjectToken *) _ttsState->_availableVoices[index].getData()); + _ttsState->_activeVoice = index; } void WindowsTextToSpeechManager::setRate(int rate) { diff --git a/common/text-to-speech.cpp b/common/text-to-speech.cpp index 9289cba214..f9dc4c69aa 100644 --- a/common/text-to-speech.cpp +++ b/common/text-to-speech.cpp @@ -98,6 +98,7 @@ TextToSpeechManager::~TextToSpeechManager() { } void TextToSpeechManager::pushState() { + stop(); TTSState *newState = new TTSState; newState->_pitch = _ttsState->_pitch; newState->_volume = _ttsState->_volume; @@ -110,6 +111,7 @@ void TextToSpeechManager::pushState() { } bool TextToSpeechManager::popState() { + stop(); if (_ttsState->_next == nullptr) return true; @@ -118,11 +120,13 @@ bool TextToSpeechManager::popState() { delete oldState; + // The voice has to be saved, because some backends change it when changing language + int voice = _ttsState->_activeVoice; setLanguage(_ttsState->_language); setPitch(_ttsState->_pitch); setVolume(_ttsState->_volume); setRate(_ttsState->_rate); - setVoice(_ttsState->_activeVoice); + setVoice(voice); return false; } |
