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.
This commit is contained in:
Torbjörn Andersson 2013-02-03 18:33:20 +01:00
parent bce7139c8c
commit 49afc87b88

View File

@ -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,