aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJohannes Schickel2010-02-09 21:51:47 +0000
committerJohannes Schickel2010-02-09 21:51:47 +0000
commitf6aa8d00689b4f4d4f3c3cf840efc1a4eb460aaf (patch)
tree34c77d3568128872b0ee741b58d5033fc440ce0b /sound
parentd349be1fb8c78e0440702051f630f1060b89fb56 (diff)
downloadscummvm-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.cpp14
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 -