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 | |
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')
-rw-r--r-- | engines/sherlock/sound.cpp | 35 | ||||
-rw-r--r-- | engines/sherlock/sound.h | 7 |
2 files changed, 32 insertions, 10 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 diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h index 9dd2edb9ce..8514559434 100644 --- a/engines/sherlock/sound.h +++ b/engines/sherlock/sound.h @@ -39,11 +39,14 @@ enum WaitType { WAIT_RETURN_IMMEDIATELY = 0, WAIT_FINISH = 1, WAIT_KBD_OR_FINISH = 2 }; +#define MAX_MIXER_CHANNELS 10 + class Sound { private: SherlockEngine *_vm; Audio::Mixer *_mixer; - Audio::SoundHandle _effectsHandle; + Audio::SoundHandle _scalpelEffectsHandle; + Audio::SoundHandle _tattooEffectsHandle[MAX_MIXER_CHANNELS]; int _curPriority; byte decodeSample(byte sample, byte& reference, int16& scale); @@ -93,6 +96,8 @@ public: void stopSndFuncPtr(int v1, int v2); void freeDigiSound(); + + Audio::SoundHandle getFreeSoundHandle(); }; } // End of namespace Sherlock |