diff options
author | Max Horn | 2010-01-23 13:33:45 +0000 |
---|---|---|
committer | Max Horn | 2010-01-23 13:33:45 +0000 |
commit | 7eb407be80857b27c718e4e6f22de61c4d88b183 (patch) | |
tree | 39fbb69a93b81351a94924ea6cf34ab902649c8b /sound | |
parent | af536542ed360e824c0f1addb68e91b5ca367aa2 (diff) | |
download | scummvm-rg350-7eb407be80857b27c718e4e6f22de61c4d88b183.tar.gz scummvm-rg350-7eb407be80857b27c718e4e6f22de61c4d88b183.tar.bz2 scummvm-rg350-7eb407be80857b27c718e4e6f22de61c4d88b183.zip |
Cleanup raw looping code
svn-id: r47471
Diffstat (limited to 'sound')
-rw-r--r-- | sound/raw.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/sound/raw.cpp b/sound/raw.cpp index 75d60bf37a..ef77f3040f 100644 --- a/sound/raw.cpp +++ b/sound/raw.cpp @@ -365,25 +365,20 @@ AudioStream *makeRawMemoryStream(const byte *ptr, uint32 len, uint loopStart, uint loopEnd) { SeekableAudioStream *s = makeRawMemoryStream(ptr, len, autoFree, rate, flags); - const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; - const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0; - const bool isLooping = (flags & Audio::FLAG_LOOP) != 0; + if ((flags & Audio::FLAG_LOOP) != 0) { + const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; + const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0; - if (isLooping) { - uint loopOffset = 0, loopLen = 0; if (loopEnd == 0) loopEnd = len; assert(loopStart <= loopEnd); assert(loopEnd <= len); - loopOffset = loopStart; - loopLen = loopEnd - loopStart; - // Verify the buffer sizes are sane if (is16Bit && isStereo) - assert((loopLen & 3) == 0 && (loopStart & 3) == 0 && (loopEnd & 3) == 0); + assert((loopStart & 3) == 0 && (loopEnd & 3) == 0); else if (is16Bit || isStereo) - assert((loopLen & 1) == 0 && (loopStart & 1) == 0 && (loopEnd & 1) == 0); + assert((loopStart & 1) == 0 && (loopEnd & 1) == 0); const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1); @@ -431,27 +426,22 @@ AudioStream *makeRawDiskStream(Common::SeekableReadStream *stream, RawDiskStream int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd) { SeekableAudioStream *s = makeRawDiskStream(stream, block, numBlocks, rate, flags, disposeStream); - const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; - const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0; - const bool isLooping = (flags & Audio::FLAG_LOOP) != 0; + if ((flags & Audio::FLAG_LOOP) != 0) { + const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; + const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0; - if (isLooping) { const uint len = s->getLength().totalNumberOfFrames() / (is16Bit ? 2 : 1) / (isStereo ? 2 : 1); - uint loopOffset = 0, loopLen = 0; if (loopEnd == 0) loopEnd = len; assert(loopStart <= loopEnd); assert(loopEnd <= len); - loopOffset = loopStart; - loopLen = loopEnd - loopStart; - // Verify the buffer sizes are sane if (is16Bit && isStereo) - assert((loopLen & 3) == 0 && (loopStart & 3) == 0 && (loopEnd & 3) == 0); + assert((loopStart & 3) == 0 && (loopEnd & 3) == 0); else if (is16Bit || isStereo) - assert((loopLen & 1) == 0 && (loopStart & 1) == 0 && (loopEnd & 3) == 0); + assert((loopStart & 1) == 0 && (loopEnd & 1) == 0); const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1); |