From 49afc87b883c89c01a8638e158a5a533279ef073 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 3 Feb 2013 18:33:20 +0100 Subject: 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. --- engines/hopkins/sound.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/hopkins/sound.cpp') 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, -- cgit v1.2.3