diff options
author | Jaromir Wysoglad | 2019-07-23 17:54:31 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-09-01 22:47:55 +0300 |
commit | 58065ceacda18dbae0e72d19ece6438ab06a332b (patch) | |
tree | 5a2ff7a8e710e29f7e1d69b49808a26dc659c57e | |
parent | 4ec10ffec786be030a358e1b5499a6b856092e81 (diff) | |
download | scummvm-rg350-58065ceacda18dbae0e72d19ece6438ab06a332b.tar.gz scummvm-rg350-58065ceacda18dbae0e72d19ece6438ab06a332b.tar.bz2 scummvm-rg350-58065ceacda18dbae0e72d19ece6438ab06a332b.zip |
TTS: Refactoring
* Delete multiple empty rows
* Make getVolume non-virtual and leave just the implementation
in base class
* Resolve warning about signed / unsigned comparison in
gui-manager
* Clear availableVoices when updating voices on linux
* By default set language to transMan language on windows
(if the transMan is available)
* Remove freeVoices method from Windows ttsMan, it isn't needed
anymore
-rw-r--r-- | backends/text-to-speech/linux/linux-text-to-speech.cpp | 7 | ||||
-rw-r--r-- | backends/text-to-speech/linux/linux-text-to-speech.h | 1 | ||||
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.cpp | 19 | ||||
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.h | 2 | ||||
-rw-r--r-- | common/text-to-speech.h | 2 | ||||
-rw-r--r-- | gui/gui-manager.cpp | 2 | ||||
-rw-r--r-- | gui/gui-manager.h | 1 | ||||
-rw-r--r-- | gui/options.cpp | 1 | ||||
-rw-r--r-- | gui/options.h | 1 |
9 files changed, 10 insertions, 26 deletions
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 3914b0f347..8c797d7cb2 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.cpp +++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp @@ -182,7 +182,6 @@ bool LinuxTextToSpeechManager::say(Common::String str, Common::String charset) { return true; } return false; - } bool LinuxTextToSpeechManager::stop() { @@ -248,10 +247,6 @@ void LinuxTextToSpeechManager::setVolume(unsigned volume) { _ttsState->_volume = volume; } -int LinuxTextToSpeechManager::getVolume() { - return (_ttsState->_volume - 50) * 2; -} - void LinuxTextToSpeechManager::setLanguage(Common::String language) { if (_speechState == BROKEN) return; @@ -278,6 +273,7 @@ void LinuxTextToSpeechManager::updateVoices() { it depends on the user to map them to the right voices in speech-dispatcher configuration */ + _ttsState->_availableVoices.clear(); char **voiceInfo = spd_list_voices(_connection); @@ -294,7 +290,6 @@ void LinuxTextToSpeechManager::updateVoices() { free(voiceInfo[i]); free(voiceInfo); - } void LinuxTextToSpeechManager::freeVoiceData(void *data) { 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 a6994f7f40..fe7eab8ed5 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.h +++ b/backends/text-to-speech/linux/linux-text-to-speech.h @@ -59,7 +59,6 @@ public: virtual void setPitch(int pitch); virtual void setVolume(unsigned volume); - virtual int getVolume(); virtual void setLanguage(Common::String language); 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 d102300028..f5c88ff12d 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.cpp +++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp @@ -76,7 +76,13 @@ void WindowsTextToSpeechManager::init() { warning("Could not initialize TTS voice"); return; } + +#ifdef USE_TRANSLATION + setLanguage(TransMan.getCurrentLanguage()); +#else setLanguage("en"); +#endif + _voice->SetOutput(_audio, FALSE); if(_ttsState->_availableVoices.size() > 0) @@ -86,7 +92,6 @@ void WindowsTextToSpeechManager::init() { } WindowsTextToSpeechManager::~WindowsTextToSpeechManager() { - freeVoices(); if (_voice) _voice->Release(); ::CoUninitialize(); @@ -207,16 +212,6 @@ void WindowsTextToSpeechManager::setVolume(unsigned volume) { _ttsState->_volume = volume; } -int WindowsTextToSpeechManager::getVolume() { - return _ttsState->_volume; -} - -void WindowsTextToSpeechManager::freeVoices() { - _ttsState->_availableVoices.clear(); - // The voice data gets freed automaticly, when the reference counting inside TTSVoice - // reaches 0, so there is no point in trying to free it here -} - void WindowsTextToSpeechManager::setLanguage(Common::String language) { if (language == "C") language = "en"; @@ -322,7 +317,7 @@ Common::String WindowsTextToSpeechManager::lcidToLocale(Common::String lcid) { } void WindowsTextToSpeechManager::updateVoices() { - freeVoices(); + _ttsState->_availableVoices.clear(); HRESULT hr = S_OK; ISpObjectToken *cpVoiceToken = nullptr; IEnumSpObjectTokens *cpEnum = nullptr; diff --git a/backends/text-to-speech/windows/windows-text-to-speech.h b/backends/text-to-speech/windows/windows-text-to-speech.h index 87e4ceb218..f60a59de71 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.h +++ b/backends/text-to-speech/windows/windows-text-to-speech.h @@ -60,7 +60,6 @@ public: virtual void setPitch(int pitch); virtual void setVolume(unsigned volume); - virtual int getVolume(); virtual void setLanguage(Common::String language); @@ -70,7 +69,6 @@ private: void init(); virtual void updateVoices(); void createVoice(void *cpVoiceToken); - void freeVoices(); Common::String lcidToLocale(Common::String lcid); SpeechState _speechState; }; diff --git a/common/text-to-speech.h b/common/text-to-speech.h index 9662783b46..678810a741 100644 --- a/common/text-to-speech.h +++ b/common/text-to-speech.h @@ -228,7 +228,7 @@ public: /** * Returns the current voice volume */ - virtual int getVolume() { return _ttsState->_volume; } + int getVolume() { return _ttsState->_volume; } /** * Sets the speech language diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 9f4af81e42..2541752001 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -641,7 +641,7 @@ void GuiManager::initTextToSpeech() { volume = 0; ttsMan->setVolume(volume); - int voice; + unsigned voice; if(ConfMan.hasKey("tts_voice")) voice = ConfMan.getInt("tts_voice", "scummvm"); else diff --git a/gui/gui-manager.h b/gui/gui-manager.h index 880c94d436..f97d52794a 100644 --- a/gui/gui-manager.h +++ b/gui/gui-manager.h @@ -177,7 +177,6 @@ protected: void giveFocusToDialog(Dialog *dialog); void setLastMousePos(int16 x, int16 y); - }; } // End of namespace GUI diff --git a/gui/options.cpp b/gui/options.cpp index 507ae34176..68053dd4bc 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -426,7 +426,6 @@ void OptionsDialog::build() { _subSpeedSlider->setValue(speed); _subSpeedLabel->setValue(speed); } - } void OptionsDialog::clean() { diff --git a/gui/options.h b/gui/options.h index 76ad4ef082..559ecbecde 100644 --- a/gui/options.h +++ b/gui/options.h @@ -223,7 +223,6 @@ private: CheckboxWidget *_muteCheckbox; - protected: // // Game GUI options |