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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jan 7 16:12:20 CET 2010


Revision: 47120
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47120&view=rev
Author:   fingolfin
Date:     2010-01-07 15:12:20 +0000 (Thu, 07 Jan 2010)

Log Message:
-----------
Add Timestamp::totalNumberOfFrames() method, clarify some comments

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

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-07 15:11:46 UTC (rev 47119)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-07 15:12:20 UTC (rev 47120)
@@ -183,8 +183,7 @@
 }
 
 uint32 calculateSampleOffset(const Timestamp &where, int rate) {
-	const Timestamp whereRate = where.convertToFramerate(rate);
-	return whereRate.secs() * rate + whereRate.numberOfFrames();
+	return where.convertToFramerate(rate).totalNumberOfFrames();
 }
 
 /**

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-07 15:11:46 UTC (rev 47119)
+++ scummvm/trunk/sound/audiostream.h	2010-01-07 15:12:20 UTC (rev 47120)
@@ -152,9 +152,9 @@
 };
 
 /**
- * A seekable audio stream. Subclasses of this class implement a
- * working seeking. The seeking itself is not required to be
- * working when the stream is being played by Mixer!
+ * A seekable audio stream. Subclasses of this class implement an
+ * interface for seeking. The seeking itself is not required to be
+ * working while the stream is being played by Mixer!
  */
 class SeekableAudioStream : public RewindableAudioStream {
 public:

Modified: scummvm/trunk/sound/timestamp.h
===================================================================
--- scummvm/trunk/sound/timestamp.h	2010-01-07 15:11:46 UTC (rev 47119)
+++ scummvm/trunk/sound/timestamp.h	2010-01-07 15:12:20 UTC (rev 47120)
@@ -129,22 +129,35 @@
 	int msecsDiff(const Timestamp &ts) const;
 
 	/**
-	 * Determines the time in milliseconds described by this timestamp,
+	 * Return the time in milliseconds described by this timestamp,
 	 * rounded down.
 	 */
 	uint32 msecs() const;
 
 	/**
-	 * Determines the time in seconds described by this timestamp,
+	 * Return the time in seconds described by this timestamp,
 	 * rounded down.
 	 */
-	inline uint32 secs() const { return _secs; }
+	inline uint32 secs() const {
+		return _secs;
+	}
 
 	/**
-	 * Determines the frames described by this timestamp.
+	 * Return the time in frames described by this timestamp.
 	 */
-	inline int numberOfFrames() const { return _numberOfFrames / _framerateFactor; }
+	inline int totalNumberOfFrames() const {
+		return _numberOfFrames / _framerateFactor + _secs * (_framerate / _framerateFactor);
+	}
 
+	/**
+	 * A timestamp consists of a number of seconds, plus a number
+	 * of frames, the latter describing a fraction of a second.
+	 * This method returns the latter number.
+	 */
+	inline int numberOfFrames() const {
+		return _numberOfFrames / _framerateFactor;
+	}
+
 	/** Return the framerate used by this timestamp. */
 	inline int framerate() const { return _framerate / _framerateFactor; }
 

Modified: scummvm/trunk/test/sound/timestamp.h
===================================================================
--- scummvm/trunk/test/sound/timestamp.h	2010-01-07 15:11:46 UTC (rev 47119)
+++ scummvm/trunk/test/sound/timestamp.h	2010-01-07 15:12:20 UTC (rev 47120)
@@ -159,13 +159,16 @@
 		TS_ASSERT_EQUALS(a.secs(), (uint32)0);
 		TS_ASSERT_EQUALS(a.msecs(), (uint32)0);
 		TS_ASSERT_EQUALS(a.numberOfFrames(), 0);
+		TS_ASSERT_EQUALS(a.totalNumberOfFrames(), 0);
 
 		TS_ASSERT_EQUALS(b.secs(), (uint32)0);
 		TS_ASSERT_EQUALS(b.msecs(), (uint32)500);
 		TS_ASSERT_EQUALS(b.numberOfFrames(), 11025);
+		TS_ASSERT_EQUALS(b.totalNumberOfFrames(), 11025);
 
 		TS_ASSERT_EQUALS(c.secs(), (uint32)1);
 		TS_ASSERT_EQUALS(c.msecs(), (uint32)1500);
 		TS_ASSERT_EQUALS(c.numberOfFrames(), 11025);
+		TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 33075);
 	}
 };


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