diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 13 | ||||
-rw-r--r-- | sound/audiostream.h | 2 | ||||
-rw-r--r-- | sound/mixer.cpp | 12 | ||||
-rw-r--r-- | sound/voc.cpp | 2 | ||||
-rw-r--r-- | sound/wave.cpp | 2 |
5 files changed, 16 insertions, 15 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 4363de3749..d0711266b1 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -200,13 +200,24 @@ int LinearMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buf } else \ return new LinearMemoryStream<STEREO, false, UNSIGNED, false>(rate, ptr, len, loopOffset, loopLen, autoFree) -AudioStream *makeLinearInputStream(int rate, byte flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen) { +AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte flags, uint loopStart, uint loopEnd) { const bool isStereo = (flags & Audio::Mixer::FLAG_STEREO) != 0; const bool is16Bit = (flags & Audio::Mixer::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Audio::Mixer::FLAG_UNSIGNED) != 0; const bool isLE = (flags & Audio::Mixer::FLAG_LITTLE_ENDIAN) != 0; const bool autoFree = (flags & Audio::Mixer::FLAG_AUTOFREE) != 0; + uint loopOffset = 0, loopLen = 0; + if (flags & Audio::Mixer::FLAG_LOOP) { + if (loopEnd == 0) + loopEnd = len; + assert(loopStart <= loopEnd); + assert(loopEnd <= len); + + loopOffset = loopStart; + loopLen = loopEnd - loopStart; + } + if (isStereo) { if (isUnsigned) { MAKE_LINEAR(true, true); diff --git a/sound/audiostream.h b/sound/audiostream.h index 499fb782ab..9cd8113147 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -97,7 +97,7 @@ public: * it to the sample format used by the mixer (i.e. 16 bit signed native endian). * Optionally supports (infinite) looping of a portion of the data. */ -AudioStream *makeLinearInputStream(int rate, byte flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen); +AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte flags, uint loopStart, uint loopEnd); /** * An audio stream to which additional data can be appended on-the-fly. diff --git a/sound/mixer.cpp b/sound/mixer.cpp index b4b9e1134e..0b9ffe3abe 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -157,17 +157,7 @@ void Mixer::playRaw( uint32 loopStart, uint32 loopEnd) { // Create the input stream - AudioStream *input; - if (flags & Mixer::FLAG_LOOP) { - if (loopEnd == 0) { - input = makeLinearInputStream(rate, flags, (byte *)sound, size, 0, size); - } else { - assert(loopStart < loopEnd && loopEnd <= size); - input = makeLinearInputStream(rate, flags, (byte *)sound, size, loopStart, loopEnd - loopStart); - } - } else { - input = makeLinearInputStream(rate, flags, (byte *)sound, size, 0, 0); - } + AudioStream *input = makeLinearInputStream((byte *)sound, size, rate, flags, loopStart, loopEnd); // Play it playInputStream(type, handle, input, id, volume, balance, true, false, (flags & Mixer::FLAG_REVERSE_STEREO)); diff --git a/sound/voc.cpp b/sound/voc.cpp index 726b555a79..2c235c05ca 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -154,7 +154,7 @@ AudioStream *makeVOCStream(Common::ReadStream &stream) { if (!data) return 0; - return makeLinearInputStream(rate, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED, data, size, 0, 0); + return makeLinearInputStream(data, size, rate, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED, 0, 0); } diff --git a/sound/wave.cpp b/sound/wave.cpp index 63bd498686..a0f1f675fb 100644 --- a/sound/wave.cpp +++ b/sound/wave.cpp @@ -192,7 +192,7 @@ AudioStream *makeWAVStream(Common::SeekableReadStream &stream) { // Since we allocated our own buffer for the data, we must set the autofree flag. flags |= Audio::Mixer::FLAG_AUTOFREE; - return makeLinearInputStream(rate, flags, data, size, 0, 0); + return makeLinearInputStream(data, size, rate, flags, 0, 0); } } // End of namespace Audio |