From 48e5ec67ffcc3f45816507d53d7b276414a31867 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 28 Oct 2006 00:18:13 +0000 Subject: SCUMM: Further SMUSH audio channel cleanup; this time unified some code, and got rid of one set of memory buffers svn-id: r24542 --- engines/scumm/smush/smush_mixer.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'engines/scumm/smush/smush_mixer.cpp') diff --git a/engines/scumm/smush/smush_mixer.cpp b/engines/scumm/smush/smush_mixer.cpp index ea5d167193..9b0f67045f 100644 --- a/engines/scumm/smush/smush_mixer.cpp +++ b/engines/scumm/smush/smush_mixer.cpp @@ -106,24 +106,16 @@ bool SmushMixer::handleFrame() { } else { int32 vol, pan; bool stereo, is_16bit; - void *data; _channels[i].chan->getParameters(stereo, is_16bit, vol, pan); + int32 size = _channels[i].chan->getAvailableSoundDataSize(); - byte flags = stereo ? Audio::Mixer::FLAG_STEREO : 0; + byte *data = _channels[i].chan->getSoundData(); + byte flags = stereo ? Audio::Mixer::FLAG_STEREO : 0; if (is_16bit) { - data = malloc(size * (stereo ? 4 : 2)); - _channels[i].chan->getSoundData((int16 *)data, size); - size *= stereo ? 4 : 2; - flags |= Audio::Mixer::FLAG_16BITS; - } else { - data = malloc(size * (stereo ? 2 : 1)); - _channels[i].chan->getSoundData((int8 *)data, size); - size *= stereo ? 2 : 1; - flags |= Audio::Mixer::FLAG_UNSIGNED; } @@ -134,9 +126,9 @@ bool SmushMixer::handleFrame() { } _mixer->setChannelVolume(_channels[i].handle, vol); _mixer->setChannelBalance(_channels[i].handle, pan); - _channels[i].stream->append((byte *)data, size); + _channels[i].stream->append(data, size); } - free(data); + delete[] data; } } } -- cgit v1.2.3