[Scummvm-cvs-logs] SF.net SVN: scummvm:[35014] scummvm/trunk/sound/audiostream.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Nov 12 13:25:26 CET 2008


Revision: 35014
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35014&view=rev
Author:   fingolfin
Date:     2008-11-12 12:25:26 +0000 (Wed, 12 Nov 2008)

Log Message:
-----------
Verify sanity of LinearMemoryStream params in the factory function instead of the constructor (which is replicated for each instantiation of the LinearMemoryStream template class) -> saves some bytes

Modified Paths:
--------------
    scummvm/trunk/sound/audiostream.cpp

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2008-11-12 10:16:06 UTC (rev 35013)
+++ scummvm/trunk/sound/audiostream.cpp	2008-11-12 12:25:26 UTC (rev 35014)
@@ -133,20 +133,10 @@
 	LinearMemoryStream(int rate, const byte *ptr, uint len, uint loopOffset, uint loopLen, bool autoFreeMemory)
 		: _ptr(ptr), _end(ptr+len), _loopPtr(0), _loopEnd(0), _rate(rate), _playtime(calculatePlayTime(rate, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1))) {
 
-		// Verify the buffer sizes are sane
-		if (is16Bit && stereo) {
-			assert((len & 3) == 0 && (loopLen & 3) == 0);
-		} else if (is16Bit || stereo) {
-			assert((len & 1) == 0 && (loopLen & 1) == 0);
-		}
-
 		if (loopLen) {
 			_loopPtr = _ptr + loopOffset;
 			_loopEnd = _loopPtr + loopLen;
 		}
-		if (stereo)	{ // Stereo requires even sized data
-			assert(len % 2 == 0);
-		}
 
 		_origPtr = autoFreeMemory ? ptr : 0;
 	}
@@ -222,6 +212,13 @@
 		loopLen = loopEnd - loopStart;
 	}
 
+	// Verify the buffer sizes are sane
+	if (is16Bit && isStereo) {
+		assert((len & 3) == 0 && (loopLen & 3) == 0);
+	} else if (is16Bit || isStereo) {
+		assert((len & 1) == 0 && (loopLen & 1) == 0);
+	}
+
 	if (isStereo) {
 		if (isUnsigned) {
 			MAKE_LINEAR(true, true);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list