diff options
author | Max Horn | 2003-08-05 01:22:09 +0000 |
---|---|---|
committer | Max Horn | 2003-08-05 01:22:09 +0000 |
commit | 74188e6143c06beb2f1a08f47750ffc529652dcb (patch) | |
tree | 3f1477895b43aef2d896e16302f9c7b2e266a134 /sound | |
parent | 1de064ee2c5ac3620f47a256ec03966aae71625c (diff) | |
download | scummvm-rg350-74188e6143c06beb2f1a08f47750ffc529652dcb.tar.gz scummvm-rg350-74188e6143c06beb2f1a08f47750ffc529652dcb.tar.bz2 scummvm-rg350-74188e6143c06beb2f1a08f47750ffc529652dcb.zip |
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
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
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; } |