diff options
-rw-r--r-- | engines/kyra/sound_digital.cpp | 1 | ||||
-rw-r--r-- | sound/audiostream.cpp | 4 | ||||
-rw-r--r-- | sound/audiostream.h | 7 | ||||
-rw-r--r-- | sound/flac.cpp | 2 | ||||
-rw-r--r-- | sound/mp3.cpp | 2 | ||||
-rw-r--r-- | sound/vorbis.cpp | 8 |
6 files changed, 24 insertions, 0 deletions
diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index 0687c06cc8..aaae5eaece 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -122,6 +122,7 @@ public: // GROSS HACK, if anyone sees this, be aware that you should // never copy this! This is just a temporary hack... bool seek(const Audio::Timestamp &) { return false; } + Audio::Timestamp getLength() const { return Audio::Timestamp(0, getRate()); } private: Common::SeekableReadStream *_stream; bool _loop; 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(); |