aboutsummaryrefslogtreecommitdiff
path: root/sound/decoders
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-30 15:37:20 +0000
committerJohannes Schickel2010-01-30 15:37:20 +0000
commit3125dfe66e7cad99f262eb05d26df05ca15c7a95 (patch)
treed0e7defee77566d9fa5ed7b321dc5237372d19c9 /sound/decoders
parentef99a7243610961354f6120d3c9c531ff7881633 (diff)
downloadscummvm-rg350-3125dfe66e7cad99f262eb05d26df05ca15c7a95.tar.gz
scummvm-rg350-3125dfe66e7cad99f262eb05d26df05ca15c7a95.tar.bz2
scummvm-rg350-3125dfe66e7cad99f262eb05d26df05ca15c7a95.zip
Add some asserts to the RawAudioStream code.
svn-id: r47720
Diffstat (limited to 'sound/decoders')
-rw-r--r--sound/decoders/raw.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/decoders/raw.cpp b/sound/decoders/raw.cpp
index 29ca3a8813..0fe11f252c 100644
--- a/sound/decoders/raw.cpp
+++ b/sound/decoders/raw.cpp
@@ -94,8 +94,11 @@ public:
// Add up length of all blocks in order to caluclate total play time
int32 len = 0;
- for (RawStreamBlockList::const_iterator i = _blocks.begin(); i != _blocks.end(); ++i)
+ for (RawStreamBlockList::const_iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
+ assert(i->len % (stereo ? 2 : 1) == 0);
len += i->len;
+ }
+
_playtime = Timestamp(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate);
}
@@ -269,8 +272,11 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
RawAudioStreamBlock block;
block.pos = 0;
+ const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
+ assert(stream->size() % ((is16Bit ? 2 : 1) * (isStereo ? 2 : 1)) == 0);
+
block.len = stream->size() / (is16Bit ? 2 : 1);
blocks.push_back(block);