aboutsummaryrefslogtreecommitdiff
path: root/sound/flac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r--sound/flac.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp
index 8699e8cfce..ddfd9bf329 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -82,7 +82,7 @@ namespace Audio {
static const uint MAX_OUTPUT_CHANNELS = 2;
-class FlacInputStream : public AudioStream {
+class FlacInputStream : public SeekableAudioStream {
protected:
Common::SeekableReadStream *_inStream;
bool _disposeAfterUse;
@@ -149,6 +149,8 @@ public:
return _totalPlayTime * _numLoops;
}
+ bool seek(const Timestamp &where);
+
bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
void setNumLoops(uint numLoops = 1) {
@@ -334,6 +336,14 @@ bool FlacInputStream::seekAbsolute(FLAC__uint64 sample) {
return result;
}
+bool FlacInputStream::seek(const Timestamp &where) {
+ _sampleCache.bufFill = 0;
+ _sampleCache.bufReadPos = NULL;
+ // Compute the start/end sample (we use floating point arithmetics here to
+ // avoid overflows).
+ return seekAbsolute((FLAC__uint64)(where.msecs() * (_streaminfo.sample_rate / 1000.0)));
+}
+
int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) {
const uint numChannels = getChannels();
@@ -770,7 +780,7 @@ void FlacInputStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder
#pragma mark -
-AudioStream *makeFlacStream(
+SeekableAudioStream *makeFlacStream(
Common::SeekableReadStream *stream,
bool disposeAfterUse,
uint32 startTime,