diff options
-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: |