From 0cba4f030691f83e487ddcc688214feef9a8b65e Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 8 Sep 2010 20:50:56 +0000 Subject: MOHAWK: Implement blocking sound in Riven Sounds that set the third argument of the playSound opcode to 1 (wherever they may be) will now block. The volume parameter of playSound is also now honored. Merge the Myst sound blocking code with this too. svn-id: r52643 --- engines/mohawk/sound.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'engines/mohawk/sound.cpp') diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 50a7d016f5..4a8c923c01 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -124,6 +124,13 @@ Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) { return NULL; } +void Sound::playSoundBlocking(uint16 id, byte volume) { + Audio::SoundHandle *handle = playSound(id, volume); + + while (_vm->_mixer->isSoundHandleActive(*handle)) + _vm->_system->delayMillis(10); +} + void Sound::playMidi(uint16 id) { uint32 idTag; if (!(_vm->getFeatures() & GF_HASMIDI)) { @@ -165,6 +172,10 @@ void Sound::playMidi(uint16 id) { _midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback); } +byte Sound::convertRivenVolume(uint16 volume) { + return (volume == 256) ? 255 : volume; +} + void Sound::playSLST(uint16 index, uint16 card) { Common::SeekableReadStream *slstStream = _vm->getRawData(ID_SLST, card); SLSTRecord slstRecord; @@ -287,13 +298,9 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16 if (loop) audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0); - // The max mixer volume is 255 and the max Riven volume is 256. Just change it to 255. - if (volume == 256) - volume = 255; - // TODO: Handle fading, possibly just raise the volume of the channel in increments? - _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, volume, convertBalance(balance)); + _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, convertRivenVolume(volume), convertBalance(balance)); } void Sound::stopSLSTSound(uint16 index, bool fade) { -- cgit v1.2.3