[Scummvm-cvs-logs] CVS: scummvm/sound audiostream.cpp,1.32,1.33

Jamieson Christian jamieson630 at users.sourceforge.net
Wed Aug 6 13:42:01 CEST 2003


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv15480/scummvm/sound

Modified Files:
	audiostream.cpp 
Log Message:
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.

Index: audiostream.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiostream.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- audiostream.cpp	6 Aug 2003 11:53:18 -0000	1.32
+++ audiostream.cpp	6 Aug 2003 20:41:05 -0000	1.33
@@ -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 @@
 
 	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 @@
 	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 @@
 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 @@
 		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++;
 		}





More information about the Scummvm-git-logs mailing list