diff options
-rw-r--r-- | sound/audiostream.cpp | 2 | ||||
-rw-r--r-- | sound/audiostream.h | 10 | ||||
-rw-r--r-- | sound/decoders/iff_sound.cpp | 4 |
3 files changed, 15 insertions, 1 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 1d81eba608..ce2c521e5e 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -169,6 +169,8 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), _done(false) { + assert(loopStart < loopEnd); + if (!_parent->rewind()) _done = true; } diff --git a/sound/audiostream.h b/sound/audiostream.h index 1cb6a422c2..37a1953bb9 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -229,6 +229,16 @@ AudioStream *makeLoopingAudioStream(SeekableAudioStream *stream, Timestamp start */ class SubLoopingAudioStream : public AudioStream { public: + /** + * Constructor for a SubLoopingAudioStream. + * + * @param stream Stream to loop + * @param loops How often the stream should be looped (0 means infinite) + * @param loopStart Start of the loop (this must be smaller than loopEnd) + * @param loopEnd End of the loop (thus must be greater than loopStart) + * @param disposeAfterUse Whether the stream should be disposed, when the + * SubLoopingAudioStream is destroyed. + */ SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, diff --git a/sound/decoders/iff_sound.cpp b/sound/decoders/iff_sound.cpp index b365015a2b..92054901e4 100644 --- a/sound/decoders/iff_sound.cpp +++ b/sound/decoders/iff_sound.cpp @@ -117,9 +117,11 @@ AudioStream *make8SVXStream(Common::ReadStream &input, bool loop) { loopStart = loader._header.oneShotHiSamples; loopEnd = loader._header.oneShotHiSamples + loader._header.repeatHiSamples; - return new SubLoopingAudioStream(stream, 0, + if (loopStart != loopEnd) { + return new SubLoopingAudioStream(stream, 0, Timestamp(0, loopStart, loader._header.samplesPerSec), Timestamp(0, loopEnd, loader._header.samplesPerSec)); + } } return stream; |