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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Jan 6 16:33:55 CET 2010


Revision: 47081
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47081&view=rev
Author:   lordhoto
Date:     2010-01-06 15:33:54 +0000 (Wed, 06 Jan 2010)

Log Message:
-----------
- Add some functionallity to query the seconds and number of frames stored in a Timestamp.
- Add tests for these

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

Modified: scummvm/trunk/sound/timestamp.h
===================================================================
--- scummvm/trunk/sound/timestamp.h	2010-01-06 15:23:33 UTC (rev 47080)
+++ scummvm/trunk/sound/timestamp.h	2010-01-06 15:33:54 UTC (rev 47081)
@@ -129,6 +129,17 @@
 	/** Return the framerate used by this timestamp. */
 	int getFramerate() const { return _framerate / _framerateFactor; }
 
+	/**
+	 * Determines the time in seconds described by this timestamp,
+	 * rounded down.
+	 */
+	uint32 secs() const { return _secs; }
+
+	/**
+	 * Determines the frames described by this timestamp.
+	 */
+	int getNumberOfFrames() const { return _numberOfFrames / _framerateFactor; }
+
 protected:
 
 	int cmp(const Timestamp &ts) const;

Modified: scummvm/trunk/test/sound/timestamp.h
===================================================================
--- scummvm/trunk/test/sound/timestamp.h	2010-01-06 15:23:33 UTC (rev 47080)
+++ scummvm/trunk/test/sound/timestamp.h	2010-01-06 15:33:54 UTC (rev 47081)
@@ -143,10 +143,27 @@
 		const Audio::Timestamp c = Audio::Timestamp(500, 100);
 		const Audio::Timestamp d = Audio::Timestamp(500, 44100);
 
-
 		TS_ASSERT_EQUALS(a.getFramerate(), 1000);
 		TS_ASSERT_EQUALS(b.getFramerate(), 67);
 		TS_ASSERT_EQUALS(c.getFramerate(), 100);
 		TS_ASSERT_EQUALS(d.getFramerate(), 44100);
 	}
+
+	void test_direct_query() {
+		const Audio::Timestamp a = Audio::Timestamp(0, 22050);
+		const Audio::Timestamp b = a.addFrames(11025);
+		const Audio::Timestamp c = Audio::Timestamp(1500, 22050);
+
+		TS_ASSERT_EQUALS(a.secs(), (uint32)0);
+		TS_ASSERT_EQUALS(a.msecs(), (uint32)0);
+		TS_ASSERT_EQUALS(a.getNumberOfFrames(), 0);
+
+		TS_ASSERT_EQUALS(b.secs(), (uint32)0);
+		TS_ASSERT_EQUALS(b.msecs(), (uint32)500);
+		TS_ASSERT_EQUALS(b.getNumberOfFrames(), 11025);
+
+		TS_ASSERT_EQUALS(c.secs(), (uint32)1);
+		TS_ASSERT_EQUALS(c.msecs(), (uint32)1500);
+		TS_ASSERT_EQUALS(c.getNumberOfFrames(), 11025);
+	}
 };


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