[Scummvm-cvs-logs] CVS: scummvm/sound audiostream.cpp,1.29,1.30
Max Horn
fingolfin at users.sourceforge.net
Tue Aug 5 11:14:01 CEST 2003
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv30241
Modified Files:
audiostream.cpp
Log Message:
cleanup
Index: audiostream.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiostream.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- audiostream.cpp 5 Aug 2003 11:30:13 -0000 1.29
+++ audiostream.cpp 5 Aug 2003 18:12:59 -0000 1.30
@@ -150,7 +150,6 @@
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 @@
if (_pos >= _bufferEnd)
_pos = _pos - (_bufferEnd - _bufferStart);
}
-#else
- for (samples = 0; samples < numSamples && !eosIntern(); samples++) {
- *buffer++ = readIntern();
- }
-#endif
return samples;
}
@@ -414,9 +408,7 @@
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 @@
refill();
}
}
-#else
- for (samples = 0; samples < numSamples && !eosIntern(); samples++) {
- *buffer++ = readIntern();
- }
-#endif
return samples;
}
@@ -460,7 +447,8 @@
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 @@
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 @@
}
inline int16 VorbisInputStream::readIntern() {
- if (_pos >= _buffer + ARRAYSIZE(_buffer)) {
+ if (_pos >= _bufferEnd) {
refill();
}
return *_pos++;
@@ -505,30 +493,23 @@
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;
}
More information about the Scummvm-git-logs
mailing list