From 74188e6143c06beb2f1a08f47750ffc529652dcb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 5 Aug 2003 01:22:09 +0000 Subject: and finally VorbisInputStream::readBuffer. Once we verified the new readBuffer methods all work, we can get rid of readIntern again and merge those back into the regular read() methods svn-id: r9476 --- sound/audiostream.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index b206c00fc4..7a71a43234 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -512,10 +512,24 @@ inline bool VorbisInputStream::eosIntern() const { } int VorbisInputStream::readBuffer(int16 *buffer, int numSamples) { - int samples; - for (samples = 0; samples < numSamples && !eosIntern(); samples++) { + int samples = 0; +#if 1 + const int16 * const bufferEnd = _buffer + ARRAYSIZE(_buffer); + while (samples < numSamples && !eosIntern()) { + if (_pos >= bufferEnd) { + refill(); + } + const int len = MIN(numSamples, bufferEnd - _pos); + memcpy(buffer, _pos, len * 2); + buffer += len; + _pos += len; + samples += len; + } +#else + for (; samples < numSamples && !eosIntern(); samples++) { *buffer++ = readIntern(); } +#endif return samples; } -- cgit v1.2.3