[Scummvm-cvs-logs] SF.net SVN: scummvm:[47029] scummvm/trunk/sound/mixer.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Jan 5 19:32:31 CET 2010


Revision: 47029
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47029&view=rev
Author:   lordhoto
Date:     2010-01-05 18:32:26 +0000 (Tue, 05 Jan 2010)

Log Message:
-----------
- Fix a bug in Channel::pause for recursive pausing.
- Fix bug in Channel:getElapsedTime, when called while the channel is paused.

Modified Paths:
--------------
    scummvm/trunk/sound/mixer.cpp

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2010-01-05 14:59:43 UTC (rev 47028)
+++ scummvm/trunk/sound/mixer.cpp	2010-01-05 18:32:26 UTC (rev 47029)
@@ -79,15 +79,19 @@
 	void pause(bool paused) {
 		//assert((paused && _pauseLevel >= 0) || (!paused && _pauseLevel));
 
-		if (paused)
+		if (paused) {
 			_pauseLevel++;
-		else if (_pauseLevel > 0)
+
+			if (_pauseLevel == 1)
+				_pauseStartTime = g_system->getMillis();
+		} else if (_pauseLevel > 0) {
 			_pauseLevel--;
 
-		if (_pauseLevel > 0)
-			_pauseStartTime = g_system->getMillis();
-		else
-			_pauseTime += (g_system->getMillis() - _pauseStartTime);
+			if (!_pauseLevel) {
+				_pauseTime = (g_system->getMillis() - _pauseStartTime);
+				_pauseStartTime = 0;
+			}
+		}
 	}
 	bool isPaused() {
 		return _pauseLevel != 0;
@@ -441,7 +445,6 @@
 		_samplesConsumed = _samplesDecoded;
 		_mixerTimeStamp = g_system->getMillis();
 		_pauseTime = 0;
-
 		_samplesDecoded += _converter->flow(*_input, data, len, vol_l, vol_r);
 	}
 }
@@ -451,8 +454,13 @@
 		return 0;
 
 	const uint32 rate = _mixer->getOutputRate();
-	const uint32 delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime;
+	uint32 delta = 0;
 
+	if (isPaused())
+		delta = _pauseStartTime - _mixerTimeStamp;
+	else
+		delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime;
+
 	// Convert the number of samples into a time duration.
 
 	Audio::Timestamp ts(0, rate);


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