From c517045349f675c3f28f7860ad8dcfe53ad69677 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 30 Nov 2008 15:15:14 +0000 Subject: Fixed some looping MIDI sound effects. svn-id: r35193 --- engines/kyra/scene_hof.cpp | 3 +++ engines/kyra/scene_lok.cpp | 3 +++ engines/kyra/sound.h | 6 ++++++ engines/kyra/sound_midi.cpp | 10 ++++++++++ 4 files changed, 22 insertions(+) (limited to 'engines/kyra') diff --git a/engines/kyra/scene_hof.cpp b/engines/kyra/scene_hof.cpp index 4785b039d7..b6c25a46c7 100644 --- a/engines/kyra/scene_hof.cpp +++ b/engines/kyra/scene_hof.cpp @@ -81,6 +81,9 @@ void KyraEngine_HoF::enterNewScene(uint16 newScene, int facing, int unk1, int un moveCharacter(facing, x, y); } + // TODO: Check how the original handled sfx still playing + _sound->stopAllSoundEffects(); + bool newSoundFile = false; uint32 waitTime = 0; if (_sceneList[newScene].sound != _lastMusicCommand) { diff --git a/engines/kyra/scene_lok.cpp b/engines/kyra/scene_lok.cpp index 53c269a926..b3b830faed 100644 --- a/engines/kyra/scene_lok.cpp +++ b/engines/kyra/scene_lok.cpp @@ -48,6 +48,9 @@ void KyraEngine_LoK::enterNewScene(int sceneId, int facing, int unk1, int unk2, _abortWalkFlag = false; _abortWalkFlag2 = false; + // TODO: Check how the original handled sfx still playing + _sound->stopAllSoundEffects(); + if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) { int newSfxFile = -1; if (_currentCharacter->sceneId == 7 && sceneId == 24) diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 84aebcf363..cfffcbdbe5 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -150,6 +150,11 @@ public: */ virtual void playSoundEffect(uint8 track) = 0; + /** + * Stop playback of all sfx tracks. + */ + virtual void stopAllSoundEffects() {} + /** * Checks if the sound driver plays any sound. * @@ -334,6 +339,7 @@ public: bool isPlaying(); void playSoundEffect(uint8 track); + void stopAllSoundEffects(); void beginFadeOut(); diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp index 1ba8e79d18..1cff57d93a 100644 --- a/engines/kyra/sound_midi.cpp +++ b/engines/kyra/sound_midi.cpp @@ -639,6 +639,16 @@ void SoundMidiPC::playSoundEffect(uint8 track) { } } +void SoundMidiPC::stopAllSoundEffects() { + Common::StackLock lock(_mutex); + + for (int i = 0; i < 3; ++i) { + _output->setSoundSource(i+1); + _sfx[i]->stopPlaying(); + _output->deinitSource(i+1); + } +} + void SoundMidiPC::beginFadeOut() { Common::StackLock lock(_mutex); -- cgit v1.2.3