aboutsummaryrefslogtreecommitdiff
path: root/audio/audiostream.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2014-06-12 00:40:26 -0400
committerMatthew Hoops2014-07-27 23:44:44 -0400
commit6d632dda27a9a05ee5668d955a254625fb2626b3 (patch)
tree12290d52f351d28a0557af13496e96a32d42e298 /audio/audiostream.cpp
parentd2353964b8712bb3604ba7af678ca6cc95278fbf (diff)
downloadscummvm-rg350-6d632dda27a9a05ee5668d955a254625fb2626b3.tar.gz
scummvm-rg350-6d632dda27a9a05ee5668d955a254625fb2626b3.tar.bz2
scummvm-rg350-6d632dda27a9a05ee5668d955a254625fb2626b3.zip
AUDIO: Better handle endOfStream() vs endOfData() in QueuingAudioStreamImpl
Diffstat (limited to 'audio/audiostream.cpp')
-rw-r--r--audio/audiostream.cpp10
1 files changed, 8 insertions, 2 deletions
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;