aboutsummaryrefslogtreecommitdiff
path: root/sound/flac.cpp
diff options
context:
space:
mode:
authorMax Horn2007-04-06 13:16:53 +0000
committerMax Horn2007-04-06 13:16:53 +0000
commit8a1cf1c2d0b661e3cbf1c9703d0835348ed328ba (patch)
tree511d32e0785c3db89b0a492b8f504d8c2bedefc2 /sound/flac.cpp
parentce8bfbb46e75f2ebd04c3d6f7edf078fee89a103 (diff)
downloadscummvm-rg350-8a1cf1c2d0b661e3cbf1c9703d0835348ed328ba.tar.gz
scummvm-rg350-8a1cf1c2d0b661e3cbf1c9703d0835348ed328ba.tar.bz2
scummvm-rg350-8a1cf1c2d0b661e3cbf1c9703d0835348ed328ba.zip
Fix looping for FLAC tracs (looping parts of a file already worked, but looping until the end of data didn't)
svn-id: r26388
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r--sound/flac.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp
index 4edc5da9b7..61e8800c31 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -332,16 +332,22 @@ int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) {
FLAC__StreamDecoderState state = getStreamDecoderState();
// Keep poking FLAC to process more samples until we completely satisfied the request
- for (; _requestedSamples > 0 && state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; state = getStreamDecoderState()) {
+ while (_requestedSamples > 0 && state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) {
assert(_sampleCache.bufFill == 0);
assert(_requestedSamples % numChannels == 0);
processSingleBlock();
+ state = getStreamDecoderState();
+
+ if (state == FLAC__STREAM_DECODER_END_OF_STREAM) {
+ _lastSampleWritten = true;
+ }
// If we reached the end of the stream, and looping is enabled: Try to rewind
if (_lastSampleWritten && _numLoops != 1) {
if (_numLoops != 0)
_numLoops--;
seekAbsolute(_firstSample);
+ state = getStreamDecoderState();
}
}