From 8a1cf1c2d0b661e3cbf1c9703d0835348ed328ba Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 6 Apr 2007 13:16:53 +0000 Subject: Fix looping for FLAC tracs (looping parts of a file already worked, but looping until the end of data didn't) svn-id: r26388 --- sound/flac.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sound/flac.cpp') 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(); } } -- cgit v1.2.3