aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-05 20:13:31 +0000
committerJohannes Schickel2010-01-05 20:13:31 +0000
commite9a94ecb9b6eb20cb7cdc4f838df3f9b049d2de6 (patch)
tree860360b7d34f7742c066537a6270a681b44ca751 /sound
parent1712e223e2e520320a5ef4edfc8ad36cd82cc4a1 (diff)
downloadscummvm-rg350-e9a94ecb9b6eb20cb7cdc4f838df3f9b049d2de6.tar.gz
scummvm-rg350-e9a94ecb9b6eb20cb7cdc4f838df3f9b049d2de6.tar.bz2
scummvm-rg350-e9a94ecb9b6eb20cb7cdc4f838df3f9b049d2de6.zip
Add a "getLength" function to SeekableAudioStream.
svn-id: r47036
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp4
-rw-r--r--sound/audiostream.h7
-rw-r--r--sound/flac.cpp2
-rw-r--r--sound/mp3.cpp2
-rw-r--r--sound/vorbis.cpp8
5 files changed, 23 insertions, 0 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 9453eb24da..4ecfbedada 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -175,6 +175,8 @@ public:
}
bool seek(const Timestamp &where);
+ // TODO: We can definitly increase the precision here, since we know the exact sample count
+ Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
void setNumLoops(uint numLoops) {
_numLoops = numLoops;
@@ -334,6 +336,8 @@ public:
return kUnknownPlayTime;
return _playtime * _numLoops;
}
+ // TODO: We can definitly increase the precision here, since we know the exact sample count
+ Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
bool seek(const Timestamp &where);
};
diff --git a/sound/audiostream.h b/sound/audiostream.h
index 15e7ea6d33..a3992ca94f 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -157,6 +157,13 @@ public:
* @return true on success, false on failure.
*/
virtual bool seek(const Timestamp &where) = 0;
+
+ /**
+ * Returns the length of the stream.
+ *
+ * @return length as Timestamp.
+ */
+ virtual Timestamp getLength() const = 0;
};
diff --git a/sound/flac.cpp b/sound/flac.cpp
index ddfd9bf329..b99f8bb484 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -150,6 +150,8 @@ public:
}
bool seek(const Timestamp &where);
+ // TODO: We can definitly increase the precision here, since FLAC allows us to catch the sample count
+ Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index 72d4652789..332fe20d59 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -100,6 +100,8 @@ public:
}
bool seek(const Timestamp &where);
+ // TODO: Maybe we can have a more precise implementation of this
+ Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
void setNumLoops(uint numLoops) {
_numLoops = numLoops;
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index eced67726a..a130ecc5ec 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -139,6 +139,14 @@ public:
}
bool seek(const Timestamp &where);
+ // TODO: Maybe we can have a more precise implementation of this
+ Timestamp getLength() const {
+#ifdef USE_TREMOR
+ return Timestamp(_endTime, getRate());
+#else
+ return Timestamp((uint32)(_endTime * 1000.0), getRate());
+#endif
+ }
protected:
bool refill();