aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders/xa.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-25 11:16:58 -0400
committerMatthew Hoops2011-08-25 11:16:58 -0400
commit9a79a336aa5427e8b52683bd39088a2c557245db (patch)
treea684d3a70f56771b209fa93b55f53cf3b71b82b3 /audio/decoders/xa.cpp
parent64d2e2db118984201068406c8470ec70158fa5ff (diff)
downloadscummvm-rg350-9a79a336aa5427e8b52683bd39088a2c557245db.tar.gz
scummvm-rg350-9a79a336aa5427e8b52683bd39088a2c557245db.tar.bz2
scummvm-rg350-9a79a336aa5427e8b52683bd39088a2c557245db.zip
AUDIO: Don't abuse rewind() for looping in XA
Thanks to LordHoto for pointing out my stupidity :P
Diffstat (limited to 'audio/decoders/xa.cpp')
-rw-r--r--audio/decoders/xa.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/audio/decoders/xa.cpp b/audio/decoders/xa.cpp
index ab7fd66481..818cd2df59 100644
--- a/audio/decoders/xa.cpp
+++ b/audio/decoders/xa.cpp
@@ -41,6 +41,8 @@ private:
Common::SeekableReadStream *_stream;
DisposeAfterUse::Flag _disposeAfterUse;
+ void seekToPos(uint pos);
+
byte _predictor;
double _samples[28];
byte _samplesRemaining;
@@ -100,7 +102,7 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
byte flags = _stream->readByte();
if (flags == 3) {
// Loop
- rewind();
+ seekToPos(_loopPoint);
continue;
} else if (flags == 6) {
// Set loop point
@@ -143,13 +145,16 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
}
bool XAStream::rewind() {
- _stream->seek(_loopPoint);
+ seekToPos(0);
+ return true;
+}
+
+void XAStream::seekToPos(uint pos) {
+ _stream->seek(pos);
_samplesRemaining = 0;
_predictor = 0;
_s1 = _s2 = 0.0;
_endOfData = false;
-
- return true;
}
RewindableAudioStream *makeXAStream(Common::SeekableReadStream *stream, int rate, DisposeAfterUse::Flag disposeAfterUse) {