From 6abc10c6eafd888db6c3da124155dd1c939c8e97 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 7 Jan 2010 14:23:42 +0000 Subject: Add a playInputStreamLooping for RewindableAudioStream to Mixer. svn-id: r47113 --- sound/mixer.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'sound/mixer.cpp') diff --git a/sound/mixer.cpp b/sound/mixer.cpp index cc1bfe036a..a59768b189 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -264,33 +264,42 @@ void MixerImpl::playInputStream( insertChannel(handle, chan); } -void MixerImpl::playInputStreamLooping( +void Mixer::playInputStreamLooping( SoundType type, SoundHandle *handle, - SeekableAudioStream *input, + RewindableAudioStream *input, uint loopCount, - Timestamp loopStart, Timestamp loopEnd, int id, byte volume, int8 balance, bool autofreeStream, bool permanent, bool reverseStereo) { - if (loopStart.msecs() != 0 || loopEnd.msecs() != 0) { - if (loopEnd.msecs() == 0) - loopEnd = input->getLength(); - - input = new SubSeekableAudioStream(input, loopStart, loopEnd, autofreeStream); - assert(input); - - autofreeStream = true; - } - LoopingAudioStream *loopingStream = new LoopingAudioStream(input, loopCount, autofreeStream); assert(loopingStream); playInputStream(type, handle, loopingStream, id, volume, balance, true, permanent, reverseStereo); } +void Mixer::playInputStreamLooping( + SoundType type, + SoundHandle *handle, + SeekableAudioStream *input, + uint loopCount, + Timestamp loopStart, Timestamp loopEnd, + int id, byte volume, int8 balance, + bool autofreeStream, + bool permanent, + bool reverseStereo) { + + if (loopStart >= loopEnd) + return; + + input = new SubSeekableAudioStream(input, loopStart, loopEnd, autofreeStream); + assert(input); + + playInputStreamLooping(type, handle, input, loopCount, id, volume, balance, true, permanent, reverseStereo); +} + void MixerImpl::mixCallback(byte *samples, uint len) { assert(samples); -- cgit v1.2.3