aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm')
-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
11 files changed, 38 insertions, 41 deletions
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 {