From 2b1d4ef990c0a822da7838aa3261bbb7f48b2fba Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 22 Sep 2005 20:45:46 +0000 Subject: Fix regression caused by recent code cleanup. Each input byte should be processed twice, so even if stream end is reached, there should be another iteration. Otherwise it always returned one byte less than expected. svn-id: r18859 --- sound/adpcm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp index 80bbbe4fdc..b38cca36e3 100644 --- a/sound/adpcm.cpp +++ b/sound/adpcm.cpp @@ -72,7 +72,9 @@ template int ADPCMInputStream::readBuffer(int16 *buffer, const int numSamples) { int samples; - for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples++) { + // Since we process high and low nibbles separately never check buffer end + // on low nibble + for (samples = 0; !_evenPos || samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples++) { if (_evenPos) { _lastByte = _stream->readByte(); buffer[samples] = decode((_lastByte >> 4) & 0x0f); -- cgit v1.2.3