diff options
author | Max Horn | 2003-06-21 19:58:38 +0000 |
---|---|---|
committer | Max Horn | 2003-06-21 19:58:38 +0000 |
commit | 720837abd92da3ac95debbf71619275245bc3a89 (patch) | |
tree | 9eda5493819a90a9a092796f2ab1cee8f9a7150b /scumm | |
parent | 9548531b1c9f0aa978822a98cc59de9fd04bb45c (diff) | |
download | scummvm-rg350-720837abd92da3ac95debbf71619275245bc3a89.tar.gz scummvm-rg350-720837abd92da3ac95debbf71619275245bc3a89.tar.bz2 scummvm-rg350-720837abd92da3ac95debbf71619275245bc3a89.zip |
reduce code duplication a bit
svn-id: r8586
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/smush/smush_mixer.cpp | 44 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 2 |
2 files changed, 21 insertions, 25 deletions
diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp index 795772aa39..69a5cf6993 100644 --- a/scumm/smush/smush_mixer.cpp +++ b/scumm/smush/smush_mixer.cpp @@ -108,44 +108,40 @@ bool SmushMixer::handleFrame() { } else { int32 rate; bool stereo, is_short; + void *data; _channels[i].chan->getParameters(rate, stereo, is_short); int32 size = _channels[i].chan->availableSoundData(); int32 flags = stereo ? SoundMixer::FLAG_STEREO : 0; if (is_short) { - short *data = new int16[size * (stereo ? 2 : 1) * 2]; - _channels[i].chan->getSoundData(data, size); - if (_channels[i].chan->getRate() == 11025) size *= 2; + data = malloc(size * (stereo ? 2 : 1) * 4); + _channels[i].chan->getSoundData((int16 *)data, size); + if (_channels[i].chan->getRate() == 11025) + size *= 2; size *= stereo ? 4 : 2; - if (_silentMixer == false) { - if (_channels[i].first) { - _channels[i].mixer_index = _mixer->playStream(NULL, -1, data, size, rate, flags | SoundMixer::FLAG_16BITS); - _channels[i].first = false; - } else { - _mixer->append(_channels[i].mixer_index, data, size, rate, flags | SoundMixer::FLAG_16BITS); - } - } + flags |= SoundMixer::FLAG_16BITS; - delete []data; } else { - int8 *data = new int8[size * (stereo ? 2 : 1) * 2]; - _channels[i].chan->getSoundData(data, size); - if (_channels[i].chan->getRate() == 11025) size *= 2; + data = malloc(size * (stereo ? 2 : 1) * 2); + _channels[i].chan->getSoundData((int8 *)data, size); + if (_channels[i].chan->getRate() == 11025) + size *= 2; size *= stereo ? 2 : 1; - if (_silentMixer == false) { - if (_channels[i].first) { - _channels[i].mixer_index = _mixer->playStream(NULL, -1, data, size, rate, flags | SoundMixer::FLAG_UNSIGNED); - _channels[i].first = false; - } else { - _mixer->append(_channels[i].mixer_index, data, size, rate, flags | SoundMixer::FLAG_UNSIGNED); - } - } + flags |= SoundMixer::FLAG_UNSIGNED; + } - delete []data; + if (_silentMixer == false) { + if (_channels[i].first) { + _channels[i].mixer_index = _mixer->playStream(NULL, -1, data, size, rate, flags); + _channels[i].first = false; + } else { + _mixer->append(_channels[i].mixer_index, data, size, rate, flags); + } } + free(data); } } } diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 6f8511059c..c9be3863f8 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -436,7 +436,7 @@ void SmushPlayer::handleImuseAction(Chunk &b) { *dst++ = *d_src2++; } else { int16 val = (int8)value << variable2; - *dst++ = val>> 8; + *dst++ = val >> 8; *dst++ = (byte)(val); } value = *(d_src2++); |