From 577635acf2d831240e6d83906f4f17f5b7600ac6 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Wed, 8 Feb 2012 09:39:15 +0100 Subject: AUDIO: Add support for RAW PCM wave stream with an incomplete packet The last incomplete packet is ignored --- audio/decoders/wave.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'audio/decoders') 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); -- cgit v1.2.3