diff options
author | Johannes Schickel | 2010-01-05 02:27:24 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-05 02:27:24 +0000 |
commit | f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b (patch) | |
tree | ebbd8705d76d5d23a2b217f7bd31012afe271d2c /sound/flac.cpp | |
parent | 00e48f687ff0b0302383abfb9971f5420dc3c265 (diff) | |
download | scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.tar.gz scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.tar.bz2 scummvm-rg350-f5c3bd887e2257fc7fdfb0d141ddbae592f1e83b.zip |
- Add a new SeekableAudioStream interface. Soon to be used to replace audio stream specific looping code by generic code in Mixer...
- Adapted some existing AudioStreams to implement that interface (not tested!)
svn-id: r47013
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r-- | sound/flac.cpp | 14 |
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, |