From 5e726f604316d31695dbf289870abfef08c8b9b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Jul 2011 19:18:00 +1000 Subject: TSAGE: Tweaks to better detect when a playing sound effect has ended --- engines/tsage/sound.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'engines/tsage') diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 60b11e3f8c..69ac426964 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -2803,6 +2803,7 @@ SoundBlasterDriver::SoundBlasterDriver(): SoundDriver() { _mixer = _vm->_mixer; _sampleRate = _mixer->getOutputRate(); _audioStream = NULL; + _channelData = NULL; } SoundBlasterDriver::~SoundBlasterDriver() { @@ -2835,6 +2836,8 @@ void SoundBlasterDriver::playSound(const byte *channelData, int dataOffset, int if (program != -1) return; + assert(channel == 0); + // If sound data has been previously set, then release it if (_channelData) updateVoice(channel); @@ -2856,7 +2859,12 @@ void SoundBlasterDriver::playSound(const byte *channelData, int dataOffset, int } void SoundBlasterDriver::updateVoice(int channel) { - // No implementation + // Stop the playing voice + if (_mixer->isSoundHandleActive(_soundHandle)) + _mixer->stopHandle(_soundHandle); + + _audioStream = NULL; + _channelData = NULL; } void SoundBlasterDriver::proc38(int channel, int cmd, int value) { @@ -2875,9 +2883,7 @@ void SoundBlasterDriver::proc42(int channel, int cmd, int value, int *v1, int *v // method in the sample playing code. But since we're using the ScummVM audio soundsystem, // it's easier simply to do the check right here if (_audioStream && (_audioStream->numQueuedStreams() == 0)) { - _mixer->stopHandle(_soundHandle); - _audioStream = NULL; - _channelData = NULL; + updateVoice(channel); } if (!_channelData) -- cgit v1.2.3