diff options
author | Johannes Schickel | 2010-02-09 21:51:47 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-02-09 21:51:47 +0000 |
commit | f6aa8d00689b4f4d4f3c3cf840efc1a4eb460aaf (patch) | |
tree | 34c77d3568128872b0ee741b58d5033fc440ce0b /sound | |
parent | d349be1fb8c78e0440702051f630f1060b89fb56 (diff) | |
download | scummvm-rg350-f6aa8d00689b4f4d4f3c3cf840efc1a4eb460aaf.tar.gz scummvm-rg350-f6aa8d00689b4f4d4f3c3cf840efc1a4eb460aaf.tar.bz2 scummvm-rg350-f6aa8d00689b4f4d4f3c3cf840efc1a4eb460aaf.zip |
Fix SubLoopingAudioStream's readBuffer implementation.
svn-id: r48018
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 763b8eb887..57db44de1f 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -180,11 +180,14 @@ SubLoopingAudioStream::~SubLoopingAudioStream() { } int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { + if (_done) + return 0; + int framesLeft = MIN(_loopEnd.frameDiff(_pos), numSamples); int framesRead = _parent->readBuffer(buffer, framesLeft); _pos = _pos.addFrames(framesRead); - if (framesLeft < numSamples || framesRead < framesLeft) { + if (_pos == _loopEnd) { if (_loops != 0) { --_loops; if (!_loops) { @@ -200,13 +203,10 @@ int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { _pos = _loopStart; framesLeft = numSamples - framesLeft; - framesRead += _parent->readBuffer(buffer + framesRead, framesLeft); - - if (_parent->endOfStream()) - _done = true; + return framesRead + readBuffer(buffer + framesRead, framesLeft); + } else { + return framesRead; } - - return framesRead; } #pragma mark - |