[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.128,1.129 mixer.h,1.55,1.56

Joost Peters joostp at users.sourceforge.net
Fri Oct 24 16:10:10 CEST 2003


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv26508/sound

Modified Files:
	mixer.cpp mixer.h 
Log Message:
added extra flag to mixer so we don't use free() on new'd pointers

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- mixer.cpp	4 Oct 2003 11:50:20 -0000	1.128
+++ mixer.cpp	24 Oct 2003 23:09:00 -0000	1.129
@@ -44,6 +44,7 @@
 	RateConverter *_converter;
 	AudioInputStream *_input;
 	byte _volume;
+	byte _flags;
 	int8 _pan;
 	bool _paused;
 
@@ -510,6 +511,7 @@
 	: Channel(mixer, handle) {
 	_id = id;
 	_ptr = (byte *)sound;
+	_flags = flags;
 	_volume = volume;
 	_pan = pan;
 	
@@ -533,7 +535,10 @@
 }
 
 ChannelRaw::~ChannelRaw() {
-	free(_ptr);
+	if (_flags & SoundMixer::FLAG_AUTOFREE)
+		free(_ptr);
+	else if (_flags & SoundMixer::FLAG_AUTODELETE)
+		delete _ptr;
 }
 
 ChannelStream::ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle,

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- mixer.h	5 Oct 2003 17:42:55 -0000	1.55
+++ mixer.h	24 Oct 2003 23:09:01 -0000	1.56
@@ -55,7 +55,9 @@
 		FLAG_16BITS = 1 << 2,           // sound is 16 bits wide (default: 8bit)
 		FLAG_AUTOFREE = 1 << 3,         // sound buffer is freed automagically at the end of playing
 		FLAG_REVERSE_STEREO = 1 << 4,   // reverse the left and right stereo channel
-		FLAG_LOOP = 1 << 5              // loop the audio
+		FLAG_LOOP = 1 << 5,             // loop the audio
+		FLAG_AUTODELETE = 1 << 6        // same as AUTOFREE, but uses delete instead of free()
+			
 	};
 
 private:





More information about the Scummvm-git-logs mailing list