aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2013-02-03 18:33:20 +0100
committerTorbjörn Andersson2013-02-03 18:33:20 +0100
commit49afc87b883c89c01a8638e158a5a533279ef073 (patch)
tree4bbe977e0a86e213815e81694bf0ae084c31678d
parentbce7139c8c5ed3966f9750c46ccfa83f6ad692c1 (diff)
downloadscummvm-rg350-49afc87b883c89c01a8638e158a5a533279ef073.tar.gz
scummvm-rg350-49afc87b883c89c01a8638e158a5a533279ef073.tar.bz2
scummvm-rg350-49afc87b883c89c01a8638e158a5a533279ef073.zip
HOPKINS: Attempt to fix crash when skipping movie
Before starting an "Swav" sound, check that its sound handle isn't already used. If it is, stop it. When skipping a movie, it still (incorrectly?) goes through the motions of playing the remaining frames, including starting any movie sounds on the way. This would cause us to lose the handle to the sound that was currently playing in the "Swav" slot, and I *think* that's what ended up confusing things. I'm still not entirely sure exactly what was happening.
-rw-r--r--engines/hopkins/sound.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
index 96c7df2329..7b59f1ee62 100644
--- a/engines/hopkins/sound.cpp
+++ b/engines/hopkins/sound.cpp
@@ -824,6 +824,12 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) {
int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16;
+ // If the handle is still in use, stop it. Otherwise we'll lose the
+ // handle to that sound. This can currently happen (but probably
+ // shouldn't) when skipping a movie.
+ if (_vm->_mixer->isSoundHandleActive(Swav[wavIndex]._soundHandle))
+ _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle);
+
// Start the voice playing
Swav[wavIndex]._audioStream->rewind();
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle,