diff options
author | Max Horn | 2007-02-28 14:48:26 +0000 |
---|---|---|
committer | Max Horn | 2007-02-28 14:48:26 +0000 |
commit | 8c8abca6f80fc63b5c11fa43319cdf56b4845660 (patch) | |
tree | ec031a874e67c92d3640824c2ee9816b5b6cab90 /engines/scumm/smush | |
parent | dea688d0f5303e552bff8ff22798719d92ed53c1 (diff) | |
download | scummvm-rg350-8c8abca6f80fc63b5c11fa43319cdf56b4845660.tar.gz scummvm-rg350-8c8abca6f80fc63b5c11fa43319cdf56b4845660.tar.bz2 scummvm-rg350-8c8abca6f80fc63b5c11fa43319cdf56b4845660.zip |
Changed the AppendableAudioStream code to use a queue of buffers, instead of a fixed size wrap-around memory buffer (this reduces memory usage in some cases by 500-700k, while actually being more flexible)
svn-id: r25909
Diffstat (limited to 'engines/scumm/smush')
-rw-r--r-- | engines/scumm/smush/smush_mixer.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/smush/smush_player.cpp | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/engines/scumm/smush/smush_mixer.cpp b/engines/scumm/smush/smush_mixer.cpp index 9e6631a365..e29a921224 100644 --- a/engines/scumm/smush/smush_mixer.cpp +++ b/engines/scumm/smush/smush_mixer.cpp @@ -105,6 +105,7 @@ bool SmushMixer::handleFrame() { _channels[i].chan->getParameters(stereo, is_16bit, vol, pan); + // Grab the audio data from the channel int32 size = _channels[i].chan->getAvailableSoundDataSize(); byte *data = _channels[i].chan->getSoundData(); @@ -116,15 +117,16 @@ bool SmushMixer::handleFrame() { } if (_mixer->isReady()) { + // Stream the data if (!_channels[i].stream) { - _channels[i].stream = Audio::makeAppendableAudioStream(_channels[i].chan->getRate(), flags, 500000); + _channels[i].stream = Audio::makeAppendableAudioStream(_channels[i].chan->getRate(), flags); _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_channels[i].handle, _channels[i].stream); } _mixer->setChannelVolume(_channels[i].handle, vol); _mixer->setChannelBalance(_channels[i].handle, pan); - _channels[i].stream->append(data, size); - } - delete[] data; + _channels[i].stream->queueBuffer(data, size); // 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 d4b3352be4..3310415f30 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -462,7 +462,7 @@ void SmushPlayer::handleIACT(Chunk &b) { c->checkParameters(index, nbframes, size, track_flags, unknown); c->appendData(b, bsize); } else { - byte output_data[4096]; + // TODO: Move this code into another SmushChannel subclass? byte *src = (byte *)malloc(bsize); b.read(src, bsize); byte *d_src = src; @@ -477,6 +477,8 @@ void SmushPlayer::handleIACT(Chunk &b) { _IACTpos += bsize; bsize = 0; } else { + byte *output_data = new byte[4096]; + memcpy(_IACToutput + _IACTpos, d_src, len); byte *dst = output_data; byte *d_src2 = _IACToutput; @@ -507,10 +509,10 @@ void SmushPlayer::handleIACT(Chunk &b) { } while (--count); if (!_IACTstream) { - _IACTstream = Audio::makeAppendableAudioStream(22050, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS, 900000); + _IACTstream = Audio::makeAppendableAudioStream(22050, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS); _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_IACTchannel, _IACTstream); } - _IACTstream->append(output_data, 0x1000); + _IACTstream->queueBuffer(output_data, 0x1000); bsize -= len; d_src += len; |