From 5b2a60d0495c76c32e358e8a2dff6c82f7ddd710 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 9 Jun 2010 13:34:15 +0000 Subject: Rewind the underlying audio stream on LoopingAudioStream creation. Also mention in the documentation that both LoopingAudioStream and SubLoopingAudioStream do rewind the underlying in their constructor. svn-id: r49539 --- sound/audiostream.cpp | 6 ++++++ sound/audiostream.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index ce2c521e5e..a092e6c29d 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -95,6 +95,12 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) { + assert(stream); + + if (!stream->rewind()) { + // TODO: Properly indicate error + _loops = _completeIterations = 1; + } } LoopingAudioStream::~LoopingAudioStream() { diff --git a/sound/audiostream.h b/sound/audiostream.h index 37a1953bb9..edf517b003 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -109,6 +109,9 @@ public: /** * Creates a looping audio stream object. * + * Note that on creation of the LoopingAudioStream object + * the underlying stream will be rewound. + * * @see makeLoopingAudioStream * * @param stream Stream to loop @@ -232,6 +235,9 @@ public: /** * Constructor for a SubLoopingAudioStream. * + * Note that on creation of the LoopingAudioStream object + * the underlying stream will be rewound. + * * @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) -- cgit v1.2.3