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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Jan 19 01:56:29 CET 2010


Revision: 47369
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47369&view=rev
Author:   fingolfin
Date:     2010-01-19 00:56:29 +0000 (Tue, 19 Jan 2010)

Log Message:
-----------
Get rid of Mixer::FLAG_AUTOFREE.
Also fix several recently introduced new/delete vs. malloc/free mismatches.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/sound.cpp
    scummvm/trunk/engines/cine/sound.cpp
    scummvm/trunk/engines/draci/sound.cpp
    scummvm/trunk/engines/drascula/sound.cpp
    scummvm/trunk/engines/groovie/roq.cpp
    scummvm/trunk/engines/groovie/vdx.cpp
    scummvm/trunk/engines/kyra/sound_towns.cpp
    scummvm/trunk/engines/kyra/vqa.cpp
    scummvm/trunk/engines/m4/sound.cpp
    scummvm/trunk/engines/made/pmvplayer.cpp
    scummvm/trunk/engines/made/resource.cpp
    scummvm/trunk/engines/mohawk/sound.cpp
    scummvm/trunk/engines/mohawk/video/qt_player.cpp
    scummvm/trunk/engines/parallaction/sound_br.cpp
    scummvm/trunk/engines/parallaction/sound_ns.cpp
    scummvm/trunk/engines/queen/sound.cpp
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/engines/saga/sound.cpp
    scummvm/trunk/engines/sci/sound/audio.cpp
    scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
    scummvm/trunk/engines/sci/sound/music.cpp
    scummvm/trunk/engines/scumm/he/cup_player_he.cpp
    scummvm/trunk/engines/scumm/he/sound_he.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
    scummvm/trunk/engines/scumm/player_mod.cpp
    scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
    scummvm/trunk/engines/scumm/smush/saud_channel.cpp
    scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.cpp
    scummvm/trunk/engines/scumm/sound.cpp
    scummvm/trunk/engines/sky/intro.cpp
    scummvm/trunk/engines/sky/sound.cpp
    scummvm/trunk/engines/sword1/sound.cpp
    scummvm/trunk/engines/teenagent/teenagent.cpp
    scummvm/trunk/engines/tinsel/bmv.cpp
    scummvm/trunk/engines/tinsel/sound.cpp
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/graphics/video/avi_decoder.cpp
    scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
    scummvm/trunk/graphics/video/smk_decoder.cpp
    scummvm/trunk/sound/aiff.cpp
    scummvm/trunk/sound/audiostream.cpp
    scummvm/trunk/sound/audiostream.h
    scummvm/trunk/sound/iff_sound.cpp
    scummvm/trunk/sound/mixer.cpp
    scummvm/trunk/sound/mixer.h
    scummvm/trunk/sound/mixer_intern.h
    scummvm/trunk/sound/raw.cpp
    scummvm/trunk/sound/raw.h
    scummvm/trunk/sound/shorten.cpp
    scummvm/trunk/sound/voc.cpp
    scummvm/trunk/sound/wave.cpp

Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/agos/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -277,7 +277,7 @@
 	byte *buffer = (byte *)malloc(size);
 	assert(buffer);
 	_file->read(buffer, size);
-	_mixer->playRaw(type, handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE);
+	_mixer->playRaw(type, handle, buffer, size, DisposeAfterUse::YES, 22050, flags);
 }
 
 #ifdef USE_MAD
@@ -740,10 +740,10 @@
 	byte *buffer = (byte *)malloc(size);
 	memcpy(buffer, soundData, size);
 
+	byte flags = 0;
 	if (_vm->getPlatform() == Common::kPlatformPC)
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, freq, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE);
-	else
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, freq, Audio::Mixer::FLAG_AUTOFREE);
+		flags = Audio::Mixer::FLAG_UNSIGNED;
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, DisposeAfterUse::YES, freq, flags);
 }
 
 // Feeble Files specific

Modified: scummvm/trunk/engines/cine/sound.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/cine/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -844,7 +844,7 @@
 void PaulaSound::playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume) {
 	assert(frequency > 0);
 	frequency = PAULA_FREQ / frequency;
-	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, frequency, Audio::Mixer::FLAG_AUTOFREE);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, DisposeAfterUse::YES, frequency, 0);
 	_mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
 }
 

Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/draci/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -194,7 +194,6 @@
 void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
 				sndHandleType handleType, bool loop) {
 
-	// Don't use FLAG_AUTOFREE, because our caching system deletes samples by itself.
 	byte flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	if (loop)
@@ -203,8 +202,9 @@
 	const Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ? 
 				Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
 
+	// Don't use DisposeAfterUse::YES, because our caching system deletes samples by itself.
 	_mixer->playRaw(soundType, handle, buffer._data,
-			buffer._length, buffer._frequency, flags, -1, volume);
+			buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, -1, volume);
 }
 
 void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {

Modified: scummvm/trunk/engines/drascula/sound.cpp
===================================================================
--- scummvm/trunk/engines/drascula/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/drascula/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -182,8 +182,8 @@
 		if (ConfMan.getBool("speech_mute"))
 			memset(soundData, 0x80, soundSize); // Mute speech but keep the pause
 
-		_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_soundHandle, soundData, soundSize - 64,
-						11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED);
+		_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_soundHandle, soundData, soundSize - 64, DisposeAfterUse::YES,
+						11025, Audio::Mixer::FLAG_UNSIGNED);
 	} else
 		warning("playFile: Could not open %s", fname);
 }

Modified: scummvm/trunk/engines/groovie/roq.cpp
===================================================================
--- scummvm/trunk/engines/groovie/roq.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/groovie/roq.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -522,7 +522,7 @@
 	}
 
 	// Create the audio buffer
-	int16 *buffer = new int16[blockHeader.size];
+	int16 *buffer = (int16 *)malloc(blockHeader.size * 2);
 
 	// Initialize the prediction with the block parameter
 	int16 prediction = blockHeader.param ^ 0x8000;
@@ -540,11 +540,11 @@
 	}
 
 	// Queue the read buffer
-	byte flags = Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE;
+	byte flags = Audio::Mixer::FLAG_16BITS;
 #ifdef SCUMM_LITTLE_ENDIAN
 	flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
 #endif
-	_audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, flags);
+	_audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
 
 	return true;
 }
@@ -565,7 +565,7 @@
 	}
 
 	// Create the audio buffer
-	int16 *buffer = new int16[blockHeader.size];
+	int16 *buffer = (int16 *)malloc(blockHeader.size * 2);
 
 	// Initialize the prediction with the block parameter
 	int16 predictionLeft = (blockHeader.param & 0xFF00) ^ 0x8000;
@@ -596,11 +596,11 @@
 	}
 
 	// Queue the read buffer
-	byte flags = Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_STEREO;
+	byte flags = Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO;
 #ifdef SCUMM_LITTLE_ENDIAN
 	flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
 #endif
-	_audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, flags);
+	_audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
 
 	return true;
 }

Modified: scummvm/trunk/engines/groovie/vdx.cpp
===================================================================
--- scummvm/trunk/engines/groovie/vdx.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/groovie/vdx.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -503,10 +503,10 @@
 		g_system->getMixer()->playInputStream(Audio::Mixer::kPlainSoundType, &sound_handle, _audioStream);
 	}
 
-	byte *data = new byte[60000];
+	byte *data = (byte *)malloc(60000);
 	int chunksize = in->read(data, 60000);
 	if (!Common::isDebugChannelEnabled(kGroovieDebugFast)) {
-		_audioStream->queueBuffer(data, chunksize, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE);
+		_audioStream->queueBuffer(data, chunksize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 	}
 }
 

Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -3925,8 +3925,8 @@
 
 	uint32 outputRate = uint32(11025 * calculatePhaseStep(note, sfxRootNoteOffs, sfxRate, 11025, 0x2000));
 
-	_currentSFX = Audio::makeRawMemoryStream(sfxPlaybackBuffer, playbackBufferSize,
-		outputRate, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LITTLE_ENDIAN | Audio::Mixer::FLAG_AUTOFREE, 0, 0);
+	_currentSFX = Audio::makeRawMemoryStream(sfxPlaybackBuffer, playbackBufferSize, DisposeAfterUse::YES,
+		outputRate, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LITTLE_ENDIAN, 0, 0);
 	_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _currentSFX);
 }
 
@@ -4297,8 +4297,8 @@
 
 	uint32 outputRate = uint32(11025 * SoundTowns::calculatePhaseStep(0x3c, 0x3c, sfxRate, 11025, 0x2000));
 
-	_currentSFX = Audio::makeRawMemoryStream(sfx, outsize, outputRate,
-		Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LITTLE_ENDIAN | Audio::Mixer::FLAG_AUTOFREE, 0, 0);
+	_currentSFX = Audio::makeRawMemoryStream(sfx, outsize, DisposeAfterUse::YES, outputRate,
+		Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LITTLE_ENDIAN, 0, 0);
 	_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_soundChannels[h], _currentSFX);
 	if (handle)
 		*handle = _soundChannels[h];

Modified: scummvm/trunk/engines/kyra/vqa.cpp
===================================================================
--- scummvm/trunk/engines/kyra/vqa.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/kyra/vqa.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -419,10 +419,10 @@
 		switch (tag) {
 		case MKID_BE('SND0'):	// Uncompressed sound
 			foundSound = true;
-			inbuf = new byte[size];
+			inbuf = (byte *)malloc(size);
 			_file->read(inbuf, size);
 			assert(_stream);
-			_stream->queueBuffer(inbuf, size, Audio::Mixer::FLAG_UNSIGNED);
+			_stream->queueBuffer(inbuf, size, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 			break;
 
 		case MKID_BE('SND1'):	// Compressed sound, almost like AUD
@@ -430,18 +430,18 @@
 			outsize = _file->readUint16LE();
 			insize = _file->readUint16LE();
 
-			inbuf = new byte[insize];
+			inbuf = (byte *)malloc(insize);
 			_file->read(inbuf, insize);
 
 			if (insize == outsize) {
 				assert(_stream);
-				_stream->queueBuffer(inbuf, insize, Audio::Mixer::FLAG_UNSIGNED);
+				_stream->queueBuffer(inbuf, insize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 			} else {
-				outbuf = new byte[outsize];
+				outbuf = (byte *)malloc(outsize);
 				decodeSND1(inbuf, insize, outbuf, outsize);
 				assert(_stream);
-				_stream->queueBuffer(outbuf, outsize, Audio::Mixer::FLAG_UNSIGNED);
-				delete[] inbuf;
+				_stream->queueBuffer(outbuf, outsize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
+				free(inbuf);
 			}
 			break;
 
@@ -610,25 +610,25 @@
 
 			switch (tag) {
 			case MKID_BE('SND0'):	// Uncompressed sound
-				inbuf = new byte[size];
+				inbuf = (byte *)malloc(size);
 				_file->read(inbuf, size);
-				_stream->queueBuffer(inbuf, size, Audio::Mixer::FLAG_UNSIGNED);
+				_stream->queueBuffer(inbuf, size, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 				break;
 
 			case MKID_BE('SND1'):	// Compressed sound
 				outsize = _file->readUint16LE();
 				insize = _file->readUint16LE();
 
-				inbuf = new byte[insize];
+				inbuf = (byte *)malloc(insize);
 				_file->read(inbuf, insize);
 
 				if (insize == outsize) {
-					_stream->queueBuffer(inbuf, insize, Audio::Mixer::FLAG_UNSIGNED);
+					_stream->queueBuffer(inbuf, insize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 				} else {
-					outbuf = new byte[outsize];
+					outbuf = (byte *)malloc(outsize);
 					decodeSND1(inbuf, insize, outbuf, outsize);
-					_stream->queueBuffer(outbuf, outsize, Audio::Mixer::FLAG_UNSIGNED);
-					delete[] inbuf;
+					_stream->queueBuffer(outbuf, outsize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
+					free(inbuf);
 				}
 				break;
 

Modified: scummvm/trunk/engines/m4/sound.cpp
===================================================================
--- scummvm/trunk/engines/m4/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/m4/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -88,8 +88,7 @@
 	_vm->res()->toss(soundName);
 
 	handle->type = kEffectHandle;
-	flags = Audio::Mixer::FLAG_AUTOFREE;
-	flags |= Audio::Mixer::FLAG_UNSIGNED;
+	flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	if (loop)
 		flags |= Audio::Mixer::FLAG_LOOP;
@@ -97,7 +96,7 @@
 	_vm->res()->toss(soundName);
 
 	// Sound format is 8bit mono, unsigned, 11025kHz
-	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, bufferSize, 11025, flags, -1, volume);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, -1, volume);
 }
 
 void Sound::pauseSound() {
@@ -144,13 +143,12 @@
 	soundStream->read(buffer, soundStream->size());
 
 	handle->type = kEffectHandle;
-	flags = Audio::Mixer::FLAG_AUTOFREE;
-	flags |= Audio::Mixer::FLAG_UNSIGNED;
+	flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	_vm->res()->toss(soundName);
 
 	// Voice format is 8bit mono, unsigned, 11025kHz
-	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, soundStream->size(), 11025, flags, -1, volume);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags, -1, volume);
 }
 
 void Sound::pauseVoice() {
@@ -248,8 +246,7 @@
 	SndHandle *handle = getHandle();
 
 	handle->type = kEffectHandle;
-	flags = Audio::Mixer::FLAG_AUTOFREE;
-	flags |= Audio::Mixer::FLAG_UNSIGNED;
+	flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	if (loop)
 		flags |= Audio::Mixer::FLAG_LOOP;
@@ -268,7 +265,7 @@
 
 	// Play sound
 	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer,
-					_dsrFile.dsrEntries[soundIndex]->uncompSize,
+					_dsrFile.dsrEntries[soundIndex]->uncompSize, DisposeAfterUse::YES,
 					_dsrFile.dsrEntries[soundIndex]->frequency, flags, -1, volume);
 
 	/*

Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/made/pmvplayer.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -138,9 +138,9 @@
 			debug(1, "chunkCount = %d; chunkSize = %d; total = %d\n", chunkCount, chunkSize, chunkCount * chunkSize);
 
 			soundSize = chunkCount * chunkSize;
-			soundData = new byte[soundSize];
+			soundData = (byte *)malloc(soundSize);
 			decompressSound(audioData + 8, soundData, chunkSize, chunkCount);
-			_audioStream->queueBuffer(soundData, soundSize, Audio::Mixer::FLAG_UNSIGNED);
+			_audioStream->queueBuffer(soundData, soundSize, DisposeAfterUse::YES, Audio::Mixer::FLAG_UNSIGNED);
 		}
 
 		// Handle palette

Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/made/resource.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -265,7 +265,7 @@
 	if (loop)
 		flags |= Audio::Mixer::FLAG_LOOP;
 
-	return Audio::makeRawMemoryStream(_soundData, _soundSize, soundRate, flags, 0, 0);
+	return Audio::makeRawMemoryStream(_soundData, _soundSize, DisposeAfterUse::NO, soundRate, flags, 0, 0);
 }
 
 void SoundResourceV1::load(byte *source, int size) {

Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/mohawk/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -435,12 +435,12 @@
 	// The sound in the CD version of Riven is encoded in Intel DVI ADPCM
 	// The sound in the DVD version of Riven is encoded in MPEG-2 Layer II or Intel DVI ADPCM
 	if (data_chunk.encoding == kCodecRaw) {
-		byte flags = Audio::Mixer::FLAG_UNSIGNED|Audio::Mixer::FLAG_AUTOFREE;
+		byte flags = Audio::Mixer::FLAG_UNSIGNED;
 		if (data_chunk.channels == 2)
 			flags |= Audio::Mixer::FLAG_STEREO;
 		if (data_chunk.loop == 0xFFFF || loop)
 			flags |= Audio::Mixer::FLAG_LOOP;
-		return Audio::makeRawMemoryStream(data_chunk.audio_data, data_chunk.size, data_chunk.sample_rate, flags, data_chunk.loopStart, data_chunk.loopEnd);
+		return Audio::makeRawMemoryStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES, data_chunk.sample_rate, flags, data_chunk.loopStart, data_chunk.loopEnd);
 	} else if (data_chunk.encoding == kCodecADPCM) {
 		Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES);
 		uint32 blockAlign = data_chunk.channels * data_chunk.bitsPerSample / 8;
@@ -481,12 +481,12 @@
 	stream->read(data, size);
 	delete stream;
 	
-	byte flags = Audio::Mixer::FLAG_UNSIGNED|Audio::Mixer::FLAG_AUTOFREE;
+	byte flags = Audio::Mixer::FLAG_UNSIGNED;
 	
 	if (loop)
 		flags |= Audio::Mixer::FLAG_LOOP;
 	
-	return Audio::makeRawMemoryStream(data, size, rate, flags, 0, 0);
+	return Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags, 0, 0);
 }
 
 SndHandle *Sound::getHandle() {

Modified: scummvm/trunk/engines/mohawk/video/qt_player.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/qt_player.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/mohawk/video/qt_player.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -1159,7 +1159,7 @@
 		
 	if (_streams[_audioStreamIndex]->codec_tag == MKID_BE('twos') || _streams[_audioStreamIndex]->codec_tag == MKID_BE('raw ')) {
 		// Fortunately, most of the audio used in Myst videos is raw...
-		uint16 flags = Audio::Mixer::FLAG_AUTOFREE;
+		uint16 flags = 0;
 		if (_streams[_audioStreamIndex]->codec_tag == MKID_BE('raw '))
 			flags |= Audio::Mixer::FLAG_UNSIGNED;
 		if (_streams[_audioStreamIndex]->channels == 2)
@@ -1170,7 +1170,7 @@
 		byte *data = (byte *)malloc(dataSize);
 		stream->read(data, dataSize);
 		delete stream;
-		return Audio::makeRawMemoryStream(data, dataSize, _streams[_audioStreamIndex]->sample_rate, flags, 0, 0);
+		return Audio::makeRawMemoryStream(data, dataSize, DisposeAfterUse::YES, _streams[_audioStreamIndex]->sample_rate, flags, 0, 0);
 	} else if (_streams[_audioStreamIndex]->codec_tag == MKID_BE('ima4')) {
 		// Riven uses this codec (as do some Myst ME videos)
 		return Audio::makeADPCMStream(stream, true, stream->size(), Audio::kADPCMApple, _streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels, 34);

Modified: scummvm/trunk/engines/parallaction/sound_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound_br.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/parallaction/sound_br.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -416,14 +416,14 @@
 	int rate = 11025;
 
 	uint32 loopStart = 0, loopEnd = 0;
-	uint32 flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
+	uint32 flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	if (looping) {
 		loopEnd = dataSize;
 		flags |= Audio::Mixer::FLAG_LOOP;
 	}
 
-	ch->stream = Audio::makeRawMemoryStream((byte *)data, dataSize, rate, flags, loopStart, loopEnd);
+	ch->stream = Audio::makeRawMemoryStream((byte *)data, dataSize, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd);
 	return ch->stream;
 }
 
@@ -483,7 +483,7 @@
 
 		// TODO: Confirm sound rate
 		int rate = 11025;
-		input = Audio::makeRawMemoryStream((byte *)data, dataSize, rate, Audio::Mixer::FLAG_AUTOFREE, 0, 0);
+		input = Audio::makeRawMemoryStream((byte *)data, dataSize, DisposeAfterUse::YES, rate, 0, 0, 0);
 	} else {
 		input = Audio::make8SVXStream(*stream, looping);
 	}

Modified: scummvm/trunk/engines/parallaction/sound_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound_ns.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/parallaction/sound_ns.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -377,7 +377,7 @@
 	if (!scumm_stricmp("beep", filename)) {
 		int rate = 11934;
 		ch->volume = 160;
-		input = Audio::makeRawMemoryStream((byte *)beepSoundBuffer, beepSoundBufferSize, rate, 0, 0, 0);
+		input = Audio::makeRawMemoryStream((byte *)beepSoundBuffer, beepSoundBufferSize, DisposeAfterUse::NO, rate, 0, 0, 0);
 	} else {
 		Common::SeekableReadStream *stream = _vm->_disk->loadSound(filename);
 		input = Audio::make8SVXStream(*stream, looping);

Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/queen/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -327,9 +327,8 @@
 	uint8 *sound = (uint8 *)malloc(size);
 	if (sound) {
 		f->read(sound, size);
-		byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
 		Audio::Mixer::SoundType type = (soundHandle == &_speechHandle) ? Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
-		_mixer->playRaw(type, soundHandle, sound, size, 11840, flags);
+		_mixer->playRaw(type, soundHandle, sound, size, DisposeAfterUse::YES, 11840, Audio::Mixer::FLAG_UNSIGNED);
 	}
 }
 
@@ -611,8 +610,7 @@
 		uint8 *soundData = (uint8 *)malloc(soundSize);
 		if (soundData) {
 			f->read(soundData, soundSize);
-			byte flags = Audio::Mixer::FLAG_AUTOFREE;
-			_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_sfxHandle, soundData, soundSize, 11025, flags);
+			_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_sfxHandle, soundData, soundSize, DisposeAfterUse::YES, 11025, 0);
 		}
 	}
 }

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/saga/music.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -304,7 +304,7 @@
 							(uint32)resData->offset + offs, (uint32)resData->offset + resData->size - offs);
 
 				if (!_digitalMusicContext->isCompressed()) {
-					byte musicFlags = Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_STEREO | 
+					byte musicFlags = Audio::Mixer::FLAG_STEREO | 
 										Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_LITTLE_ENDIAN;
 					Audio::RawDiskStreamAudioBlock audioBlocks[1];
 					audioBlocks[0].pos = 0;

Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/saga/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -66,8 +66,6 @@
 void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume,
 				sndHandleType handleType, bool loop) {
 
-	buffer.flags |= Audio::Mixer::FLAG_AUTOFREE;
-
 	if (loop)
 		buffer.flags |= Audio::Mixer::FLAG_LOOP;
 
@@ -76,7 +74,7 @@
 
 	if (!buffer.isCompressed) {
 		_mixer->playRaw(soundType, handle, buffer.buffer,
-				buffer.size, buffer.frequency, buffer.flags, -1, volume);
+				buffer.size, DisposeAfterUse::YES, buffer.frequency, buffer.flags, -1, volume);
 	} else {
 		Audio::AudioStream *stream = 0;
 

Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sci/sound/audio.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -245,7 +245,7 @@
 	}
 
 	if (data)
-		audioStream = Audio::makeRawMemoryStream(data, size, _audioRate, flags | Audio::Mixer::FLAG_AUTOFREE);
+		audioStream = Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, _audioRate, flags);
 
 	if (audioStream) {
 		*sampleLen = (flags & Audio::Mixer::FLAG_16BITS ? size >> 1 : size) * 60 / _audioRate;

Modified: scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/iterator/iterator.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sci/sound/iterator/iterator.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -551,8 +551,8 @@
 	memcpy(sound, data, size);
 
 	// Convert stream format flags
-	int flags = Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED;
-	return Audio::makeRawMemoryStream(sound, size, rate, flags, 0, 0);
+	int flags = Audio::Mixer::FLAG_UNSIGNED;
+	return Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags, 0, 0);
 }
 
 Audio::AudioStream *Sci0SongIterator::getAudioStream() {

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -178,7 +178,7 @@
 		if (track->digitalChannelNr != -1) {
 			byte *channelData = track->channels[track->digitalChannelNr].data;
 			delete pSnd->pStreamAud;
-			pSnd->pStreamAud = Audio::makeRawMemoryStream(channelData, track->digitalSampleSize, track->digitalSampleRate, Audio::Mixer::FLAG_UNSIGNED);
+			pSnd->pStreamAud = Audio::makeRawMemoryStream(channelData, track->digitalSampleSize, DisposeAfterUse::NO, track->digitalSampleRate, Audio::Mixer::FLAG_UNSIGNED);
 			delete pSnd->pLoopStream;
 			pSnd->pLoopStream = 0;
 			pSnd->soundType = Audio::Mixer::kSFXSoundType;

Modified: scummvm/trunk/engines/scumm/he/cup_player_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/cup_player_he.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/he/cup_player_he.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -176,7 +176,7 @@
 					loopEnd = soundSize - 8;
 				}
 				_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &sfxChannel->handle,
-						Audio::makeRawMemoryStream(soundData + 8, soundSize - 8, 11025, flags, 0, loopEnd));
+						Audio::makeRawMemoryStream(soundData + 8, soundSize - 8, DisposeAfterUse::NO, 11025, flags, 0, loopEnd));
 			}
 		} else {
 			warning("Unable to find a free channel to play sound %d", sfx->num);

Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -572,7 +572,7 @@
 		musicFile.close();
 
 		if (_vm->_game.heversion == 70) {
-			_mixer->playRaw(type, &_heSoundChannels[heChannel], spoolPtr, size, 11025, flags, soundID);
+			_mixer->playRaw(type, &_heSoundChannels[heChannel], spoolPtr, size, DisposeAfterUse::NO, 11025, flags, soundID);
 			return;
 		}
 	}
@@ -657,17 +657,15 @@
 			if (_heChannel[heChannel].timer)
 				_heChannel[heChannel].timer = size * 1000 / rate;
 
-			flags |= Audio::Mixer::FLAG_AUTOFREE;
-			
 			// makeADPCMStream returns a stream in native endianness, but RawMemoryStream (and playRaw)
 			// defaults to big endian. If we're on a little endian system, set the LE flag.
 #ifdef SCUMM_LITTLE_ENDIAN
 			flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
 #endif
-			
-			_mixer->playRaw(type, &_heSoundChannels[heChannel], sound + heOffset, size - heOffset, rate, flags, soundID);
+
+			_mixer->playRaw(type, &_heSoundChannels[heChannel], sound + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, soundID);
 		} else {
-			_mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + stream.pos() + heOffset, size - heOffset, rate, flags, soundID);
+			_mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + stream.pos() + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, soundID);
 		}
 	}
 	// Support for sound in Humongous Entertainment games
@@ -725,7 +723,7 @@
 		}
 
 		_mixer->stopHandle(_heSoundChannels[heChannel]);
-		_mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID);
+		_mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + heOffset + 8, size, DisposeAfterUse::NO, rate, flags, soundID);
 	}
 	// Support for PCM music in 3DO versions of Humongous Entertainment games
 	else if (READ_BE_UINT32(ptr) == MKID_BE('MRAW')) {
@@ -738,13 +736,12 @@
 		assert(READ_BE_UINT32(ptr) == MKID_BE('SDAT'));
 		size = READ_BE_UINT32(ptr + 4) - 8;
 
-		flags = Audio::Mixer::FLAG_AUTOFREE;
 		byte *sound = (byte *)malloc(size);
 		memcpy(sound, ptr + 8, size);
 
 		_mixer->stopID(_currentMusic);
 		_currentMusic = soundID;
-		_mixer->playRaw(Audio::Mixer::kMusicSoundType, NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kMusicSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, 0, soundID);
 	}
 	else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) {
 		if (_vm->_imuse) {

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -299,7 +299,7 @@
 						int tmpFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits);
 						curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize);
 
-						delete[] tmpPtr;
+						free(tmpPtr);
 					} else if (bits == 16) {
 						curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize);
 						if (channels == 1) {
@@ -313,7 +313,7 @@
 						if (_radioChatterSFX && track->soundId == 10000) {
 							if (curFeedSize > feedSize)
 								curFeedSize = feedSize;
-							byte *buf = new byte[curFeedSize];
+							byte *buf = (byte *)malloc(curFeedSize);
 							int index = 0;
 							int count = curFeedSize - 4;
 							byte *ptr_1 = tmpSndBufferPtr;
@@ -332,7 +332,7 @@
 							buf[curFeedSize - 2] = 0x80;
 							buf[curFeedSize - 3] = 0x80;
 							buf[curFeedSize - 4] = 0x80;
-							delete[] tmpSndBufferPtr;
+							free(tmpSndBufferPtr);
 							tmpSndBufferPtr = buf;
 						}
 						if (channels == 2) {
@@ -344,10 +344,10 @@
 						curFeedSize = feedSize;
 
 					if (_mixer->isReady()) {
-						track->stream->queueBuffer(tmpSndBufferPtr, curFeedSize, makeMixerFlags(track->mixerFlags));
+						track->stream->queueBuffer(tmpSndBufferPtr, curFeedSize, DisposeAfterUse::YES, makeMixerFlags(track->mixerFlags));
 						track->regionOffset += curFeedSize;
 					} else
-						delete[] tmpSndBufferPtr;
+						free(tmpSndBufferPtr);
 
 					if (_sound->isEndOfRegion(track->soundDesc, track->curRegion)) {
 						switchToNextRegion(track);

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -33,7 +33,7 @@
 uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size) {
 	uint32 loop_size = size / 3;
 	uint32 s_size = loop_size * 4;
-	byte *ptr = *dst = new byte[s_size];
+	byte *ptr = *dst = (byte *)malloc(s_size);
 	assert(ptr);
 
 	uint32 tmp;

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -655,11 +655,11 @@
 	if ((soundDesc->bundle) && (!soundDesc->compressed)) {
 		size = soundDesc->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside);
 	} else if (soundDesc->resPtr) {
-		*buf = new byte[size];
+		*buf = (byte *)malloc(size);
 		assert(*buf);
 		memcpy(*buf, soundDesc->resPtr + start + offset + header_size, size);
 	} else if ((soundDesc->bundle) && (soundDesc->compressed)) {
-		*buf = new byte[size];
+		*buf = (byte *)malloc(size);
 		assert(*buf);
 		char fileName[24];
 		int offsetMs = (((offset * 8 * 10) / soundDesc->bits) / (soundDesc->channels * soundDesc->freq)) * 100;

Modified: scummvm/trunk/engines/scumm/player_mod.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_mod.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/player_mod.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -95,7 +95,7 @@
 	_channels[i].pan = pan;
 	_channels[i].freq = rate;
 	_channels[i].ctr = 0;
-	_channels[i].input = Audio::makeRawMemoryStream((const byte*)data, size, rate, Audio::Mixer::FLAG_AUTOFREE | (loopStart != loopEnd ? Audio::Mixer::FLAG_LOOP : 0), loopStart, loopEnd);
+	_channels[i].input = Audio::makeRawMemoryStream((const byte*)data, size, DisposeAfterUse::YES, rate, (loopStart != loopEnd ? Audio::Mixer::FLAG_LOOP : 0), loopStart, loopEnd);
 	// read the first sample
 	_channels[i].input->readBuffer(&_channels[i].pos, 1);
 }

Modified: scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/imuse_channel.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/smush/imuse_channel.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -69,7 +69,7 @@
 		size -= 8;
 		_tbufferSize = size;
 		assert(_tbufferSize);
-		_tbuffer = new byte[_tbufferSize];
+		_tbuffer = (byte *)malloc(_tbufferSize);
 		if (!_tbuffer)
 			error("imuse_channel failed to allocate memory");
 		b.read(_tbuffer, size);
@@ -78,16 +78,16 @@
 		if (_tbuffer) {
 			byte *old = _tbuffer;
 			int32 new_size = size + _tbufferSize;
-			_tbuffer = new byte[new_size];
+			_tbuffer = (byte *)malloc(new_size);
 			if (!_tbuffer)
 				error("imuse_channel failed to allocate memory");
 			memcpy(_tbuffer, old, _tbufferSize);
-			delete[] old;
+			free(old);
 			b.read(_tbuffer + _tbufferSize, size);
 			_tbufferSize += size;
 		} else {
 			_tbufferSize = size;
-			_tbuffer = new byte[_tbufferSize];
+			_tbuffer = (byte *)malloc(_tbufferSize);
 			if (!_tbuffer)
 				error("imuse_channel failed to allocate memory");
 			b.read(_tbuffer, size);
@@ -152,7 +152,7 @@
 		_srbufferSize -= remaining_size;
 		assert(_inData);
 		if (_tbuffer == 0) {
-			_tbuffer = new byte[remaining_size];
+			_tbuffer = (byte *)malloc(remaining_size);
 			memcpy(_tbuffer, _sbuffer + _sbufferSize - remaining_size, remaining_size);
 			_tbufferSize = remaining_size;
 			_sbufferSize -= remaining_size;
@@ -161,11 +161,11 @@
 				(const void *)this, _dataSize, _inData, _tbuffer, _tbufferSize, _sbuffer, _sbufferSize, _srbufferSize);
 			byte *old = _tbuffer;
 			int new_size = remaining_size + _tbufferSize;
-			_tbuffer = new byte[new_size];
+			_tbuffer = (byte *)malloc(new_size);
 			if (!_tbuffer)
 				error("imuse_channel failed to allocate memory");
 			memcpy(_tbuffer, old, _tbufferSize);
-			delete[] old;
+			free(old);
 			memcpy(_tbuffer + _tbufferSize, _sbuffer + _sbufferSize - remaining_size, remaining_size);
 			_tbufferSize += remaining_size;
 		}
@@ -177,7 +177,7 @@
 	int new_size = loop_size * 4;
 	byte *keep, *decoded;
 	uint32 value;
-	keep = decoded = new byte[new_size];
+	keep = decoded = (byte *)malloc(new_size);
 	assert(keep);
 	unsigned char * source = _sbuffer;
 
@@ -190,7 +190,7 @@
 		value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
 		WRITE_BE_UINT16(decoded, value); decoded += 2;
 	}
-	delete[] _sbuffer;
+	free(_sbuffer);
 	_sbuffer = (byte *)keep;
 	_sbufferSize = new_size;
 }

Modified: scummvm/trunk/engines/scumm/smush/saud_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/saud_channel.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/smush/saud_channel.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -130,16 +130,16 @@
 	}
 	if (_tbuffer) {
 		byte *old = _tbuffer;
-		_tbuffer = new byte[_tbufferSize + size];
+		_tbuffer = (byte *)malloc(_tbufferSize + size);
 		if (!_tbuffer)
 			error("saud_channel failed to allocate memory");
 		memcpy(_tbuffer, old, _tbufferSize);
-		delete[] old;
+		free(old);
 		b.read(_tbuffer + _tbufferSize, size);
 		_tbufferSize += size;
 	} else {
 		_tbufferSize = size;
-		_tbuffer = new byte[_tbufferSize];
+		_tbuffer = (byte *)malloc(_tbufferSize);
 		if (!_tbuffer)
 			error("saud_channel failed to allocate memory");
 		b.read(_tbuffer, _tbufferSize);

Modified: scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_mixer.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/smush/smush_mixer.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -127,7 +127,7 @@
 					}
 					_mixer->setChannelVolume(_channels[i].handle, vol);
 					_mixer->setChannelBalance(_channels[i].handle, pan);
-					_channels[i].stream->queueBuffer(data, size, flags);	// The stream will free the buffer for us
+					_channels[i].stream->queueBuffer(data, size, DisposeAfterUse::YES, flags);	// The stream will free the buffer for us
 				} else
 					delete[] data;
 			}

Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -437,7 +437,7 @@
 					_IACTpos += bsize;
 					bsize = 0;
 				} else {
-					byte *output_data = new byte[4096];
+					byte *output_data = (byte *)malloc(4096);
 
 					memcpy(_IACToutput + _IACTpos, d_src, len);
 					byte *dst = output_data;
@@ -472,7 +472,7 @@
 						_IACTstream = Audio::makeQueuingAudioStream(22050, true);
 						_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_IACTchannel, _IACTstream);
 					}
-					_IACTstream->queueBuffer(output_data, 0x1000, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS);
+					_IACTstream->queueBuffer(output_data, 0x1000, DisposeAfterUse::YES, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS);
 
 					bsize -= len;
 					d_src += len;

Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/scumm/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -162,7 +162,7 @@
 	char *sound;
 	int size = -1;
 	int rate;
-	byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
+	byte flags = Audio::Mixer::FLAG_UNSIGNED;
 
 	if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine) {
 		if (soundID >= 13 && soundID <= 32) {
@@ -201,7 +201,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr, size);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
 	}
 	// WORKAROUND bug # 1311447
 	else if (READ_BE_UINT32(ptr) == 0x460e200d) {
@@ -223,7 +223,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr, size);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
 	}
 	// Support for sampled sound effects in Monkey Island 1 and 2
 	else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) {
@@ -294,7 +294,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr + 6, size);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
 	}
 	else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) {
 
@@ -347,7 +347,7 @@
 				if (loopEnd > 0)
 					flags |= Audio::Mixer::FLAG_LOOP;
 
-				_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, waveSize, rate, flags, soundID, 255, 0, loopStart, loopEnd);
+				_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, waveSize, DisposeAfterUse::YES, rate, flags, soundID, 255, 0, loopStart, loopEnd);
 			}
 			break;
 		case 1:
@@ -419,7 +419,7 @@
 		// offset 26: ?  if != 0: stop current sound?
 		// offset 27: ?  loopcount? 0xff == -1 for infinite?
 
-		flags = Audio::Mixer::FLAG_AUTOFREE;
+		flags = 0;
 		size = READ_BE_UINT16(ptr + 12);
 		assert(size);
 		
@@ -439,7 +439,7 @@
 		}
 
 		memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate,
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate,
 				flags, soundID, vol, 0, loopStart, loopEnd);
 	}
 	else {

Modified: scummvm/trunk/engines/sky/intro.cpp
===================================================================
--- scummvm/trunk/engines/sky/intro.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sky/intro.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -733,8 +733,8 @@
 		// probably use _skySound instead of calling playRaw()
 		// directly, but this will have to do for now.
 		memset(vData, 127, sizeof(DataFileHeader));
-		_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_voice, vData, _skyDisk->_lastLoadedFileSize, 11025,
-				Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED, SOUND_VOICE);
+		_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_voice, vData, _skyDisk->_lastLoadedFileSize, DisposeAfterUse::YES,
+				11025, Audio::Mixer::FLAG_UNSIGNED, SOUND_VOICE);
 		return true;
 	case WAITVOICE:
 		while (_mixer->isSoundHandleActive(_voice))
@@ -749,13 +749,13 @@
 		return true;
 	case LOOPBG:
 		_mixer->stopID(SOUND_BG);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
-				Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LOOP, SOUND_BG);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
+				11025, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LOOP, SOUND_BG);
 		return true;
 	case PLAYBG:
 		_mixer->stopID(SOUND_BG);
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
-				Audio::Mixer::FLAG_UNSIGNED, SOUND_BG);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
+				11025, Audio::Mixer::FLAG_UNSIGNED, SOUND_BG);
 		return true;
 	case STOPBG:
 		_mixer->stopID(SOUND_BG);

Modified: scummvm/trunk/engines/sky/sound.cpp
===================================================================
--- scummvm/trunk/engines/sky/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sky/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -1035,13 +1035,13 @@
 
 void Sound::playSound(uint32 id, byte *sound, uint32 size, Audio::SoundHandle *handle) {
 	byte flags = 0;
-	flags |= Audio::Mixer::FLAG_UNSIGNED|Audio::Mixer::FLAG_AUTOFREE;
+	flags |= Audio::Mixer::FLAG_UNSIGNED;
 	size -= sizeof(DataFileHeader);
 	byte *buffer = (byte *)malloc(size);
 	memcpy(buffer, sound+sizeof(DataFileHeader), size);
 
 	_mixer->stopID(id);
-	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, 11025, flags, id);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, DisposeAfterUse::YES, 11025, flags, id);
 }
 
 void Sound::loadSection(uint8 pSection) {
@@ -1116,9 +1116,9 @@
 	}
 
 	if (channel == 0)
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound0, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
 	else
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound1, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
 }
 
 void Sound::fnStartFx(uint32 sound, uint8 channel) {
@@ -1240,7 +1240,7 @@
 		rate = 11025;
 
 	_mixer->stopID(SOUND_SPEECH);
-	_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_ingameSpeech, playBuffer, speechSize, rate, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE, SOUND_SPEECH);
+	_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_ingameSpeech, playBuffer, speechSize, DisposeAfterUse::YES, rate, Audio::Mixer::FLAG_UNSIGNED, SOUND_SPEECH);
 	return true;
 }
 

Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/sword1/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -45,7 +45,7 @@
 namespace Sword1 {
 
 #define SOUND_SPEECH_ID 1
-#define SPEECH_FLAGS (Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_LITTLE_ENDIAN)
+#define SPEECH_FLAGS (Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_LITTLE_ENDIAN)
 
 Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan) {
 	g_eventRec.registerRandomSource(_rnd, "sword1sound");
@@ -271,7 +271,7 @@
 							flags |= Audio::Mixer::FLAG_STEREO;
 						if (_fxList[elem->id].type == FX_LOOP)
 							flags |= Audio::Mixer::FLAG_LOOP;
-						_mixer->playRaw(Audio::Mixer::kSFXSoundType, &elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan);
+						_mixer->playRaw(Audio::Mixer::kSFXSoundType, &elem->handle, sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, elem->id, volume, pan);
 					}
 			}
 		} else
@@ -356,7 +356,7 @@
 			uint32 size;
 			int16 *data = uncompressSpeech(index + _cowHeaderSize, sampleSize, &size);
 			if (data)
-				_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
+				_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_speechHandle, data, size, DisposeAfterUse::YES, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
 		} else if (_cowMode == CowPSX && sampleSize != 0xffffffff) {
 			_cowFile.seek(index * 2048);
 			_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, new Audio::VagStream(_cowFile.readStream(sampleSize)), SOUND_SPEECH_ID, speechVol, speechPan);

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -897,7 +897,7 @@
 	in->read(data, size);
 	//debug(0, "playing %u samples...", size);
 
-	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, data, size, 11025, Audio::Mixer::FLAG_AUTOFREE);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, data, size, DisposeAfterUse::YES, 11025, 0);
 }
 
 

Modified: scummvm/trunk/engines/tinsel/bmv.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/bmv.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/tinsel/bmv.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -446,14 +446,14 @@
 	if (audioOffset == 0 && blobs == 0)
 		blobs = 57;
 
-	byte *data = new byte[blobs * 128];
+	byte *data = (byte *)malloc(blobs * 128);
 
 	if (audioOffset != 0)
 		PrepAudio(bigBuffer+audioOffset, blobs, data);
 	else
 		memset(data, 0, blobs * 128);
 
-	_audioStream->queueBuffer(data, blobs * 128, Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO);
+	_audioStream->queueBuffer(data, blobs * 128, DisposeAfterUse::YES, Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO);
 
 	if (currentSoundFrame == ADVANCE_SOUND) {
 		if (!audioStarted) {

Modified: scummvm/trunk/engines/tinsel/sound.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/tinsel/sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -153,8 +153,8 @@
 			#endif
 			break;
 		default:
-			_vm->_mixer->playRaw(type, &curChan.handle, sampleBuf, sampleLen, 22050,
-				Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED);
+			_vm->_mixer->playRaw(type, &curChan.handle, sampleBuf, sampleLen, DisposeAfterUse::YES, 22050,
+				Audio::Mixer::FLAG_UNSIGNED);
 			break;
 		}
 		if (sampleStream) {

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -591,7 +591,7 @@
 		case kAnimationSoundType16BitsRAW:
 			size = f.size();
 			rate = 22050;
-			flags = Audio::Mixer::FLAG_UNSIGNED|Audio::Mixer::FLAG_AUTOFREE;
+			flags = Audio::Mixer::FLAG_UNSIGNED;
 			if (type == kAnimationSoundType16BitsRAW) 
 				flags = Audio::Mixer::FLAG_LITTLE_ENDIAN | Audio::Mixer::FLAG_16BITS;
 			
@@ -599,7 +599,7 @@
 				uint8 *sampleData = (uint8 *)malloc(size);
 				if (sampleData) {
 					f.read(sampleData, size);
-					stream = Audio::makeRawMemoryStream(sampleData, size, rate, flags);
+					stream = Audio::makeRawMemoryStream(sampleData, size, DisposeAfterUse::YES, rate, flags);
 				}
 			}
 			break;

Modified: scummvm/trunk/graphics/video/avi_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/graphics/video/avi_decoder.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -323,13 +323,13 @@
 		byte *data = new byte[chunkSize];
 		_fileStream->read(data, chunkSize);
 
-		byte flags = Audio::Mixer::FLAG_AUTOFREE;
+		byte flags = 0;
 		if (_audsHeader.sampleSize == 2)
 			flags |= Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_LITTLE_ENDIAN;
 		else
 			flags |= Audio::Mixer::FLAG_UNSIGNED;
 
-		_audStream->queueBuffer(data, chunkSize, flags);
+		_audStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, flags);
 		_fileStream->skip(chunkSize & 1); // Alignment
 	} else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' || getStreamType(nextTag) == 'AM') {		
 		// Compressed Frame

Modified: scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -600,12 +600,12 @@
 		return;
 	}
 
-	byte *soundBuf = new byte[_soundSliceSize];
+	byte *soundBuf = (byte *)malloc(_soundSliceSize);
 
 	_stream->read(soundBuf, _soundSliceSize);
 	unsignedToSigned(soundBuf, _soundSliceSize);
 
-	_audioStream->queueBuffer(soundBuf, _soundSliceSize, 0);
+	_audioStream->queueBuffer(soundBuf, _soundSliceSize, DisposeAfterUse::YES, 0);
 }
 
 bool Imd::initialSoundSlice(bool hasNextCmd) {
@@ -616,12 +616,12 @@
 		return false;
 	}
 
-	byte *soundBuf = new byte[dataLength];
+	byte *soundBuf = (byte *)malloc(dataLength);
 
 	_stream->read(soundBuf, dataLength);
 	unsignedToSigned(soundBuf, dataLength);
 
-	_audioStream->queueBuffer(soundBuf, dataLength, 0);
+	_audioStream->queueBuffer(soundBuf, dataLength, DisposeAfterUse::YES, 0);
 
 	return _soundStage == 1;
 }
@@ -630,11 +630,11 @@
 	if (hasNextCmd || !_soundEnabled)
 		return;
 
-	byte *soundBuf = new byte[_soundSliceSize];
+	byte *soundBuf = (byte *)malloc(_soundSliceSize);
 
 	memset(soundBuf, 0, _soundSliceSize);
 
-	_audioStream->queueBuffer(soundBuf, _soundSliceSize, 0);
+	_audioStream->queueBuffer(soundBuf, _soundSliceSize, DisposeAfterUse::YES, 0);
 }
 
 void Imd::videoData(uint32 size, State &state) {
@@ -2022,7 +2022,7 @@
 	uint32 inSize  = size;
 	uint32 outSize = size + channels;
 
-	int16 *out   = new int16[outSize];
+	int16 *out   = (int16 *)malloc(outSize * 2);
 	byte  *sound = (byte *) out;
 
 	int channel = 0;
@@ -2056,7 +2056,7 @@
 
 	uint32 outSize = size * 2;
 
-	int16 *out   = new int16[outSize];
+	int16 *out   = (int16 *)malloc(outSize * 2);
 	byte  *sound = (byte *) out;
 
 	index = CLIP<int32>(index, 0, 88);
@@ -2110,7 +2110,7 @@
 	if (!_audioStream)
 		return 0;
 
-	byte *soundBuf = new byte[size];
+	byte *soundBuf = (byte *)malloc(size);
 	memset(soundBuf, 0, size);
 
 	return soundBuf;
@@ -2122,7 +2122,7 @@
 		return 0;
 	}
 
-	byte *soundBuf = new byte[size];
+	byte *soundBuf = (byte *)malloc(size);
 	_stream->read(soundBuf, size);
 	unsignedToSigned(soundBuf, size);
 
@@ -2187,7 +2187,7 @@
 		flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0;
 		flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0;
 
-		_audioStream->queueBuffer(sound, size, flags);
+		_audioStream->queueBuffer(sound, size, DisposeAfterUse::YES, flags);
 	}
 }
 
@@ -2205,7 +2205,7 @@
 		flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0;
 		flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0;
 
-		_audioStream->queueBuffer(sound, size, flags);
+		_audioStream->queueBuffer(sound, size, DisposeAfterUse::YES, flags);
 	}
 }
 

Modified: scummvm/trunk/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/graphics/video/smk_decoder.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -562,14 +562,14 @@
 
 		if (_header.audioInfo[i].hasAudio && chunkSize > 0 && i == 0) {
 			// If it's track 0, play the audio data
-			byte *soundBuffer = new byte[chunkSize];
+			byte *soundBuffer = (byte *)malloc(chunkSize);
 
 			_fileStream->read(soundBuffer, chunkSize);
 
 			if (_header.audioInfo[i].isCompressed) {
 				// Compressed audio (Huffman DPCM encoded)
 				queueCompressedBuffer(soundBuffer, chunkSize, dataSizeUnpacked, i);
-				delete[] soundBuffer;
+				free(soundBuffer);
 			} else {
 				// Uncompressed audio (PCM)
 				byte flags = 0;
@@ -578,7 +578,7 @@
 				if (_header.audioInfo[0].isStereo)
 					flags = flags | Audio::Mixer::FLAG_STEREO;
 
-				_audioStream->queueBuffer(soundBuffer, chunkSize, flags);
+				_audioStream->queueBuffer(soundBuffer, chunkSize, DisposeAfterUse::YES, flags);
 				// The sound buffer will be deleted by QueuingAudioStream
 			}
 
@@ -767,7 +767,7 @@
 
 	int numBytes = 1 * (isStereo ? 2 : 1) * (is16Bits ? 2 : 1);
 
-	byte *unpackedBuffer = new byte[unpackedSize];
+	byte *unpackedBuffer = (byte *)malloc(unpackedSize);
 	byte *curPointer = unpackedBuffer;
 	uint32 curPos = 0;
 
@@ -832,7 +832,7 @@
 		flags = flags | Audio::Mixer::FLAG_16BITS;
 	if (_header.audioInfo[0].isStereo)
 		flags = flags | Audio::Mixer::FLAG_STEREO;
-	_audioStream->queueBuffer(unpackedBuffer, unpackedSize, flags);
+	_audioStream->queueBuffer(unpackedBuffer, unpackedSize, DisposeAfterUse::YES, flags);
 	// unpackedBuffer will be deleted by QueuingAudioStream
 }
 

Modified: scummvm/trunk/sound/aiff.cpp
===================================================================
--- scummvm/trunk/sound/aiff.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/aiff.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -172,10 +172,8 @@
 	assert(data);
 	stream.read(data, size);
 
-	// Since we allocated our own buffer for the data, we must set the autofree flag.
-	flags |= Audio::Mixer::FLAG_AUTOFREE;
-
-	return makeRawMemoryStream(data, size, rate, flags);
+	// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
+	return makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags);
 }
 
 } // End of namespace Audio

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -252,8 +252,8 @@
 #pragma mark -
 
 
-void QueuingAudioStream::queueBuffer(byte *data, uint32 size, byte flags) {
-	AudioStream *stream = makeRawMemoryStream(data, size, getRate(), flags, 0, 0);
+void QueuingAudioStream::queueBuffer(byte *data, uint32 size, DisposeAfterUse::Flag disposeAfterUse, byte flags) {
+	AudioStream *stream = makeRawMemoryStream(data, size, disposeAfterUse, getRate(), flags, 0, 0);
 	queueAudioStream(stream, DisposeAfterUse::YES);
 }
 

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/audiostream.h	2010-01-19 00:56:29 UTC (rev 47369)
@@ -315,7 +315,7 @@
 	 * the buffer will be delete[]'d (so make sure to allocate them
 	 * with new[], not with malloc).
 	 */
-	void queueBuffer(byte *data, uint32 size, byte flags);
+	void queueBuffer(byte *data, uint32 size, DisposeAfterUse::Flag disposeAfterUse, byte flags);
 
 	/**
 	 * Mark the stream as finished, that is, signal that no further data

Modified: scummvm/trunk/sound/iff_sound.cpp
===================================================================
--- scummvm/trunk/sound/iff_sound.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/iff_sound.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -99,9 +99,7 @@
 		flags |= Audio::Mixer::FLAG_LOOP;
 	}
 
-	flags |= Audio::Mixer::FLAG_AUTOFREE;
-
-	return Audio::makeRawMemoryStream((byte *)loader._data, loader._dataSize, loader._header.samplesPerSec, flags, loopStart, loopEnd);
+	return Audio::makeRawMemoryStream((byte *)loader._data, loader._dataSize, DisposeAfterUse::YES, loader._header.samplesPerSec, flags, loopStart, loopEnd);
 }
 
 }

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/mixer.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -221,12 +221,14 @@
 			SoundType type,
 			SoundHandle *handle,
 			void *sound,
-			uint32 size, uint rate, byte flags,
+			uint32 size,
+			DisposeAfterUse::Flag autofreeBuffer,
+			uint rate, byte flags,
 			int id, byte volume, int8 balance,
 			uint32 loopStart, uint32 loopEnd) {
 
 	// Create the input stream
-	AudioStream *input = makeRawMemoryStream((byte *)sound, size, rate, flags, loopStart, loopEnd);
+	AudioStream *input = makeRawMemoryStream((byte *)sound, size, autofreeBuffer, rate, flags, loopStart, loopEnd);
 
 	// Play it
 	playInputStream(type, handle, input, id, volume, balance, DisposeAfterUse::YES, false, ((flags & Mixer::FLAG_REVERSE_STEREO) != 0));

Modified: scummvm/trunk/sound/mixer.h
===================================================================
--- scummvm/trunk/sound/mixer.h	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/mixer.h	2010-01-19 00:56:29 UTC (rev 47369)
@@ -88,9 +88,6 @@
 		/** reverse the left and right stereo channel */
 		FLAG_REVERSE_STEREO = 1 << 4,
 
-		/** sound buffer is freed automagically at the end of playing */
-		FLAG_AUTOFREE = 1 << 5,
-
 		/** loop the audio */
 		FLAG_LOOP = 1 << 6
 	};
@@ -137,7 +134,9 @@
 	virtual void playRaw(
 		SoundType type,
 		SoundHandle *handle,
-		void *sound, uint32 size, uint rate, byte flags,
+		void *sound, uint32 size,
+		DisposeAfterUse::Flag autofreeBuffer,
+		uint rate, byte flags,
 		int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
 		uint32 loopStart = 0, uint32 loopEnd = 0) = 0;
 

Modified: scummvm/trunk/sound/mixer_intern.h
===================================================================
--- scummvm/trunk/sound/mixer_intern.h	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/mixer_intern.h	2010-01-19 00:56:29 UTC (rev 47369)
@@ -77,7 +77,9 @@
 	virtual void playRaw(
 		SoundType type,
 		SoundHandle *handle,
-		void *sound, uint32 size, uint rate, byte flags,
+		void *sound, uint32 size,
+		DisposeAfterUse::Flag autofreeBuffer,
+		uint rate, byte flags,
 		int id, byte volume, int8 balance,
 		uint32 loopStart, uint32 loopEnd);
 

Modified: scummvm/trunk/sound/raw.cpp
===================================================================
--- scummvm/trunk/sound/raw.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/raw.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -328,12 +328,13 @@
 		} else \
 			return new RawMemoryStream<STEREO, false, UNSIGNED, false>(rate, ptr, len, autoFree)
 
-SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len, int rate, byte flags) {
+SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
+		DisposeAfterUse::Flag autoFree,
+		int rate, byte flags) {
 	const bool isStereo   = (flags & Mixer::FLAG_STEREO) != 0;
 	const bool is16Bit    = (flags & Mixer::FLAG_16BITS) != 0;
 	const bool isUnsigned = (flags & Mixer::FLAG_UNSIGNED) != 0;
 	const bool isLE       = (flags & Mixer::FLAG_LITTLE_ENDIAN) != 0;
-	const DisposeAfterUse::Flag autoFree   = (flags & Mixer::FLAG_AUTOFREE) != 0 ? DisposeAfterUse::YES : DisposeAfterUse::NO;
 
 	// Verify the buffer sizes are sane
 	if (is16Bit && isStereo) {
@@ -358,9 +359,11 @@
 }
 
 
-AudioStream *makeRawMemoryStream(const byte *ptr, uint32 len, int rate,
-                                   byte flags, uint loopStart, uint loopEnd) {
-	SeekableAudioStream *stream = makeRawMemoryStream(ptr, len, rate, flags);
+AudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
+		DisposeAfterUse::Flag autoFree,
+		int rate, byte flags,
+		uint loopStart, uint loopEnd) {
+	SeekableAudioStream *stream = makeRawMemoryStream(ptr, len, autoFree, rate, flags);
 
 	const bool isStereo   = (flags & Mixer::FLAG_STEREO) != 0;
 	const bool is16Bit    = (flags & Mixer::FLAG_16BITS) != 0;

Modified: scummvm/trunk/sound/raw.h
===================================================================
--- scummvm/trunk/sound/raw.h	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/raw.h	2010-01-19 00:56:29 UTC (rev 47369)
@@ -48,7 +48,9 @@
  * @see Mixer::RawFlags
  * @return The new SeekableAudioStream (or 0 on failure).
  */
-SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len, int rate, byte flags);
+SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
+		DisposeAfterUse::Flag autofreeBuffer,
+		int rate, byte flags);
 
 /**
  * NOTE:
@@ -61,8 +63,10 @@
  * signed native endian). Optionally supports (infinite) looping of a portion
  * of the data.
  */
-AudioStream *makeRawMemoryStream(const byte *ptr, uint32 len, int rate,
-                                   byte flags, uint loopStart, uint loopEnd);
+AudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
+		DisposeAfterUse::Flag autofreeBuffer,
+		int rate, byte flags,
+		uint loopStart, uint loopEnd);
 
 
 /**
@@ -87,8 +91,10 @@
  * @param disposeStream Whether the "stream" object should be destroyed after playback.
  * @return The new SeekableAudioStream (or 0 on failure).
  */
-SeekableAudioStream *makeRawDiskStream(Common::SeekableReadStream *stream, RawDiskStreamAudioBlock *block,
-		int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream);
+SeekableAudioStream *makeRawDiskStream(Common::SeekableReadStream *stream,
+		RawDiskStreamAudioBlock *block, int numBlocks,
+		int rate, byte flags,
+		DisposeAfterUse::Flag disposeStream);
 
 /**
  * NOTE:
@@ -99,8 +105,11 @@
  * RawDiskStreamAudioBlock which defines the start position and length of
  * each block of uncompressed audio in the stream.
  */
-AudioStream *makeRawDiskStream(Common::SeekableReadStream *stream, RawDiskStreamAudioBlock *block,
-		int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd);
+AudioStream *makeRawDiskStream(Common::SeekableReadStream *stream,
+		RawDiskStreamAudioBlock *block, int numBlocks,
+		int rate, byte flags,
+		DisposeAfterUse::Flag disposeStream,
+		uint loopStart, uint loopEnd);
 
 
 } // End of namespace Audio

Modified: scummvm/trunk/sound/shorten.cpp
===================================================================
--- scummvm/trunk/sound/shorten.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/shorten.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -523,10 +523,8 @@
 	if (!data)
 		return 0;
 
-	// Since we allocated our own buffer for the data, we must set the autofree flag.
-	flags |= Audio::Mixer::FLAG_AUTOFREE;
-
-	return makeRawMemoryStream(data, size, rate, flags, 0, 0);
+	// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
+	return makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags, 0, 0);
 }
 
 } // End of namespace Audio

Modified: scummvm/trunk/sound/voc.cpp
===================================================================
--- scummvm/trunk/sound/voc.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/voc.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -353,7 +353,7 @@
 	if (!data)
 		return 0;
 
-	return makeRawMemoryStream(data, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, loopStart, loopEnd);
+	return makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd);
 #endif
 }
 
@@ -368,7 +368,7 @@
 	if (!data)
 		return 0;
 
-	return makeRawMemoryStream(data, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
+	return makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags);
 #endif
 }
 

Modified: scummvm/trunk/sound/wave.cpp
===================================================================
--- scummvm/trunk/sound/wave.cpp	2010-01-19 00:54:06 UTC (rev 47368)
+++ scummvm/trunk/sound/wave.cpp	2010-01-19 00:56:29 UTC (rev 47369)
@@ -188,10 +188,8 @@
 	if (disposeAfterUse == DisposeAfterUse::YES)
 		delete stream;
 
-	// Since we allocated our own buffer for the data, we must set the autofree flag.
-	flags |= Audio::Mixer::FLAG_AUTOFREE;
-
-	return makeRawMemoryStream(data, size, rate, flags);
+	// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
+	return makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags);
 }
 
 } // End of namespace Audio


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