From 9f070d0736db8faef9a7c5bb8e7154eea18bdb59 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 11 Jan 2020 21:18:48 +0100 Subject: [PATCH] KYRA: (HOF) - fix speech glitch (bug #11309) (the original does not cut off the current speech playback when starting a new voc file, but rather waits for it to finish) --- engines/kyra/engine/kyra_hof.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/kyra/engine/kyra_hof.cpp b/engines/kyra/engine/kyra_hof.cpp index 2e5d091bf9b..6f303c1cfa2 100644 --- a/engines/kyra/engine/kyra_hof.cpp +++ b/engines/kyra/engine/kyra_hof.cpp @@ -1419,6 +1419,15 @@ void KyraEngine_HoF::snd_playVoiceFile(int id) { assert(id >= 0 && id <= 9999999); sprintf(vocFile, "%07d", id); if (_sound->isVoicePresent(vocFile)) { + // Unlike the original I have added a timeout here. I have chosen a size that makes sure that it + // won't get triggered in any of the bug #11309 situations, but still avoids infinite hangups if + // something goes wrong. + uint32 end = _system->getMillis() + 2500; + while (snd_voiceIsPlaying() && _system->getMillis() < end && !skipFlag()) + delay(10); + if (_system->getMillis() >= end && !skipFlag()) + debugC(3, kDebugLevelSound, "KyraEngine_HoF::snd_playVoiceFile(): Speech finish wait timeout"); + snd_stopVoice(); while (!_sound->voicePlay(vocFile, &_speechHandle)) {