diff options
Diffstat (limited to 'engines/mohawk/sound.cpp')
-rw-r--r-- | engines/mohawk/sound.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 198627e012..38cb0b3608 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -21,13 +21,14 @@ */ #include "common/debug.h" +#include "common/events.h" #include "common/system.h" -#include "common/util.h" #include "common/textconsole.h" +#include "audio/mididrv.h" #include "audio/midiparser.h" -#include "audio/musicplugin.h" #include "audio/audiostream.h" +#include "audio/decoders/adpcm.h" #include "audio/decoders/mp3.h" #include "audio/decoders/raw.h" #include "audio/decoders/wave.h" @@ -163,8 +164,26 @@ Audio::SoundHandle *Sound::replaceSoundMyst(uint16 id, byte volume, bool loop) { void Sound::playSoundBlocking(uint16 id, byte volume) { Audio::SoundHandle *handle = playSound(id, volume); - while (_vm->_mixer->isSoundHandleActive(*handle)) + while (_vm->_mixer->isSoundHandleActive(*handle) && !_vm->shouldQuit()) { + Common::Event event; + while (_vm->_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + switch (event.kbd.keycode) { + case Common::KEYCODE_SPACE: + _vm->pauseGame(); + break; + default: + break; + } + default: + break; + } + } + + // Cut down on CPU usage _vm->_system->delayMillis(10); + } } void Sound::playMidi(uint16 id) { @@ -625,7 +644,7 @@ uint16 Sound::convertMystID(uint16 id) { return id; } -Audio::SoundHandle *Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { +void Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { debug(0, "Replacing background sound with %d", id); // TODO: The original engine does fading @@ -641,8 +660,11 @@ Audio::SoundHandle *Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { // Check if sound is already playing if (_mystBackgroundSound.type == kUsedHandle && _vm->_mixer->isSoundHandleActive(_mystBackgroundSound.handle) - && _vm->getResourceName(ID_MSND, convertMystID(_mystBackgroundSound.id)).hasPrefix(prefix)) - return &_mystBackgroundSound.handle; + && _vm->getResourceName(ID_MSND, convertMystID(_mystBackgroundSound.id)).hasPrefix(prefix)) { + // The sound is already playing, just change the volume + changeBackgroundVolumeMyst(volume); + return; + } // Stop old background sound stopBackgroundMyst(); @@ -659,10 +681,7 @@ Audio::SoundHandle *Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(rewindStream, 0); _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mystBackgroundSound.handle, audStream, -1, volume >> 8); - return &_mystBackgroundSound.handle; } - - return NULL; } void Sound::stopBackgroundMyst() { |