[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.13,1.14 mixer.h,1.7,1.8

Pawe? Ko?odziejski aquadran at users.sourceforge.net
Tue Oct 15 00:02:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv30178

Modified Files:
	mixer.cpp mixer.h 
Log Message:
changes to soundmixer - added timeout param to stream

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mixer.cpp	2 Oct 2002 17:31:54 -0000	1.13
+++ mixer.cpp	15 Oct 2002 07:01:33 -0000	1.14
@@ -107,8 +107,14 @@
 }
 
 int SoundMixer::playStream(PlayingSoundHandle * handle, int idx, void * sound, uint32 size,
-														uint rate, byte flags) {
-	return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags));
+														uint rate, byte flags, int32 timeout) {
+	return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags, timeout));
+}
+
+void SoundMixer::stopChannel(int index) {
+	if (_channels[index] == NULL) {
+		_channels[index]->_toBeDestroyed = true;
+	}
 }
 
 #ifdef COMPRESSED_SOUND_FILE
@@ -613,7 +619,7 @@
 }
 
 SoundMixer::ChannelStream::ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate,
-										 byte flags) {
+										 byte flags, int32 timeout) {
 	_mixer = mixer;
 	_flags = flags;
 	_bufferSize = 2000000;
@@ -627,6 +633,7 @@
 	_fpPos = 0;
 	_fpSpeed = (1 << 16) * rate / mixer->_outputRate;
 	_toBeDestroyed = false;
+	_setTimeOut = timeout;
 
 	/* adjust the magnitute to prevent division error */
 	while (size & 0xFFFF0000)
@@ -671,6 +678,9 @@
 	}
 
 	if (_pos == end_of_data) {
+		if (_timeOut == -1) {
+			return;
+		}
 		if (--_timeOut == 0) {
 			realDestroy();
 		}
@@ -690,7 +700,7 @@
 			mixer_helper_table[_flags & 0x07] (data, &len, &_pos, &fp_pos, fp_speed, vol_tab, end_of_data, (_flags & FLAG_REVERSE_STEREO) ? true : false);
 		}
 	}
-	_timeOut = 3;
+	_timeOut = _setTimeOut;
 	_fpPos = fp_pos;
 }
 

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mixer.h	2 Oct 2002 17:31:55 -0000	1.7
+++ mixer.h	15 Oct 2002 07:01:34 -0000	1.8
@@ -80,11 +80,12 @@
 		uint32 _fpPos;
 		uint32 _bufferSize;
 		uint32 _rate;
-		uint32 _timeOut;
+		int32 _timeOut;
+		int32 _setTimeOut;
 		byte _flags;
 
 	public:
-		ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags);
+		ChannelStream(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int32 timout);
 
 		void append(void * sound, uint32 size);
 		void mix(int16 * data, uint len);
@@ -182,7 +183,8 @@
 	int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags);
 	int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id);
 	int playStream(PlayingSoundHandle * handle, int index, void * sound, uint32 size, uint rate,
-									byte flags);
+									byte flags, int32 timeout = 3);
+	void stopChannel(int index);
 #ifdef COMPRESSED_SOUND_FILE
 	int playMP3(PlayingSoundHandle * handle, void * sound, uint32 size, byte flags);
 	int playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration);





More information about the Scummvm-git-logs mailing list