From 82d464367b1060003886b1a331a03f5ca099499f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 10 Jul 2014 00:39:29 -0400 Subject: [PATCH] AUDIO: Better handle endOfStream() vs endOfData() in LoopingAudioStream --- audio/audiostream.cpp | 10 +++++++--- audio/audiostream.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index 36f714b402c..fbf672ca228 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -98,7 +98,7 @@ LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops // TODO: Properly indicate error _loops = _completeIterations = 1; } - if (stream->endOfData()) { + if (stream->endOfStream()) { // Apparently this is an empty stream _loops = _completeIterations = 1; } @@ -122,7 +122,7 @@ int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { _loops = _completeIterations = 1; return samplesRead; } - if (_parent->endOfData()) { + if (_parent->endOfStream()) { // Apparently this is an empty stream _loops = _completeIterations = 1; } @@ -134,7 +134,11 @@ int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { } bool LoopingAudioStream::endOfData() const { - return (_loops != 0 && (_completeIterations == _loops)); + return (_loops != 0 && _completeIterations == _loops) || _parent->endOfData(); +} + +bool LoopingAudioStream::endOfStream() const { + return _loops != 0 && _completeIterations == _loops; } AudioStream *makeLoopingAudioStream(RewindableAudioStream *stream, uint loops) { diff --git a/audio/audiostream.h b/audio/audiostream.h index d5d7d0b6c7b..ad842d7ca8d 100644 --- a/audio/audiostream.h +++ b/audio/audiostream.h @@ -118,6 +118,7 @@ public: int readBuffer(int16 *buffer, const int numSamples); bool endOfData() const; + bool endOfStream() const; bool isStereo() const { return _parent->isStereo(); } int getRate() const { return _parent->getRate(); }