aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2010-01-19 00:56:29 +0000
committerMax Horn2010-01-19 00:56:29 +0000
commit557bb394de6619dd1f360b72333fd2ec7b3defab (patch)
treeb1166a12105d01c92edb528177d24aa5115232e5 /engines
parent69be7476212916b166ac16db41253cd367fb0dcc (diff)
downloadscummvm-rg350-557bb394de6619dd1f360b72333fd2ec7b3defab.tar.gz
scummvm-rg350-557bb394de6619dd1f360b72333fd2ec7b3defab.tar.bz2
scummvm-rg350-557bb394de6619dd1f360b72333fd2ec7b3defab.zip
Get rid of Mixer::FLAG_AUTOFREE.
Also fix several recently introduced new/delete vs. malloc/free mismatches. svn-id: r47369
Diffstat (limited to 'engines')
-rw-r--r--engines/agos/sound.cpp8
-rw-r--r--engines/cine/sound.cpp2
-rw-r--r--engines/draci/sound.cpp4
-rw-r--r--engines/drascula/sound.cpp4
-rw-r--r--engines/groovie/roq.cpp12
-rw-r--r--engines/groovie/vdx.cpp4
-rw-r--r--engines/kyra/sound_towns.cpp8
-rw-r--r--engines/kyra/vqa.cpp28
-rw-r--r--engines/m4/sound.cpp15
-rw-r--r--engines/made/pmvplayer.cpp4
-rw-r--r--engines/made/resource.cpp2
-rw-r--r--engines/mohawk/sound.cpp8
-rw-r--r--engines/mohawk/video/qt_player.cpp4
-rw-r--r--engines/parallaction/sound_br.cpp6
-rw-r--r--engines/parallaction/sound_ns.cpp2
-rw-r--r--engines/queen/sound.cpp6
-rw-r--r--engines/saga/music.cpp2
-rw-r--r--engines/saga/sound.cpp4
-rw-r--r--engines/sci/sound/audio.cpp2
-rw-r--r--engines/sci/sound/iterator/iterator.cpp4
-rw-r--r--engines/sci/sound/music.cpp2
-rw-r--r--engines/scumm/he/cup_player_he.cpp2
-rw-r--r--engines/scumm/he/sound_he.cpp15
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp10
-rw-r--r--engines/scumm/imuse_digi/dimuse_codecs.cpp2
-rw-r--r--engines/scumm/imuse_digi/dimuse_sndmgr.cpp4
-rw-r--r--engines/scumm/player_mod.cpp2
-rw-r--r--engines/scumm/smush/imuse_channel.cpp18
-rw-r--r--engines/scumm/smush/saud_channel.cpp6
-rw-r--r--engines/scumm/smush/smush_mixer.cpp2
-rw-r--r--engines/scumm/smush/smush_player.cpp4
-rw-r--r--engines/scumm/sound.cpp14
-rw-r--r--engines/sky/intro.cpp12
-rw-r--r--engines/sky/sound.cpp10
-rw-r--r--engines/sword1/sound.cpp6
-rw-r--r--engines/teenagent/teenagent.cpp2
-rw-r--r--engines/tinsel/bmv.cpp4
-rw-r--r--engines/tinsel/sound.cpp4
-rw-r--r--engines/tucker/sequences.cpp4
39 files changed, 121 insertions, 131 deletions
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp
index 4d79f4fed3..5b9257b068 100644
--- a/engines/agos/sound.cpp
+++ b/engines/agos/sound.cpp
@@ -277,7 +277,7 @@ void RawSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType typ
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 @@ void Sound::playRawData(byte *soundData, uint sound, uint size, uint freq) {
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
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 39acb44ecb..736241c3b1 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -844,7 +844,7 @@ void PaulaSound::update() {
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);
}
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp
index d12fccd27e..d593437cf6 100644
--- a/engines/draci/sound.cpp
+++ b/engines/draci/sound.cpp
@@ -194,7 +194,6 @@ SndHandle *Sound::getHandle() {
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 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
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) {
diff --git a/engines/drascula/sound.cpp b/engines/drascula/sound.cpp
index 06585e3dce..0a4876e802 100644
--- a/engines/drascula/sound.cpp
+++ b/engines/drascula/sound.cpp
@@ -182,8 +182,8 @@ void DrasculaEngine::playFile(const char *fname) {
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);
}
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 11e7fd9aaa..5887ccbf22 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -522,7 +522,7 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) {
}
// 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 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) {
}
// 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 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) {
}
// 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 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) {
}
// 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;
}
diff --git a/engines/groovie/vdx.cpp b/engines/groovie/vdx.cpp
index e2764defa6..b41e28747a 100644
--- a/engines/groovie/vdx.cpp
+++ b/engines/groovie/vdx.cpp
@@ -503,10 +503,10 @@ void VDXPlayer::chunkSound(Common::ReadStream *in) {
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);
}
}
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index b4da44df6a..061893a452 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -3925,8 +3925,8 @@ void SoundTowns::playSoundEffect(uint8 track) {
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 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle,
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];
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index fde6e06a96..69d63b60f2 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -419,10 +419,10 @@ void VQAMovie::displayFrame(uint frameNum) {
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 @@ void VQAMovie::displayFrame(uint frameNum) {
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 @@ void VQAMovie::play() {
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;
diff --git a/engines/m4/sound.cpp b/engines/m4/sound.cpp
index 1b24a3382d..ecc3ff6567 100644
--- a/engines/m4/sound.cpp
+++ b/engines/m4/sound.cpp
@@ -88,8 +88,7 @@ void Sound::playSound(const char *soundName, int volume, bool loop, int channel)
_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 @@ void Sound::playSound(const char *soundName, int volume, bool loop, int channel)
_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 @@ void Sound::playVoice(const char *soundName, int volume) {
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 @@ void Sound::playDSRSound(int soundIndex, int volume, bool loop) {
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 @@ void Sound::playDSRSound(int soundIndex, int volume, bool loop) {
// 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);
/*
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index b0b1f0d70f..f65678c510 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -138,9 +138,9 @@ bool PmvPlayer::play(const char *filename) {
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
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index 335634598a..7edddbb644 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -265,7 +265,7 @@ Audio::AudioStream *SoundResource::getAudioStream(int soundRate, bool loop) {
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) {
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp
index 1c70972b0a..33bc71e8bf 100644
--- a/engines/mohawk/sound.cpp
+++ b/engines/mohawk/sound.cpp
@@ -435,12 +435,12 @@ Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stre
// 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 @@ Audio::AudioStream *Sound::makeOldMohawkWaveStream(Common::SeekableReadStream *s
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() {
diff --git a/engines/mohawk/video/qt_player.cpp b/engines/mohawk/video/qt_player.cpp
index 50928a0aac..4ddb8d2ee8 100644
--- a/engines/mohawk/video/qt_player.cpp
+++ b/engines/mohawk/video/qt_player.cpp
@@ -1159,7 +1159,7 @@ Audio::AudioStream *QTPlayer::createAudioStream(Common::SeekableReadStream *stre
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 @@ Audio::AudioStream *QTPlayer::createAudioStream(Common::SeekableReadStream *stre
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);
diff --git a/engines/parallaction/sound_br.cpp b/engines/parallaction/sound_br.cpp
index 1441a313bc..5dfbf742c0 100644
--- a/engines/parallaction/sound_br.cpp
+++ b/engines/parallaction/sound_br.cpp
@@ -416,14 +416,14 @@ Audio::AudioStream *DosSoundMan_br::loadChannelData(const char *filename, Channe
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 @@ Audio::AudioStream *AmigaSoundMan_br::loadChannelData(const char *filename, Chan
// 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);
}
diff --git a/engines/parallaction/sound_ns.cpp b/engines/parallaction/sound_ns.cpp
index e9215cf117..303d323265 100644
--- a/engines/parallaction/sound_ns.cpp
+++ b/engines/parallaction/sound_ns.cpp
@@ -377,7 +377,7 @@ Audio::AudioStream *AmigaSoundMan_ns::loadChannelData(const char *filename, Chan
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);
diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp
index b0bc2cf6b6..b03084f7bc 100644
--- a/engines/queen/sound.cpp
+++ b/engines/queen/sound.cpp
@@ -327,9 +327,8 @@ void SBSound::playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *so
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 @@ void AmigaSound::playSound(const char *base) {
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);
}
}
}
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index bd089f1b38..70b62dbd02 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -304,7 +304,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
(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;
diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp
index 2636567880..e8307699ff 100644
--- a/engines/saga/sound.cpp
+++ b/engines/saga/sound.cpp
@@ -66,8 +66,6 @@ SndHandle *Sound::getHandle() {
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 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int
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;
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index e43d7d001f..bdb8c165f6 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -245,7 +245,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
}
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;
diff --git a/engines/sci/sound/iterator/iterator.cpp b/engines/sci/sound/iterator/iterator.cpp
index 232a40f121..5cb5f2d321 100644
--- a/engines/sci/sound/iterator/iterator.cpp
+++ b/engines/sci/sound/iterator/iterator.cpp
@@ -551,8 +551,8 @@ static Audio::AudioStream *makeStream(byte *data, int size, int rate) {
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() {
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 8a99c34076..5a5e5c877e 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -178,7 +178,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
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;
diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp
index dc4eafe56b..ea8f9e9f8a 100644
--- a/engines/scumm/he/cup_player_he.cpp
+++ b/engines/scumm/he/cup_player_he.cpp
@@ -176,7 +176,7 @@ void CUP_Player::updateSfx() {
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);
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index bd003033c7..d4e1e407a8 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -572,7 +572,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
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 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
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 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
}
_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 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
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) {
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index 7672587904..cf5cc99579 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -299,7 +299,7 @@ void IMuseDigital::callback() {
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 @@ void IMuseDigital::callback() {
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 @@ void IMuseDigital::callback() {
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 @@ void IMuseDigital::callback() {
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);
diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp
index 479a7a5470..3f7c341701 100644
--- a/engines/scumm/imuse_digi/dimuse_codecs.cpp
+++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp
@@ -33,7 +33,7 @@ namespace BundleCodecs {
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;
diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
index e366a04969..76e606af5b 100644
--- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
@@ -655,11 +655,11 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte
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;
diff --git a/engines/scumm/player_mod.cpp b/engines/scumm/player_mod.cpp
index 6495da6d48..4e878768ef 100644
--- a/engines/scumm/player_mod.cpp
+++ b/engines/scumm/player_mod.cpp
@@ -95,7 +95,7 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
_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);
}
diff --git a/engines/scumm/smush/imuse_channel.cpp b/engines/scumm/smush/imuse_channel.cpp
index c01a2acca3..a838fdba56 100644
--- a/engines/scumm/smush/imuse_channel.cpp
+++ b/engines/scumm/smush/imuse_channel.cpp
@@ -69,7 +69,7 @@ bool ImuseChannel::appendData(Common::SeekableReadStream &b, int32 size) {
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 @@ bool ImuseChannel::appendData(Common::SeekableReadStream &b, int32 size) {
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 @@ void ImuseChannel::decode() {
_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 @@ void ImuseChannel::decode() {
(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 @@ void ImuseChannel::decode() {
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 @@ void ImuseChannel::decode() {
value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
WRITE_BE_UINT16(decoded, value); decoded += 2;
}
- delete[] _sbuffer;
+ free(_sbuffer);
_sbuffer = (byte *)keep;
_sbufferSize = new_size;
}
diff --git a/engines/scumm/smush/saud_channel.cpp b/engines/scumm/smush/saud_channel.cpp
index b4c12b8553..94df70633f 100644
--- a/engines/scumm/smush/saud_channel.cpp
+++ b/engines/scumm/smush/saud_channel.cpp
@@ -130,16 +130,16 @@ bool SaudChannel::appendData(Common::SeekableReadStream &b, int32 size) {
}
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);
diff --git a/engines/scumm/smush/smush_mixer.cpp b/engines/scumm/smush/smush_mixer.cpp
index c069f6fe1b..a9b5e6077e 100644
--- a/engines/scumm/smush/smush_mixer.cpp
+++ b/engines/scumm/smush/smush_mixer.cpp
@@ -127,7 +127,7 @@ bool SmushMixer::handleFrame() {
}
_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;
}
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index cc84a4db4a..871ce76803 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -437,7 +437,7 @@ void SmushPlayer::handleIACT(int32 subSize, Common::SeekableReadStream &b) {
_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 @@ void SmushPlayer::handleIACT(int32 subSize, Common::SeekableReadStream &b) {
_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;
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 80887c7cb8..7b6975b818 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -162,7 +162,7 @@ void Sound::playSound(int soundID) {
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 @@ void Sound::playSound(int soundID) {
// 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 @@ void Sound::playSound(int soundID) {
// 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 @@ void Sound::playSound(int soundID) {
// 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 @@ void Sound::playSound(int soundID) {
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 @@ void Sound::playSound(int soundID) {
// 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 @@ void Sound::playSound(int soundID) {
}
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 {
diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp
index ae6e445303..5e1b432418 100644
--- a/engines/sky/intro.cpp
+++ b/engines/sky/intro.cpp
@@ -733,8 +733,8 @@ bool Intro::nextPart(uint16 *&data) {
// 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 @@ bool Intro::nextPart(uint16 *&data) {
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);
diff --git a/engines/sky/sound.cpp b/engines/sky/sound.cpp
index 67cb1b8fbd..f46b40be86 100644
--- a/engines/sky/sound.cpp
+++ b/engines/sky/sound.cpp
@@ -1035,13 +1035,13 @@ Sound::~Sound() {
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 @@ void Sound::playSound(uint16 sound, uint16 volume, uint8 channel) {
}
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 @@ bool Sound::startSpeech(uint16 textNum) {
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;
}
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index b3671791a1..d3eaad7c5c 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -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 @@ void Sound::playSample(QueueElement *elem) {
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 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
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);
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index a057116907..83cb8e10b2 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -897,7 +897,7 @@ void TeenAgentEngine::playSoundNow(byte id) {
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);
}
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index 85cc9bc7f2..50a0d5193c 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -446,14 +446,14 @@ void BMVPlayer::MovieAudio(int audioOffset, int blobs) {
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) {
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index 8f6dd762ba..8c3ddbaf3f 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -153,8 +153,8 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
#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) {
diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp
index 16dba3e346..19041a33c4 100644
--- a/engines/tucker/sequences.cpp
+++ b/engines/tucker/sequences.cpp
@@ -591,7 +591,7 @@ Audio::RewindableAudioStream *AnimationSequencePlayer::loadSound(int index, Anim
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 @@ Audio::RewindableAudioStream *AnimationSequencePlayer::loadSound(int index, Anim
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;