diff options
author | Henry Bush | 2009-02-01 11:56:12 +0000 |
---|---|---|
committer | Henry Bush | 2009-02-01 11:56:12 +0000 |
commit | 6438c40958a09561f785631d8a5dddf0a37f52d0 (patch) | |
tree | 4e88d909bc7593d0d2feabad06872ba0c147c493 | |
parent | 6abcac40de30bb42a16899b0f0dd7f6332fa736f (diff) | |
download | scummvm-rg350-6438c40958a09561f785631d8a5dddf0a37f52d0.tar.gz scummvm-rg350-6438c40958a09561f785631d8a5dddf0a37f52d0.tar.bz2 scummvm-rg350-6438c40958a09561f785631d8a5dddf0a37f52d0.zip |
T7G: Fix for 2474078 (hopefully). Check if volume has fallen to correct level at end of applyfading, in case it gets set to correct level during it.
svn-id: r36173
-rw-r--r-- | engines/groovie/music.cpp | 24 | ||||
-rw-r--r-- | engines/groovie/script.cpp | 2 |
2 files changed, 15 insertions, 11 deletions
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp index 5812d0a9ba..c69ab69827 100644 --- a/engines/groovie/music.cpp +++ b/engines/groovie/music.cpp @@ -175,31 +175,27 @@ void MusicPlayer::setGameVolume(uint16 volume, uint16 time) { } void MusicPlayer::startBackground() { + debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: startBackground()"); if (!_isPlaying && _backgroundFileRef) { + debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the background song (0x%4X)", _backgroundFileRef); play(_backgroundFileRef, true); } } void MusicPlayer::endTrack() { - debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: End of song"); + debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: endTrack()"); unload(); - _isPlaying = false; startBackground(); } void MusicPlayer::applyFading() { + debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: applyFading() _fadingStartTime = %d, _fadingDuration = %d, _fadingStartVolume = %d, _fadingEndVolume = %d", _fadingStartTime, _fadingDuration, _fadingStartVolume, _fadingEndVolume); Common::StackLock lock(_mutex); // Calculate the passed time uint32 time = _vm->_system->getMillis() - _fadingStartTime; + debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: time = %d, _gameVolume = %d", time, _gameVolume); if (time >= _fadingDuration) { - // If we were fading to 0, stop the playback and restore the volume - if (_fadingEndVolume == 0) { - debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Faded to zero: end of song"); - unload(); - _fadingEndVolume = 100; - } - // Set the end volume _gameVolume = _fadingEndVolume; } else { @@ -207,6 +203,14 @@ void MusicPlayer::applyFading() { _gameVolume = (_fadingStartVolume * (_fadingDuration - time) + _fadingEndVolume * time) / _fadingDuration; } + if (_gameVolume == _fadingEndVolume) { + // If we were fading to 0, stop the playback and restore the volume + if (_fadingEndVolume == 0) { + debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Faded to zero: end of song. _fadingEndVolume set to 100"); + _fadingEndVolume = 100; + unload(); + } + } // Apply the new volume to all the channels for (int i = 0; i < 0x10; i++) { @@ -273,6 +277,7 @@ bool MusicPlayer::load(uint16 fileref) { void MusicPlayer::unload() { debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Stopping the playback"); + _isPlaying = false; // Unload the parser _midiParser->unloadMusic(); @@ -359,6 +364,7 @@ void MusicPlayer::metaEvent(byte type, byte *data, uint16 length) { } void MusicPlayer::onTimer(void *refCon) { + debugC(9, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: onTimer()"); MusicPlayer *music = (MusicPlayer *)refCon; Common::StackLock lock(music->_mutex); diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index d2518b85b4..88b2d3e4d9 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -581,8 +581,6 @@ void Script::o_inputloopstart() { _mouseClicked = _eventMouseClicked; _eventMouseClicked = false; - //_vm->_musicPlayer->startBackground(); - // Save the current pressed character for the whole loop _kbdChar = _eventKbdChar; _eventKbdChar = 0; |