aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-08-05 18:12:59 +0000
committerMax Horn2003-08-05 18:12:59 +0000
commit79fd7ee44117f762b4253bc0e9521c38cdafbb08 (patch)
tree7f801a759e9664642fd2409d80174c5ab4ce8a0b /sound
parent995ec987d0f8a9b152b8c5880ffe36dfbb602f2d (diff)
downloadscummvm-rg350-79fd7ee44117f762b4253bc0e9521c38cdafbb08.tar.gz
scummvm-rg350-79fd7ee44117f762b4253bc0e9521c38cdafbb08.tar.bz2
scummvm-rg350-79fd7ee44117f762b4253bc0e9521c38cdafbb08.zip
cleanup
svn-id: r9512
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp37
1 files changed, 9 insertions, 28 deletions
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<stereo, is16Bit, isUnsigned>::readIntern() {
template<bool stereo, bool is16Bit, bool isUnsigned>
int WrappedMemoryStream<stereo, is16Bit, isUnsigned>::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<stereo, is16Bit, isUnsigned>::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;
}