AUDIO: Better handle endOfStream() vs endOfData() in QueuingAudioStreamImpl

This commit is contained in:
Matthew Hoops 2014-06-12 00:40:26 -04:00
parent d2353964b8
commit 6d632dda27

View File

@ -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;