aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-01-07 15:12:20 +0000
committerMax Horn2010-01-07 15:12:20 +0000
commit32ec5746bebcfbaecece143f2ee75644a1000d17 (patch)
treecbd9512ceaebfc0b6c2ff959d66e12dfcc566315
parent423094cd5f624feb259a0c6cbfefd269553ef44d (diff)
downloadscummvm-rg350-32ec5746bebcfbaecece143f2ee75644a1000d17.tar.gz
scummvm-rg350-32ec5746bebcfbaecece143f2ee75644a1000d17.tar.bz2
scummvm-rg350-32ec5746bebcfbaecece143f2ee75644a1000d17.zip
Add Timestamp::totalNumberOfFrames() method, clarify some comments
svn-id: r47120
-rw-r--r--sound/audiostream.cpp3
-rw-r--r--sound/audiostream.h6
-rw-r--r--sound/timestamp.h23
-rw-r--r--test/sound/timestamp.h3
4 files changed, 25 insertions, 10 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 79e8308115..6a3b1d792d 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -183,8 +183,7 @@ inline int32 calculatePlayTime(int rate, int samples) {
}
uint32 calculateSampleOffset(const Timestamp &where, int rate) {
- const Timestamp whereRate = where.convertToFramerate(rate);
- return whereRate.secs() * rate + whereRate.numberOfFrames();
+ return where.convertToFramerate(rate).totalNumberOfFrames();
}
/**
diff --git a/sound/audiostream.h b/sound/audiostream.h
index 528a6e25d8..15dce74661 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -152,9 +152,9 @@ private:
};
/**
- * 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:
diff --git a/sound/timestamp.h b/sound/timestamp.h
index cf149a65d0..699723e79b 100644
--- a/sound/timestamp.h
+++ b/sound/timestamp.h
@@ -129,21 +129,34 @@ public:
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; }
diff --git a/test/sound/timestamp.h b/test/sound/timestamp.h
index 0df459dc64..213c49ad7f 100644
--- a/test/sound/timestamp.h
+++ b/test/sound/timestamp.h
@@ -159,13 +159,16 @@ class TimestampTestSuite : public CxxTest::TestSuite
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);
}
};