diff options
author | Max Horn | 2003-12-26 21:40:30 +0000 |
---|---|---|
committer | Max Horn | 2003-12-26 21:40:30 +0000 |
commit | ec56e09af6a56e7d90bf97ed5723b21e7f2fcb26 (patch) | |
tree | 027b24998397ae265c7de66bbef6690404f15a79 | |
parent | 7c6e720a82bfcc9d7be669ddbabb2dcf96d99c1c (diff) | |
download | scummvm-rg350-ec56e09af6a56e7d90bf97ed5723b21e7f2fcb26.tar.gz scummvm-rg350-ec56e09af6a56e7d90bf97ed5723b21e7f2fcb26.tar.bz2 scummvm-rg350-ec56e09af6a56e7d90bf97ed5723b21e7f2fcb26.zip |
change IMuseDigital to 'own' the AudioInputStream (the idea is that eventually it can use a custom AudioInputStream, and thus implement a pull interface instead of push one)
svn-id: r11950
-rw-r--r-- | scumm/imuse_digi.cpp | 26 | ||||
-rw-r--r-- | scumm/imuse_digi.h | 6 |
2 files changed, 23 insertions, 9 deletions
diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index 10bb921fec..4a25804be2 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -661,6 +661,10 @@ static uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo return s_size; } +IMuseDigital::Channel::Channel() + : idSound(-1), used(false), stream(0) { +} + void IMuseDigital::timer_handler(void *refCon) { IMuseDigital *imuseDigital = (IMuseDigital *)refCon; imuseDigital->callback(); @@ -691,6 +695,7 @@ IMuseDigital::~IMuseDigital() { for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) { _scumm->_mixer->stopHandle(_channel[l].handle); + delete _channel[l].stream; } delete _bundle; @@ -706,7 +711,8 @@ void IMuseDigital::callback() { if (_channel[l].used) { if (_channel[l].toBeRemoved) { debug(5, "IMuseDigital::callback(): stoped sound: %d", _channel[l].idSound); - _scumm->_mixer->endStream(_channel[l].handle); + if (_channel[l].stream) + _channel[l].stream->finish(); free(_channel[l].data); _channel[l].used = false; continue; @@ -745,12 +751,15 @@ void IMuseDigital::callback() { int pan = (_channel[l].pan != 64) ? 2 * _channel[l].pan - 127 : 0; if (_scumm->_mixer->isReady()) { - if (!_channel[l].handle.isActive()) - _scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq, - _channel[l].mixerFlags, 100000); - _scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000); - _scumm->_mixer->setChannelPan(_channel[l].handle, pan); - _scumm->_mixer->appendStream(_channel[l].handle, _channel[l].data + _channel[l].offset, mixer_size); + if (!_channel[l].stream) { + // Create an AudioInputStream and hook it to the mixer. + _channel[l].stream = makeWrappedInputStream(_channel[l].freq, _channel[l].mixerFlags, 100000); + _scumm->_mixer->playInputStream(&_channel[l].handle, _channel[l].stream, true, _channel[l].vol / 1000, _channel[l].pan, -1, false); + } else { + _scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000); + _scumm->_mixer->setChannelPan(_channel[l].handle, pan); + } + _channel[l].stream->append(_channel[l].data + _channel[l].offset, mixer_size); } _channel[l].offset += mixer_size; } @@ -802,6 +811,9 @@ void IMuseDigital::startSound(int sound) { _channel[l].offset = 0; _channel[l].idSound = sound; + + delete _channel[l].stream; + _channel[l].stream = 0; uint32 tag; int32 size = 0; diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h index eb7ade49d2..9bd7b379e9 100644 --- a/scumm/imuse_digi.h +++ b/scumm/imuse_digi.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "scumm/music.h" +#include "sound/audiostream.h" #include "sound/mixer.h" namespace Scumm { @@ -84,11 +85,12 @@ private: int idSound; int32 mixerSize; int mixerFlags; - PlayingSoundHandle handle; bool used; bool toBeRemoved; + PlayingSoundHandle handle; + WrappedAudioInputStream *stream; - Channel() : idSound(-1), used(false) {} + Channel(); }; Channel _channel[MAX_DIGITAL_CHANNELS]; |