mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
- Add some functionallity to query the seconds and number of frames stored in a Timestamp.
- Add tests for these svn-id: r47081
This commit is contained in:
parent
84f3034406
commit
e72707b04e
@ -129,6 +129,17 @@ public:
|
||||
/** 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;
|
||||
|
@ -143,10 +143,27 @@ class TimestampTestSuite : public CxxTest::TestSuite
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user