diff options
author | Jamieson Christian | 2003-08-06 20:41:05 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-08-06 20:41:05 +0000 |
commit | 99716fc38e26112777947f9fb0606a9d09668aeb (patch) | |
tree | 5744058e8cedd3deb343c7283fcf908da358b0a9 /sound | |
parent | 1615278ecc376f7de5136e72239e86363cd96134 (diff) | |
download | scummvm-rg350-99716fc38e26112777947f9fb0606a9d09668aeb.tar.gz scummvm-rg350-99716fc38e26112777947f9fb0606a9d09668aeb.tar.bz2 scummvm-rg350-99716fc38e26112777947f9fb0606a9d09668aeb.zip |
Changed readSample template function
to Fingolfin's new READSAMPLE macro.
Circumvents buggy template function
handling in MSVC6. Props to Fingolfin
for tracking this bug down by remote.
svn-id: r9580
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 270a36e5db..665c5ab0b2 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -26,13 +26,8 @@ #include "common/file.h" #include "common/util.h" -template<bool is16Bit, bool isUnsigned> -static inline int16 readSample(const byte *ptr) { - uint16 sample = is16Bit ? READ_BE_UINT16(ptr) : (*ptr << 8); - if (isUnsigned) - sample ^= 0x8000; - return (int16)sample; -} +#define READSAMPLE(is16Bit, isUnsigned, ptr) \ + ((is16Bit ? READ_BE_UINT16(ptr) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0)) #pragma mark - #pragma mark --- LinearMemoryStream --- @@ -49,7 +44,7 @@ protected: inline int16 readIntern() { //assert(_ptr < _end); - int16 val = readSample<is16Bit, isUnsigned>(_ptr); + int16 val = READSAMPLE(is16Bit, isUnsigned, _ptr); _ptr += (is16Bit ? 2 : 1); if (_loopPtr && _ptr == _end) { _ptr = _loopPtr; @@ -81,7 +76,7 @@ int LinearMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer, i while (samples < numSamples && !eosIntern()) { const int len = MIN(numSamples, (int)(_end - _ptr) / (is16Bit ? 2 : 1)); while (samples < len) { - *buffer++ = readSample<is16Bit, isUnsigned>(_ptr); + *buffer++ = READSAMPLE(is16Bit, isUnsigned, _ptr); _ptr += (is16Bit ? 2 : 1); samples++; } @@ -137,7 +132,7 @@ WrappedMemoryStream<stereo, is16Bit, isUnsigned>::WrappedMemoryStream(uint buffe template<bool stereo, bool is16Bit, bool isUnsigned> inline int16 WrappedMemoryStream<stereo, is16Bit, isUnsigned>::readIntern() { //assert(_pos != _end); - int16 val = readSample<is16Bit, isUnsigned>(_pos); + int16 val = READSAMPLE(is16Bit, isUnsigned, _pos); _pos += (is16Bit ? 2 : 1); // Wrap around? @@ -154,7 +149,7 @@ int WrappedMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer, const byte *endMarker = (_pos > _end) ? _bufferEnd : _end; const int len = MIN(numSamples, (int)(endMarker - _pos) / (is16Bit ? 2 : 1)); while (samples < len) { - *buffer++ = readSample<is16Bit, isUnsigned>(_pos); + *buffer++ = READSAMPLE(is16Bit, isUnsigned, _pos); _pos += (is16Bit ? 2 : 1); samples++; } |