aboutsummaryrefslogtreecommitdiff
path: root/backends/text-to-speech/windows
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-09-05 03:36:16 +0200
committerThierry Crozat2019-09-05 23:52:46 +0100
commitba859f1eeda287214e90358b71728c594e2be652 (patch)
treef4e26db26e02c8cea5005961d31131b6623b7f64 /backends/text-to-speech/windows
parent8f930126e7de6db9c22ff9f02d52564c4c99a9a8 (diff)
downloadscummvm-rg350-ba859f1eeda287214e90358b71728c594e2be652.tar.gz
scummvm-rg350-ba859f1eeda287214e90358b71728c594e2be652.tar.bz2
scummvm-rg350-ba859f1eeda287214e90358b71728c594e2be652.zip
TTS: Minimize the time needed for stop() on Win32
This gets rid of freezes when using TTS on Windows.
Diffstat (limited to 'backends/text-to-speech/windows')
-rw-r--r--backends/text-to-speech/windows/windows-text-to-speech.cpp10
1 files changed, 4 insertions, 6 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 a59f21952b..ceca3e4566 100644
--- a/backends/text-to-speech/windows/windows-text-to-speech.cpp
+++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp
@@ -231,18 +231,16 @@ bool WindowsTextToSpeechManager::stop() {
resume();
_audio->SetState(SPAS_STOP, 0);
WaitForSingleObject(_speechMutex, INFINITE);
+ // Delete the speech queue
while (!_speechQueue.empty()) {
if (_speechQueue.front() != NULL)
free(_speechQueue.front());
_speechQueue.pop_front();
}
- _speechQueue.push_back(NULL);
+ // Stop the current speech
+ _voice->Speak(NULL, SPF_PURGEBEFORESPEAK | SPF_ASYNC, 0);
+ _speechState = READY;
ReleaseMutex(_speechMutex);
- if (_thread != NULL) {
- WaitForSingleObject(_thread, INFINITE);
- CloseHandle(_thread);
- _thread = NULL;
- }
_audio->SetState(SPAS_RUN, 0);
return false;
}