From 1805b07a4871d7fe704200d7a1a8f135220a0258 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 3 Jan 2004 02:30:34 +0000 Subject: simplification (possible since read() doesn't have to be efficient anymore) svn-id: r12103 --- sound/audiostream.cpp | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 0e86bc00d7..457f2b5bc1 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -259,40 +259,18 @@ private: const bool _isStereo; InputProc *_proc; void *_refCon; - int16 _buffer[2048]; - const int16 *_pos; - int _len; - - void refill() { - // Fill the buffer - (_proc)(_refCon, _buffer, 2048); - _pos = _buffer; - _len = 2048; - } public: ProcInputStream(int rate, bool stereo, InputProc *proc, void *refCon) - : _rate(rate), _isStereo(stereo), _proc(proc), _refCon(refCon), _len(0) { } + : _rate(rate), _isStereo(stereo), _proc(proc), _refCon(refCon) { } int readBuffer(int16 *buffer, const int numSamples) { - int remSamples = numSamples; - while (remSamples > 0) { - if (_len == 0) - refill(); - // Copy data to the output - int samples = MIN(_len, remSamples); - memcpy(buffer, _pos, samples * sizeof(int16)); - _pos += samples; - _len -= samples; - buffer += samples; - remSamples -= samples; - } + (_proc)(_refCon, buffer, numSamples); return numSamples; } int16 read() { - if (_len == 0) - refill(); - _len--; - return *_pos++; + int16 sample; + (_proc)(_refCon, &sample, 1); + return sample; } bool isStereo() const { return _isStereo; } bool endOfData() const { return false; } -- cgit v1.2.3