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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Jan 4 23:48:52 CET 2010


Revision: 46995
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46995&view=rev
Author:   fingolfin
Date:     2010-01-04 22:48:52 +0000 (Mon, 04 Jan 2010)

Log Message:
-----------
Switch Channel::getElapsedTime() to use a Timestamp for its computations

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

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2010-01-04 22:48:28 UTC (rev 46994)
+++ scummvm/trunk/sound/mixer.cpp	2010-01-04 22:48:52 UTC (rev 46995)
@@ -29,6 +29,7 @@
 #include "sound/mixer_intern.h"
 #include "sound/rate.h"
 #include "sound/audiostream.h"
+#include "sound/timestamp.h"
 
 
 namespace Audio {
@@ -451,15 +452,15 @@
 	if (_mixerTimeStamp == 0)
 		return 0;
 
-	// Convert the number of samples into a time duration. To avoid
-	// overflow, this has to be done in a somewhat non-obvious way.
+	const uint32 rate = _mixer->getOutputRate();
+	const uint32 delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime;
 
-	uint32 rate = _mixer->getOutputRate();
+	// Convert the number of samples into a time duration.
 
-	uint32 seconds = _samplesConsumed / rate;
-	uint32 milliseconds = (1000 * (_samplesConsumed % rate)) / rate;
+	Audio::Timestamp ts(0, rate);
 
-	uint32 delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime;
+	ts = ts.addFrames(_samplesConsumed);
+	ts = ts.addMsecs(delta);
 
 	// In theory it would seem like a good idea to limit the approximation
 	// so that it never exceeds the theoretical upper bound set by
@@ -467,7 +468,7 @@
 	// the Broken Sword cutscenes noticeably jerkier. I guess the mixer
 	// isn't invoked at the regular intervals that I first imagined.
 
-	return 1000 * seconds + milliseconds + delta;
+	return ts.msecs();
 }
 
 


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