diff options
author | Matthew Hoops | 2010-09-08 20:50:56 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-09-08 20:50:56 +0000 |
commit | 0cba4f030691f83e487ddcc688214feef9a8b65e (patch) | |
tree | 040f822b9c29f6d43d9a96e39296fd9764056dcd /engines/mohawk/sound.cpp | |
parent | 47ad577a785aaeef7856aca883b367e9b681c4b7 (diff) | |
download | scummvm-rg350-0cba4f030691f83e487ddcc688214feef9a8b65e.tar.gz scummvm-rg350-0cba4f030691f83e487ddcc688214feef9a8b65e.tar.bz2 scummvm-rg350-0cba4f030691f83e487ddcc688214feef9a8b65e.zip |
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
Diffstat (limited to 'engines/mohawk/sound.cpp')
-rw-r--r-- | engines/mohawk/sound.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
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) { |