[Scummvm-cvs-logs] SF.net SVN: scummvm:[36173] scummvm/trunk/engines/groovie

spookypeanut at users.sourceforge.net spookypeanut at users.sourceforge.net
Sun Feb 1 12:56:12 CET 2009


Revision: 36173
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36173&view=rev
Author:   spookypeanut
Date:     2009-02-01 11:56:12 +0000 (Sun, 01 Feb 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/groovie/music.cpp
    scummvm/trunk/engines/groovie/script.cpp

Modified: scummvm/trunk/engines/groovie/music.cpp
===================================================================
--- scummvm/trunk/engines/groovie/music.cpp	2009-02-01 09:50:41 UTC (rev 36172)
+++ scummvm/trunk/engines/groovie/music.cpp	2009-02-01 11:56:12 UTC (rev 36173)
@@ -175,31 +175,27 @@
 }
 
 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 @@
 		_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 @@
 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::onTimer(void *refCon) {
+	debugC(9, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: onTimer()");
 	MusicPlayer *music = (MusicPlayer *)refCon;
 	Common::StackLock lock(music->_mutex);
 

Modified: scummvm/trunk/engines/groovie/script.cpp
===================================================================
--- scummvm/trunk/engines/groovie/script.cpp	2009-02-01 09:50:41 UTC (rev 36172)
+++ scummvm/trunk/engines/groovie/script.cpp	2009-02-01 11:56:12 UTC (rev 36173)
@@ -581,8 +581,6 @@
 	_mouseClicked = _eventMouseClicked;
 	_eventMouseClicked = false;
 
-	//_vm->_musicPlayer->startBackground();
-
 	// Save the current pressed character for the whole loop
 	_kbdChar = _eventKbdChar;
 	_eventKbdChar = 0;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list