From 6fbadccf0874dffbe09be5908b523bd480805b83 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Sun, 18 Aug 2019 01:12:59 +0530 Subject: HDB: Fix voice playing when no message on screen --- engines/hdb/hdb.cpp | 6 ++++++ engines/hdb/menu.cpp | 1 + engines/hdb/sound.cpp | 8 ++++---- engines/hdb/sound.h | 10 ++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index 1eaa102927..43b419abdc 100644 --- a/engines/hdb/hdb.cpp +++ b/engines/hdb/hdb.cpp @@ -214,6 +214,7 @@ void HDBGame::changeGameState() { break; case GAME_PLAY: _menu->startMenu(); + _sound->stopVoices(); _gameState = GAME_MENU; break; case GAME_LOADING: @@ -1022,6 +1023,11 @@ Common::Error HDBGame::run() { _map->drawForegrounds(); _ai->animateTargets(); + // Check for voice to interrupt + if (!_window->dialogActive() && !_window->dialogChoiceActive() && !_window->msgBarActive()) { + _sound->stopVoices(); + } + _window->drawDialog(); _window->drawDialogChoice(); _window->drawInventory(); diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp index 3dc7d2fe36..c1427c6ab4 100644 --- a/engines/hdb/menu.cpp +++ b/engines/hdb/menu.cpp @@ -33,6 +33,7 @@ #include "hdb/menu.h" #include "hdb/map.h" #include "hdb/mpc.h" +#include "hdb/window.h" namespace HDB { diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp index b41622b39e..28cee431ae 100644 --- a/engines/hdb/sound.cpp +++ b/engines/hdb/sound.cpp @@ -1626,14 +1626,14 @@ void Sound::playVoice(int index, int actor) { if (!_voicesOn || g_hdb->isPPC()) return; - // make sure we aren't playing a line more than once this time (only on CHANNEL 0) - if (!actor && _voicePlayed[index - FIRST_VOICE]) - return; - // is voice channel already active? if so, shut 'er down (automagically called StopVoice via callback) if (_voices[actor].active) g_hdb->_mixer->stopHandle(*_voices[actor].handle); + // make sure we aren't playing a line more than once this time (only on CHANNEL 0) + if (!actor && _voicePlayed[index - FIRST_VOICE]) + return; + Common::SeekableReadStream *stream = nullptr; if (g_hdb->getPlatform() == Common::kPlatformLinux) { Common::String updatedName(soundList[index].name); diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h index d810cae28c..bbc4174f63 100644 --- a/engines/hdb/sound.h +++ b/engines/hdb/sound.h @@ -1513,6 +1513,16 @@ public: void playSound(int index); void playSoundEx(int index, int channel, bool loop); void playVoice(int index, int actor); + void stopVoices() { + if (_voices[0].active) { + g_hdb->_mixer->stopHandle(*_voices[0].handle); + _voices[0].active = false; + } + if (_voices[1].active) { + g_hdb->_mixer->stopHandle(*_voices[1].handle); + _voices[1].active = false; + } + } void startMusic(SoundType song); void fadeInMusic(SoundType song, int ramp); void fadeOutMusic(int ramp); -- cgit v1.2.3