From e3d1ec482c510d0b7a851cb0d2a675bad79a2ec9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 21 Jul 2010 20:12:35 +0000 Subject: LURE: Make LURE respect the mute settings. svn-id: r51101 --- engines/lure/game.cpp | 2 -- engines/lure/game.h | 4 ---- engines/lure/sound.cpp | 23 ++++++++++++++--------- engines/lure/sound.h | 14 ++++++++++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index 5d2f0e8ed1..e77ac25716 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -56,8 +56,6 @@ Game::Game() { _debugFlag = gDebugLevel >= ERROR_BASIC; _soundFlag = true; - _musicVolume = ConfMan.getBool("music_mute") ? 0 : MIN(255, ConfMan.getInt("music_volume")); - _sfxVolume = ConfMan.getBool("sfx_mute") ? 0 : MIN(255, ConfMan.getInt("sfx_volume")); } Game::~Game() { diff --git a/engines/lure/game.h b/engines/lure/game.h index 3864e9c205..123ac0dca7 100644 --- a/engines/lure/game.h +++ b/engines/lure/game.h @@ -48,8 +48,6 @@ class Game { private: Debugger *_debugger; bool _fastTextFlag, _soundFlag; - uint8 _sfxVolume; - uint8 _musicVolume; uint8 _state; uint16 _tellCommands[MAX_TELL_COMMANDS * 3 + 1]; int _numTellCommands; @@ -87,8 +85,6 @@ public: bool &debugFlag() { return _debugFlag; } bool fastTextFlag() { return _fastTextFlag; } bool soundFlag() { return _soundFlag; } - uint8 sfxVolume() { return ConfMan.getInt("sfx_volume"); } - uint8 musicVolume() { return ConfMan.getInt("music_volume"); } Debugger &debugger() { return *_debugger; } // Menu item support methods diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index cd539dfab4..a75545c330 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -72,6 +72,8 @@ SoundManager::SoundManager() { _channelsInner[index].volume = 90; } } + + syncSounds(); } SoundManager::~SoundManager() { @@ -288,16 +290,21 @@ uint8 SoundManager::descIndexOf(uint8 soundNumber) { // Used to sync the volume for all channels with the Config Manager // void SoundManager::syncSounds() { - Game &game = Game::getReference(); musicInterface_TidySounds(); + bool mute = false; + if (ConfMan.hasKey("mute")) + mute = ConfMan.getBool("mute"); + _musicVolume = mute ? 0 : MIN(255, ConfMan.getInt("music_volume")); + _sfxVolume = mute ? 0 : MIN(255, ConfMan.getInt("sfx_volume")); + g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { if ((*i)->isMusic()) - (*i)->setVolume(game.musicVolume()); + (*i)->setVolume(_musicVolume); else - (*i)->setVolume(game.sfxVolume()); + (*i)->setVolume(_sfxVolume); } g_system->unlockMutex(_soundMutex); } @@ -599,9 +606,9 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], } if (_isMusic) - setVolume(ConfMan.getInt("music_volume")); + setVolume(Sound.musicVolume()); else - setVolume(ConfMan.getInt("sfx_volume")); + setVolume(Sound.sfxVolume()); _passThrough = false; @@ -658,8 +665,7 @@ void MidiMusic::setVolume(int volume) { _volume = volume; - Game &game = Game::getReference(); - volume *= _isMusic ? game.musicVolume() : game.sfxVolume(); + volume *= _isMusic ? Sound.musicVolume() : Sound.sfxVolume(); for (int i = 0; i < _numChannels; ++i) { if (_channels[_channelNumber + i].midiChannel != NULL) @@ -707,8 +713,7 @@ void MidiMusic::send(uint32 b) { // Adjust volume changes by song and master volume byte volume = (byte)((b >> 16) & 0x7F); _channels[channel].volume = volume; - Game &game = Game::getReference(); - int master_volume = _isMusic ? game.musicVolume() : game.sfxVolume(); + int master_volume = _isMusic ? Sound.musicVolume() : Sound.sfxVolume(); volume = volume * _volume * master_volume / 65025; b = (b & 0xFF00FFFF) | (volume << 16); } else if ((b & 0xF0) == 0xC0) { diff --git a/engines/lure/sound.h b/engines/lure/sound.h index c41cec48fe..6d248fbd20 100644 --- a/engines/lure/sound.h +++ b/engines/lure/sound.h @@ -105,7 +105,7 @@ public: bool isMusic() {return _isMusic; } }; -class SoundManager: public Common::Singleton { +class SoundManager : public Common::Singleton { private: // Outer sound interface properties MemoryBlock *_descs; @@ -128,11 +128,15 @@ private: Common::MutexRef _soundMutex; bool _paused; + uint _musicVolume; + uint _sfxVolume; + // Internal support methods void bellsBodge(); void musicInterface_TidySounds(); static void onTimer(void *data); void doTimer(); + public: SoundManager(); ~SoundManager(); @@ -156,9 +160,11 @@ public: void fadeOut(); void pause() { _paused = true; } void resume() { _paused = false; } - bool getPaused() { return _paused; } - bool hasNativeMT32() { return _nativeMT32; } - bool isRoland() { return _isRoland; } + bool getPaused() const { return _paused; } + bool hasNativeMT32() const { return _nativeMT32; } + bool isRoland() const { return _isRoland; } + uint musicVolume() const { return _musicVolume; } + uint sfxVolume() const { return _sfxVolume; } // The following methods implement the external sound player module void musicInterface_Initialise(); -- cgit v1.2.3