Add a "getLength" function to SeekableAudioStream.

svn-id: r47036
This commit is contained in:
Johannes Schickel 2010-01-05 20:13:31 +00:00
parent 1712e223e2
commit e9a94ecb9b
6 changed files with 24 additions and 0 deletions

View file

@ -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;

View file

@ -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);
};

View file

@ -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;
};

View file

@ -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 ; }

View file

@ -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;

View file

@ -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();