diff options
author | Filippos Karapetis | 2015-06-14 13:34:37 +0300 |
---|---|---|
committer | Filippos Karapetis | 2015-06-14 13:34:37 +0300 |
commit | 9e1ae6d82a7c6dbf08f78488d99daaff416c47ae (patch) | |
tree | d2a4fbaf79d2e88642be67f678f7107001affef2 /engines/sherlock/sound.cpp | |
parent | a7e73e5785783fa0417a401a51d8cf809e4add11 (diff) | |
download | scummvm-rg350-9e1ae6d82a7c6dbf08f78488d99daaff416c47ae.tar.gz scummvm-rg350-9e1ae6d82a7c6dbf08f78488d99daaff416c47ae.tar.bz2 scummvm-rg350-9e1ae6d82a7c6dbf08f78488d99daaff416c47ae.zip |
SHERLOCK: RT: Initial support for multiple sound effects
The paper boy in the intro sounds correct now
Diffstat (limited to 'engines/sherlock/sound.cpp')
-rw-r--r-- | engines/sherlock/sound.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index 33897320d7..795ccb030e 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -192,7 +192,9 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit audioStream = Audio::makeAIFFStream(stream, DisposeAfterUse::YES); } - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_effectsHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume); + Audio::SoundHandle effectsHandle = (IS_SERRATED_SCALPEL) ? _scalpelEffectsHandle : getFreeSoundHandle(); + + _mixer->playStream(Audio::Mixer::kPlainSoundType, &effectsHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume); _soundPlaying = true; _curPriority = priority; @@ -209,22 +211,23 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit retval = false; break; } - } while (!_vm->shouldQuit() && _mixer->isSoundHandleActive(_effectsHandle)); + } while (!_vm->shouldQuit() && _mixer->isSoundHandleActive(effectsHandle)); _soundPlaying = false; - _mixer->stopHandle(_effectsHandle); + _mixer->stopHandle(effectsHandle); return retval; } void Sound::playLoadedSound(int bufNum, WaitType waitType) { - if (_mixer->isSoundHandleActive(_effectsHandle) && (_curPriority > _vm->_scene->_sounds[bufNum]._priority)) - return; + if (IS_SERRATED_SCALPEL) { + if (_mixer->isSoundHandleActive(_scalpelEffectsHandle) && (_curPriority > _vm->_scene->_sounds[bufNum]._priority)) + return; - stopSound(); - playSound(_vm->_scene->_sounds[bufNum]._name, waitType, _vm->_scene->_sounds[bufNum]._priority); + stopSound(); + } - return; + playSound(_vm->_scene->_sounds[bufNum]._name, waitType, _vm->_scene->_sounds[bufNum]._priority); } void Sound::freeLoadedSounds() { @@ -234,7 +237,12 @@ void Sound::freeLoadedSounds() { } void Sound::stopSound() { - _mixer->stopHandle(_effectsHandle); + if (IS_SERRATED_SCALPEL) { + _mixer->stopHandle(_scalpelEffectsHandle); + } else { + for (int i = 0; i < MAX_MIXER_CHANNELS; i++) + _mixer->stopHandle(_tattooEffectsHandle[i]); + } } void Sound::stopSndFuncPtr(int v1, int v2) { @@ -249,5 +257,14 @@ void Sound::freeDigiSound() { _soundPlaying = false; } +Audio::SoundHandle Sound::getFreeSoundHandle() { + for (int i = 0; i < MAX_MIXER_CHANNELS; i++) { + if (!_mixer->isSoundHandleActive(_tattooEffectsHandle[i])) + return _tattooEffectsHandle[i]; + } + + error("getFreeSoundHandle: No sound handle found"); +} + } // End of namespace Sherlock |