[Scummvm-cvs-logs] SF.net SVN: scummvm:[47159] scummvm/trunk/sound

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Jan 8 17:25:51 CET 2010


Revision: 47159
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47159&view=rev
Author:   lordhoto
Date:     2010-01-08 16:25:51 +0000 (Fri, 08 Jan 2010)

Log Message:
-----------
Add another makeLoopingAudioStream factory for transparently looping a certain interval of a SeekableAudioStream.

Modified Paths:
--------------
    scummvm/trunk/sound/audiostream.cpp
    scummvm/trunk/sound/audiostream.h

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-08 16:21:36 UTC (rev 47158)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-08 16:25:51 UTC (rev 47159)
@@ -144,6 +144,22 @@
 		return stream;
 }
 
+AudioStream *makeLoopingAudioStream(SeekableAudioStream *stream, Timestamp start, Timestamp end, uint loops) {
+	if (!start.totalNumberOfFrames() && (!end.totalNumberOfFrames() || end == stream->getLength())) {
+		return makeLoopingAudioStream(stream, loops);
+	} else {
+		if (!end.totalNumberOfFrames())
+			end = stream->getLength();
+
+		if (start > end) {
+			delete stream;
+			return 0;
+		}
+
+		return makeLoopingAudioStream(new SubSeekableAudioStream(stream, start, end), loops);
+	}
+}
+
 #pragma mark -
 #pragma mark --- SubSeekableAudioStream ---
 #pragma mark -

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-08 16:21:36 UTC (rev 47158)
+++ scummvm/trunk/sound/audiostream.h	2010-01-08 16:25:51 UTC (rev 47159)
@@ -197,6 +197,25 @@
 };
 
 /**
+ * Wrapper functionallity to efficiently create a stream, which might be looped
+ * in a certain interval.
+ *
+ * This automatically starts the stream at time "start"!
+ *
+ * Note that this function does not return a LoopingAudioStream, because it does
+ * not create one, when the loop count is "1". This allows to keep the runtime
+ * overhead down, when the code does not require any functionallity only offered
+ * by LoopingAudioStream.
+ *
+ * @param stream Stream to loop (will be automatically destroyed, when the looping is done)
+ * @param start Starttime of the stream interval to be looped
+ * @param end End of the stream interval to be looped (a zero time, means till end)
+ * @param loops How often to loop (0 = infinite)
+ * @return A new AudioStream, which offers the desired functionallity.
+ */
+AudioStream *makeLoopingAudioStream(SeekableAudioStream *stream, Timestamp start, Timestamp end, uint loops);
+
+/**
  * A SubSeekableAudioStream provides access to a SeekableAudioStream
  * just in the range [start, end).
  * The same caveats apply to SubSeekableAudioStream as do to SeekableAudioStream.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list