From 79fd7ee44117f762b4253bc0e9521c38cdafbb08 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 5 Aug 2003 18:12:59 +0000 Subject: cleanup svn-id: r9512 --- sound/audiostream.cpp | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'sound') diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 0312992802..5a25d61468 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -150,7 +150,6 @@ inline int16 WrappedMemoryStream::readIntern() { template int WrappedMemoryStream::readBuffer(int16 *buffer, int numSamples) { int samples = 0; -#if 1 while (samples < numSamples && !eosIntern()) { const byte *endMarker = (_pos > _end) ? _bufferEnd : _end; const int len = MIN(numSamples, (endMarker - _pos) / (is16Bit ? 2 : 1)); @@ -163,11 +162,6 @@ int WrappedMemoryStream::readBuffer(int16 *buffer, if (_pos >= _bufferEnd) _pos = _pos - (_bufferEnd - _bufferStart); } -#else - for (samples = 0; samples < numSamples && !eosIntern(); samples++) { - *buffer++ = readIntern(); - } -#endif return samples; } @@ -414,9 +408,7 @@ inline int16 MP3InputStream::readIntern() { int MP3InputStream::readBuffer(int16 *buffer, int numSamples) { int samples = 0; -#if 1 - if (_isStereo) - assert(_curChannel == 0); + assert(_curChannel == 0); // Paranoia check while (samples < numSamples && !eosIntern()) { const int len = MIN(numSamples, (int)(_synth.pcm.length - _posInFrame) * (_isStereo ? 2 : 1)); while (samples < len) { @@ -432,11 +424,6 @@ int MP3InputStream::readBuffer(int16 *buffer, int numSamples) { refill(); } } -#else - for (samples = 0; samples < numSamples && !eosIntern(); samples++) { - *buffer++ = readIntern(); - } -#endif return samples; } @@ -460,7 +447,8 @@ class VorbisInputStream : public MusicStream { bool _eofFlag; int _numChannels; int16 _buffer[4096]; - int16 *_pos; + const int16 * const _bufferEnd; + const int16 *_pos; void refill(); inline int16 readIntern(); @@ -483,8 +471,8 @@ public: VorbisInputStream::VorbisInputStream(OggVorbis_File *file, int duration) - : _ov_file(file) { - _pos = _buffer + ARRAYSIZE(_buffer); + : _ov_file(file), _bufferEnd(_buffer + ARRAYSIZE(_buffer)) { + _pos = _bufferEnd; _numChannels = ov_info(_ov_file, -1)->channels; if (duration) @@ -496,7 +484,7 @@ VorbisInputStream::VorbisInputStream(OggVorbis_File *file, int duration) } inline int16 VorbisInputStream::readIntern() { - if (_pos >= _buffer + ARRAYSIZE(_buffer)) { + if (_pos >= _bufferEnd) { refill(); } return *_pos++; @@ -505,30 +493,23 @@ inline int16 VorbisInputStream::readIntern() { inline bool VorbisInputStream::eosIntern() const { if (_eofFlag) return true; - if (_pos < _buffer + ARRAYSIZE(_buffer)) + if (_pos < _bufferEnd) return false; return (_end_pos <= ov_pcm_tell(_ov_file)); } int VorbisInputStream::readBuffer(int16 *buffer, int numSamples) { int samples = 0; -#if 1 - const int16 * const bufferEnd = _buffer + ARRAYSIZE(_buffer); while (samples < numSamples && !eosIntern()) { - if (_pos >= bufferEnd) { + if (_pos >= _bufferEnd) { refill(); } - const int len = MIN(numSamples, bufferEnd - _pos); + 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