aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders/wave.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2012-02-08 09:39:15 +0100
committerBastien Bouclet2012-02-09 16:10:50 +0100
commit577635acf2d831240e6d83906f4f17f5b7600ac6 (patch)
treea99aeb9ebe9269160e7e0df4052be430326a0bb3 /audio/decoders/wave.cpp
parent9d85382c153bd4bcb58b7683f4d06658bf18c4d7 (diff)
downloadscummvm-rg350-577635acf2d831240e6d83906f4f17f5b7600ac6.tar.gz
scummvm-rg350-577635acf2d831240e6d83906f4f17f5b7600ac6.tar.bz2
scummvm-rg350-577635acf2d831240e6d83906f4f17f5b7600ac6.zip
AUDIO: Add support for RAW PCM wave stream with an incomplete packet
The last incomplete packet is ignored
Diffstat (limited to 'audio/decoders/wave.cpp')
-rw-r--r--audio/decoders/wave.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/audio/decoders/wave.cpp b/audio/decoders/wave.cpp
index 3cf4566d0c..44188f84ca 100644
--- a/audio/decoders/wave.cpp
+++ b/audio/decoders/wave.cpp
@@ -175,6 +175,13 @@ RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, Dispose
else if (type == 2) // MS ADPCM
return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMS, rate, (flags & Audio::FLAG_STEREO) ? 2 : 1, blockAlign);
+ // Raw PCM, make sure the last packet is complete
+ uint sampleSize = (flags & Audio::FLAG_16BITS ? 2 : 1) * (flags & Audio::FLAG_STEREO ? 2 : 1);
+ if (size % sampleSize != 0) {
+ warning("makeWAVStream: Trying to play a WAVE file with an incomplete PCM packet");
+ size &= ~(sampleSize - 1);
+ }
+
// Raw PCM. Just read everything at once.
// TODO: More elegant would be to wrap the stream.
byte *data = (byte *)malloc(size);