From 74e94ac7f32dfd06567cd153127b9dafc2dec5d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 11 Aug 2016 21:18:12 -0400 Subject: TITANIC: Hook up wave pump for callbacks --- engines/titanic/events.cpp | 10 ++++++---- engines/titanic/sound/qmixer.cpp | 3 ++- engines/titanic/sound/sound_manager.cpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp index 8a7cd550e8..318ddf5726 100644 --- a/engines/titanic/events.cpp +++ b/engines/titanic/events.cpp @@ -84,6 +84,11 @@ void Events::pollEvents() { void Events::pollEventsAndWait() { pollEvents(); g_system->delayMillis(10); + + // Regularly update the sound mixer + CGameManager *gameManager = g_vm->_window->_gameManager; + if (gameManager) + gameManager->_sound.updateMixer(); } bool Events::checkForNextFrameCounter() { @@ -114,12 +119,9 @@ uint32 Events::getTicksCount() const { void Events::sleep(uint time) { uint32 delayEnd = g_system->getMillis() + time; - CSound &sound = g_vm->_window->_gameManager->_sound; - while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) { + while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) pollEventsAndWait(); - sound.updateMixer(); - } } bool Events::waitForPress(uint expiry) { diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp index da4f6725a5..32554a5659 100644 --- a/engines/titanic/sound/qmixer.cpp +++ b/engines/titanic/sound/qmixer.cpp @@ -138,7 +138,8 @@ void QMixer::qsWaveMixPump() { if (!channel._sounds.empty()) { SoundEntry &sound = channel._sounds.front(); if (sound._started && !_mixer->isSoundHandleActive(sound._soundHandle)) { - sound._callback(iChannel, sound._waveFile, sound._userData); + if (sound._callback) + sound._callback(iChannel, sound._waveFile, sound._userData); channel._sounds.erase(channel._sounds.begin()); } } diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index 8d92e0cf8c..18ad9703ea 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -323,7 +323,7 @@ bool QSoundManager::isActive(const CWaveFile *waveFile) const { } void QSoundManager::waveMixPump() { - + qsWaveMixPump(); } uint QSoundManager::getLatency() const { -- cgit v1.2.3