aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-25 02:46:50 -0400
committerMatthew Hoops2011-08-25 10:14:17 -0400
commit37a401a17295d10f0e5fb104330fc5f21d125362 (patch)
treeebc28d99cd133328ded14cd6e4c6fa27fa91a57f /audio/decoders
parent19768db88210c8491a729fb20ac6af040296a0ec (diff)
downloadscummvm-rg350-37a401a17295d10f0e5fb104330fc5f21d125362.tar.gz
scummvm-rg350-37a401a17295d10f0e5fb104330fc5f21d125362.tar.bz2
scummvm-rg350-37a401a17295d10f0e5fb104330fc5f21d125362.zip
AUDIO: Properly handle XA flags
Diffstat (limited to 'audio/decoders')
-rw-r--r--audio/decoders/xa.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/audio/decoders/xa.cpp b/audio/decoders/xa.cpp
index 9871775973..9b4f27f9fc 100644
--- a/audio/decoders/xa.cpp
+++ b/audio/decoders/xa.cpp
@@ -46,6 +46,7 @@ private:
byte _samplesRemaining;
int _rate;
double _s1, _s2;
+ uint _loopPoint;
};
XAStream::XAStream(Common::SeekableReadStream *stream, int rate, DisposeAfterUse::Flag disposeAfterUse)
@@ -54,6 +55,7 @@ XAStream::XAStream(Common::SeekableReadStream *stream, int rate, DisposeAfterUse
_predictor = 0;
_s1 = _s2 = 0.0;
_rate = rate;
+ _loopPoint = 0;
}
@@ -103,8 +105,20 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
byte shift = _predictor & 0xf;
_predictor >>= 4;
- if (_stream->readByte() == 7)
- return samplesDecoded;
+ byte flags = _stream->readByte();
+ if (flags & 0x1) {
+ if (flags == 3) {
+ // Loop
+ rewind();
+ continue;
+ } else {
+ // End of stream
+ return samplesDecoded;
+ }
+ } else if (flags & 0x4) {
+ // Set loop point
+ _loopPoint = _stream->pos() - 2;
+ }
for (i = 0; i < 28; i += 2) {
byte d = _stream->readByte();
@@ -135,7 +149,7 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
}
bool XAStream::rewind() {
- _stream->seek(0);
+ _stream->seek(_loopPoint);
_samplesRemaining = 0;
_predictor = 0;
_s1 = _s2 = 0.0;