aboutsummaryrefslogtreecommitdiff
path: root/sound/audiostream.cpp
diff options
context:
space:
mode:
authorMax Horn2008-11-12 12:25:26 +0000
committerMax Horn2008-11-12 12:25:26 +0000
commit0c501d303f64fe752b1660c192dc8dca5d0a776d (patch)
tree660e7c7b22285982542adee89d424c73b963627a /sound/audiostream.cpp
parent0ce8400841443ce9c96f3f96e5fcd508eb4fd92a (diff)
downloadscummvm-rg350-0c501d303f64fe752b1660c192dc8dca5d0a776d.tar.gz
scummvm-rg350-0c501d303f64fe752b1660c192dc8dca5d0a776d.tar.bz2
scummvm-rg350-0c501d303f64fe752b1660c192dc8dca5d0a776d.zip
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
svn-id: r35014
Diffstat (limited to 'sound/audiostream.cpp')
-rw-r--r--sound/audiostream.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 588c49ebec..7ba7871bc0 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -133,20 +133,10 @@ public:
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 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte f
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);