diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2017-05-07 23:12:19 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2017-05-07 23:12:19 +0300 |
commit | 44687d58099527a597a5d18447cb8988b9f45763 (patch) | |
tree | e9dd23f91f9a602b22121151c95f9f40a32e7fcd /src/mumble/TextToSpeech_unix.cpp | |
parent | bf7ce38106f03c1ab79e9a7cc4599053e4f3a458 (diff) |
TextToSpeech_unix: make setVolume not initialize speech-dispatcher.
It turns out that TextToSpeech attempts to set the volume on its engines
near initialization time.
This made our lazy-initialization pretty much useless.
This commit tries to remedy that by storing the last value passed to setVolume.
It then uses that stored value the first time speech-dispatcher is initialized.
As a result, we only initialize speech-dispatcher in say(), not setVolume().
Diffstat (limited to 'src/mumble/TextToSpeech_unix.cpp')
-rw-r--r-- | src/mumble/TextToSpeech_unix.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mumble/TextToSpeech_unix.cpp b/src/mumble/TextToSpeech_unix.cpp index a2e5683fc..b5e0125da 100644 --- a/src/mumble/TextToSpeech_unix.cpp +++ b/src/mumble/TextToSpeech_unix.cpp @@ -21,6 +21,9 @@ class TextToSpeechPrivate { #ifdef USE_SPEECHD protected: SPDConnection *spd; + /// Used to store the requested volume of the TextToSpeech object + /// before speech-dispatcher has been initialized. + int volume; bool initialized; void ensureInitialized(); #endif @@ -34,6 +37,7 @@ class TextToSpeechPrivate { #ifdef USE_SPEECHD TextToSpeechPrivate::TextToSpeechPrivate() { initialized = false; + volume = -1; spd = NULL; } @@ -76,6 +80,10 @@ void TextToSpeechPrivate::ensureInitialized() { } initialized = true; + + if (volume != -1) { + setVolume(volume); + } } void TextToSpeechPrivate::say(const QString &txt) { @@ -86,7 +94,10 @@ void TextToSpeechPrivate::say(const QString &txt) { } void TextToSpeechPrivate::setVolume(int vol) { - ensureInitialized(); + if (!initialized) { + volume = vol; + return; + } if (spd) spd_set_volume(spd, vol * 2 - 100); |