diff options
author | D G Turner | 2012-08-04 20:29:37 +0100 |
---|---|---|
committer | D G Turner | 2012-08-04 20:29:37 +0100 |
commit | 43e2c6ee1ec8f47a61f69572043b2beca01f53f6 (patch) | |
tree | b03401467209acce70ebc0b29f66ad990c1ca9c9 /audio/decoders | |
parent | 9c47fdae293e05888d3b4ec45fd4b374d1022c0b (diff) | |
download | scummvm-rg350-43e2c6ee1ec8f47a61f69572043b2beca01f53f6.tar.gz scummvm-rg350-43e2c6ee1ec8f47a61f69572043b2beca01f53f6.tar.bz2 scummvm-rg350-43e2c6ee1ec8f47a61f69572043b2beca01f53f6.zip |
AUDIO: Correct ADPCM Fixes to ensure internal buffers are drained.
This also adds an omitted _decodedSampleCount initialization in Oki
ADPCM decoder.
Diffstat (limited to 'audio/decoders')
-rw-r--r-- | audio/decoders/adpcm.cpp | 4 | ||||
-rw-r--r-- | audio/decoders/adpcm_intern.h | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/audio/decoders/adpcm.cpp b/audio/decoders/adpcm.cpp index e7297423f6..2fe509e1f3 100644 --- a/audio/decoders/adpcm.cpp +++ b/audio/decoders/adpcm.cpp @@ -71,7 +71,7 @@ int Oki_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { int samples; byte data; - for (samples = 0; samples < numSamples && !_stream->eos() && (_stream->pos() < _endpos); samples++) { + for (samples = 0; samples < numSamples && !endOfData(); samples++) { if (_decodedSampleCount == 0) { data = _stream->readByte(); _decodedSamples[0] = decodeOKI((data >> 4) & 0x0f); @@ -123,7 +123,7 @@ int DVI_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { int samples; byte data; - for (samples = 0; samples < numSamples && !_stream->eos() && (_stream->pos() < _endpos); samples++) { + for (samples = 0; samples < numSamples && !endOfData(); samples++) { if (_decodedSampleCount == 0) { data = _stream->readByte(); _decodedSamples[0] = decodeIMA((data >> 4) & 0x0f, 0); diff --git a/audio/decoders/adpcm_intern.h b/audio/decoders/adpcm_intern.h index 423c4af267..3b8d8c74d0 100644 --- a/audio/decoders/adpcm_intern.h +++ b/audio/decoders/adpcm_intern.h @@ -37,7 +37,6 @@ #include "common/stream.h" #include "common/textconsole.h" - namespace Audio { class ADPCMStream : public RewindableAudioStream { @@ -64,12 +63,11 @@ public: ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign); virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); } - virtual bool isStereo() const { return _channels == 2; } - virtual int getRate() const { return _rate; } + virtual bool isStereo() const { return _channels == 2; } + virtual int getRate() const { return _rate; } virtual bool rewind(); - /** * This table is used by some ADPCM variants (IMA and OKI) to adjust the * step for use on the next sample. @@ -83,7 +81,9 @@ public: class Oki_ADPCMStream : public ADPCMStream { public: Oki_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) - : ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {} + : ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; } + + virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); } virtual int readBuffer(int16 *buffer, const int numSamples); @@ -114,6 +114,8 @@ public: DVI_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) : Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; } + virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); } + virtual int readBuffer(int16 *buffer, const int numSamples); private: |