From 3a1de9a1828dccac216cc9833de0b8c06a681d07 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 21 Apr 2013 13:51:31 +0200 Subject: AUDIO: Handle empty parent stream in LoopingAudioStream This should fix bug #3571139. --- audio/audiostream.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'audio') diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index 2d65d4afef..8bd4b95c49 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -98,6 +98,10 @@ LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops // TODO: Properly indicate error _loops = _completeIterations = 1; } + if (stream->endOfData()) { + // Apparently this is an empty stream + _loops = _completeIterations = 1; + } } int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { @@ -118,6 +122,10 @@ int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { _loops = _completeIterations = 1; return samplesRead; } + if (_parent->endOfData()) { + // Apparently this is an empty stream + _loops = _completeIterations = 1; + } return samplesRead + readBuffer(buffer + samplesRead, remainingSamples); } -- cgit v1.2.3