From be5c865c508c93f6910468a07d3947237e7e0a8e Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Fri, 9 Aug 2019 00:45:02 +0200 Subject: TTS: Add proper speech queuing, update INT_NO_REP. Before I used SPD to queue messages and I had a copy of the queue, so I could requeue everything when resume is called(). But more control of the queue is needed, so I don't use the SPD's queue and instead start speeches from my queue one by one from another thread. INTERRUPT_NO_REPEAT now behaves as described in the documentation --- backends/text-to-speech/linux/linux-text-to-speech.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'backends/text-to-speech/linux/linux-text-to-speech.h') 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 23c35c33f6..33f15daccb 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.h +++ b/backends/text-to-speech/linux/linux-text-to-speech.h @@ -30,6 +30,12 @@ #include "common/text-to-speech.h" #include "common/str.h" #include "common/list.h" +#include "common/mutex.h" + +struct StartSpeechParams { + pthread_mutex_t *mutex; + Common::List *speechQueue; +}; class LinuxTextToSpeechManager : public Common::TextToSpeechManager { public: @@ -62,13 +68,9 @@ public: virtual bool isReady(); virtual void setVoice(unsigned index); - virtual void setRate(int rate); - virtual void setPitch(int pitch); - virtual void setVolume(unsigned volume); - virtual void setLanguage(Common::String language); void updateState(SpeechEvent event); @@ -80,11 +82,14 @@ private: virtual void updateVoices(); void createVoice(int typeNumber, Common::TTSVoice::Gender, Common::TTSVoice::Age, char *description); Common::String strToUtf8(Common::String str, Common::String charset); - bool spdSay(const char *str); + static void *startSpeech(void *p); + StartSpeechParams _params; SpeechState _speechState; - Common::String _lastSaid; Common::List _speechQueue; + pthread_mutex_t _speechMutex; + pthread_t _thread; + bool _threadCreated; }; #endif -- cgit v1.2.3