[Scummvm-cvs-logs] SF.net SVN: scummvm:[47091] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Jan 6 21:24:56 CET 2010


Revision: 47091
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47091&view=rev
Author:   lordhoto
Date:     2010-01-06 20:24:56 +0000 (Wed, 06 Jan 2010)

Log Message:
-----------
Add a constructor to Timestamp, which allows for specifying seconds + start frames directly.

Modified Paths:
--------------
    scummvm/trunk/sound/timestamp.cpp
    scummvm/trunk/sound/timestamp.h
    scummvm/trunk/test/sound/timestamp.h

Modified: scummvm/trunk/sound/timestamp.cpp
===================================================================
--- scummvm/trunk/sound/timestamp.cpp	2010-01-06 20:22:00 UTC (rev 47090)
+++ scummvm/trunk/sound/timestamp.cpp	2010-01-06 20:24:56 UTC (rev 47091)
@@ -46,7 +46,16 @@
 	_numberOfFrames = (ms % 1000) * _framerate / 1000;
 }
 
+Timestamp::Timestamp(uint s, int frames, int fr) {
+	assert(fr > 0);
 
+	_secs = s;
+	_framerateFactor = 1000 / gcd(1000, fr);
+	_framerate = fr * _framerateFactor;
+	_numberOfFrames = 0;
+	*this = addFrames(frames);
+}
+
 Timestamp Timestamp::convertToFramerate(int newFramerate) const {
 	Timestamp ts(*this);
 

Modified: scummvm/trunk/sound/timestamp.h
===================================================================
--- scummvm/trunk/sound/timestamp.h	2010-01-06 20:22:00 UTC (rev 47090)
+++ scummvm/trunk/sound/timestamp.h	2010-01-06 20:24:56 UTC (rev 47091)
@@ -78,6 +78,14 @@
 	Timestamp(uint32 msecs, int framerate);
 
 	/**
+	 * Set up a timestamp with a given time, frames and framerate.
+	 * @param secs      starting time in seconds
+	 * @param frames    starting frames
+	 * @param framerate number of frames per second (must be > 0)
+	 */
+	Timestamp(uint secs, int frames, int framerate);
+
+	/**
 	 * Return a timestamp which represents as closely as possible
 	 * the point in time describes by this timestamp, but with
 	 * a different framerate.

Modified: scummvm/trunk/test/sound/timestamp.h
===================================================================
--- scummvm/trunk/test/sound/timestamp.h	2010-01-06 20:22:00 UTC (rev 47090)
+++ scummvm/trunk/test/sound/timestamp.h	2010-01-06 20:24:56 UTC (rev 47091)
@@ -89,6 +89,8 @@
 		const Audio::Timestamp a = Audio::Timestamp(500, 1000);
 		Audio::Timestamp b = Audio::Timestamp(0, 1000);
 		Audio::Timestamp c = Audio::Timestamp(0, 100);
+		
+		TS_ASSERT_EQUALS(a, Audio::Timestamp(0, 500, 1000));
 
 		TS_ASSERT(a != b);
 		TS_ASSERT(a != c);


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