From 6d632dda27a9a05ee5668d955a254625fb2626b3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 12 Jun 2014 00:40:26 -0400 Subject: AUDIO: Better handle endOfStream() vs endOfData() in QueuingAudioStreamImpl --- audio/audiostream.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'audio/audiostream.cpp') diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index bfb1dda2ad..54dcd9b05d 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -318,7 +318,7 @@ public: virtual bool endOfData() const { Common::StackLock lock(_mutex); - return _queue.empty(); + return _queue.empty() || _queue.front()._stream->endOfData(); } virtual bool endOfStream() const { @@ -365,11 +365,17 @@ int QueuingAudioStreamImpl::readBuffer(int16 *buffer, const int numSamples) { AudioStream *stream = _queue.front()._stream; samplesDecoded += stream->readBuffer(buffer + samplesDecoded, numSamples - samplesDecoded); - if (stream->endOfData()) { + // Done with the stream completely + if (stream->endOfStream()) { StreamHolder tmp = _queue.pop(); if (tmp._disposeAfterUse == DisposeAfterUse::YES) delete stream; + continue; } + + // Done with data but not the stream, bail out + if (stream->endOfData()) + break; } return samplesDecoded; -- cgit v1.2.3