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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jan 7 15:23:42 CET 2010


Revision: 47113
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47113&view=rev
Author:   lordhoto
Date:     2010-01-07 14:23:42 +0000 (Thu, 07 Jan 2010)

Log Message:
-----------
Add a playInputStreamLooping for RewindableAudioStream to Mixer.

Modified Paths:
--------------
    scummvm/trunk/sound/mixer.cpp
    scummvm/trunk/sound/mixer.h
    scummvm/trunk/sound/mixer_intern.h

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2010-01-07 14:22:57 UTC (rev 47112)
+++ scummvm/trunk/sound/mixer.cpp	2010-01-07 14:23:42 UTC (rev 47113)
@@ -264,33 +264,42 @@
 	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);
 

Modified: scummvm/trunk/sound/mixer.h
===================================================================
--- scummvm/trunk/sound/mixer.h	2010-01-07 14:22:57 UTC (rev 47112)
+++ scummvm/trunk/sound/mixer.h	2010-01-07 14:23:42 UTC (rev 47113)
@@ -37,6 +37,7 @@
 namespace Audio {
 
 class AudioStream;
+class RewindableAudioStream;
 class SeekableAudioStream;
 class Channel;
 class Mixer;
@@ -179,10 +180,41 @@
 	 * @param type	the type (voice/sfx/music) of the stream
 	 * @param handle	a SoundHandle which can be used to reference and control
 	 *                  the stream via suitable mixer methods
+	 * @param input	the actual RewindableAudioStream to be played
+	 * @param loopCount			how often the data shall be looped (0 = infinite)
+	 * @param id	a unique id assigned to this stream
+	 * @param volume	the volume with which to play the sound, ranging from 0 to 255
+	 * @param balance	the balance with which to play the sound, ranging from -128 to 127
+	 * @param autofreeStream	a flag indicating whether the stream should be
+	 *                          freed after playback finished
+	 * @param permanent	a flag indicating whether a plain stopAll call should
+	 *                  not stop this particular stream
+	 * @param reverseStereo	a flag indicating whether left and right channels shall be swapped
+	 */
+	void playInputStreamLooping(
+		SoundType type,
+		SoundHandle *handle,
+		RewindableAudioStream *input,
+		uint loopCount,
+		int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
+		bool autofreeStream = true,
+		bool permanent = false,
+		bool reverseStereo = false);
+
+	/**
+	 * Start playing the given audio input stream with looping.
+	 *
+	 * Note that the sound id assigned below is unique. At most one stream
+	 * with a given id can play at any given time. Trying to play a sound
+	 * with an id that is already in use causes the new sound to be not played.
+	 *
+	 * @param type	the type (voice/sfx/music) of the stream
+	 * @param handle	a SoundHandle which can be used to reference and control
+	 *                  the stream via suitable mixer methods
 	 * @param input	the actual SeekableAudioStream to be played
 	 * @param loopCount			how often the data shall be looped (0 = infinite)
-	 * @param loopStart			the (optional) time offset from which to start playback
-	 * @param loopEnd			the (optional) time offset where the loop should end
+	 * @param loopStart			the time offset from which to start playback
+	 * @param loopEnd			the time offset where the loop should end
 	 * @param id	a unique id assigned to this stream
 	 * @param volume	the volume with which to play the sound, ranging from 0 to 255
 	 * @param balance	the balance with which to play the sound, ranging from -128 to 127
@@ -192,16 +224,16 @@
 	 *                  not stop this particular stream
 	 * @param reverseStereo	a flag indicating whether left and right channels shall be swapped
 	 */
-	virtual void playInputStreamLooping(
+	void playInputStreamLooping(
 		SoundType type,
 		SoundHandle *handle,
 		SeekableAudioStream *input,
 		uint loopCount,
-		Timestamp loopStart = Timestamp(0, 1000), Timestamp loopEnd = Timestamp(0, 1000),
+		Timestamp loopStart, Timestamp loopEnd,
 		int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
 		bool autofreeStream = true,
 		bool permanent = false,
-		bool reverseStereo = false) = 0;
+		bool reverseStereo = false);
 
 	/**
 	 * Stop all currently playing sounds.

Modified: scummvm/trunk/sound/mixer_intern.h
===================================================================
--- scummvm/trunk/sound/mixer_intern.h	2010-01-07 14:22:57 UTC (rev 47112)
+++ scummvm/trunk/sound/mixer_intern.h	2010-01-07 14:23:42 UTC (rev 47113)
@@ -90,17 +90,6 @@
 		bool permanent,
 		bool reverseStereo);
 
-	virtual void 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);
-
 	virtual void stopAll();
 	virtual void stopID(int id);
 	virtual void stopHandle(SoundHandle handle);


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