GLK: Add speech volume synchronization

This commit is contained in:
Thierry Crozat 2020-06-22 00:17:01 +01:00
parent 5f34aaa52b
commit 98bc3f45bd
3 changed files with 19 additions and 1 deletions

View File

@ -38,6 +38,7 @@
#include "glk/screen.h"
#include "glk/selection.h"
#include "glk/sound.h"
#include "glk/speech.h"
#include "glk/streams.h"
#include "glk/windows.h"
@ -271,6 +272,8 @@ void GlkEngine::syncSoundSettings() {
int volume = ConfMan.getBool("sfx_mute") ? 0 : CLIP(ConfMan.getInt("sfx_volume"), 0, 255);
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, volume);
SpeechManager::syncSoundSettings();
}
void GlkEngine::beep() {

View File

@ -51,6 +51,19 @@ void SpeechManager::releaseSpeechManagerInstance() {
}
}
void SpeechManager::syncSoundSettings() {
#if defined(USE_TTS)
debugC(kDebugSpeech, "SpeechManager::syncSoundSettings");
if (_instance && _instance->_ttsMan) {
int volume = (ConfMan.getInt("speech_volume") * 100) / 256;
if (ConfMan.hasKey("mute") && ConfMan.getBool("mute"))
volume = 0;
debugC(kDebugSpeech, "Set speech volume to %d", volume);
_instance->_ttsMan->setVolume(volume);
}
#endif
}
SpeechManager::SpeechManager() :
_refCount(0)
#if defined(USE_TTS)
@ -68,7 +81,7 @@ SpeechManager::SpeechManager() :
_ttsMan->setLanguage(ConfMan.get("language"));
// Volume
int volume = (ConfMan.getInt("speech_volume") * 100) / 256;
if (ConfMan.hasKey("mute", "scummvm") && ConfMan.getBool("mute", "scummvm"))
if (ConfMan.hasKey("mute") && ConfMan.getBool("mute"))
volume = 0;
_ttsMan->setVolume(volume);
// Voice

View File

@ -45,6 +45,8 @@ public:
void purgeSpeech(Speech *);
void addSpeech(const uint32 *buf, size_t len, Speech *);
static void syncSoundSettings();
private:
SpeechManager();
~SpeechManager();