diff options
author | Max Horn | 2004-01-03 02:30:34 +0000 |
---|---|---|
committer | Max Horn | 2004-01-03 02:30:34 +0000 |
commit | 1805b07a4871d7fe704200d7a1a8f135220a0258 (patch) | |
tree | 0cd45818350cb3232f829fa00a504e67af8f7bfb | |
parent | d212b2c2e1bc6aba370fa5e0ae4d122cd19a2466 (diff) | |
download | scummvm-rg350-1805b07a4871d7fe704200d7a1a8f135220a0258.tar.gz scummvm-rg350-1805b07a4871d7fe704200d7a1a8f135220a0258.tar.bz2 scummvm-rg350-1805b07a4871d7fe704200d7a1a8f135220a0258.zip |
simplification (possible since read() doesn't have to be efficient anymore)
svn-id: r12103
-rw-r--r-- | sound/audiostream.cpp | 32 |
1 files 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; } |