aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-07-12 00:46:42 +0200
committerFilippos Karapetis2019-09-01 22:47:55 +0300
commit62a011e28a4a7e253ad07319cef760566cba59cb (patch)
treee1e45440cbc2825adfb88097380c1c35dd1d68b0 /common
parent7f895d21df5ddb7c82a2f685d3a9fcc09b3d3a7a (diff)
downloadscummvm-rg350-62a011e28a4a7e253ad07319cef760566cba59cb.tar.gz
scummvm-rg350-62a011e28a4a7e253ad07319cef760566cba59cb.tar.bz2
scummvm-rg350-62a011e28a4a7e253ad07319cef760566cba59cb.zip
TTS: Add ttsStatus push and pop functions
Diffstat (limited to 'common')
-rw-r--r--common/text-to-speech.cpp35
-rw-r--r--common/text-to-speech.h9
2 files changed, 40 insertions, 4 deletions
diff --git a/common/text-to-speech.cpp b/common/text-to-speech.cpp
index 1e2456d8a6..459d4706db 100644
--- a/common/text-to-speech.cpp
+++ b/common/text-to-speech.cpp
@@ -30,7 +30,8 @@ TextToSpeechManager::TextToSpeechManager() {
_ttsState->_pitch = 0;
_ttsState->_volume = 0;
_ttsState->_rate = 0;
- _ttsState->_activeVoice = nullptr;
+ _ttsState->_activeVoice = 0;
+ _ttsState->_language = "en";
_ttsState->_next = nullptr;
}
@@ -46,5 +47,37 @@ TextToSpeechManager::~TextToSpeechManager() {
}
}
+void TextToSpeechManager::pushState() {
+ TTSState *newState = new TTSState;
+ newState->_pitch = _ttsState->_pitch;
+ newState->_volume = _ttsState->_volume;
+ newState->_rate = _ttsState->_rate;
+ newState->_activeVoice = _ttsState->_activeVoice;
+ newState->_language = _ttsState->_language;
+ newState->_next = _ttsState;
+ _ttsState = newState;
+ updateVoices();
+}
+
+bool TextToSpeechManager::popState() {
+ if (_ttsState->_next == nullptr)
+ return true;
+
+ for (TTSVoice *i = _ttsState->_availaibleVoices.begin(); i < _ttsState->_availaibleVoices.end(); i++) {
+ free(i->_data);
+ }
+
+ TTSState *oldState = _ttsState;
+ _ttsState = _ttsState->_next;
+
+ delete oldState;
+
+ setLanguage(_ttsState->_language);
+ setPitch(_ttsState->_pitch);
+ setVolume(_ttsState->_volume);
+ setRate(_ttsState->_rate);
+ return false;
+}
+
}
#endif
diff --git a/common/text-to-speech.h b/common/text-to-speech.h
index 4bb81118bf..2c9b5c7778 100644
--- a/common/text-to-speech.h
+++ b/common/text-to-speech.h
@@ -63,7 +63,7 @@ struct TTSState {
int _pitch;
int _volume;
String _language;
- TTSVoice *_activeVoice;
+ int _activeVoice;
Array<TTSVoice> _availaibleVoices;
TTSState *_next;
};
@@ -87,8 +87,8 @@ public:
virtual bool isPaused() { return false; }
virtual bool isReady() { return false; }
- virtual void setVoice(TTSVoice *voice) {}
- TTSVoice getVoice() { return *(_ttsState->_activeVoice); }
+ virtual void setVoice(unsigned index) {}
+ TTSVoice getVoice() { return _ttsState->_availaibleVoices[_ttsState->_activeVoice]; }
virtual void setRate(int rate) {}
int getRate() { return _ttsState->_rate; }
@@ -104,6 +104,9 @@ public:
Array<TTSVoice> getVoicesArray() { return _ttsState->_availaibleVoices; }
+ void pushState();
+ bool popState();
+
protected:
TTSState *_ttsState;