diff options
Diffstat (limited to 'engines/saga')
-rw-r--r-- | engines/saga/sfuncs.cpp | 2 | ||||
-rw-r--r-- | engines/saga/sndres.cpp | 2 | ||||
-rw-r--r-- | engines/saga/sound.cpp | 13 | ||||
-rw-r--r-- | engines/saga/sound.h | 3 |
4 files changed, 17 insertions, 3 deletions
diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 99a9cbf4d9..328d4040af 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1464,6 +1464,8 @@ void Script::sfPlayLoopedSound(SCRIPTFUNC_PARAMS) { } else { _vm->_sound->stopSound(); } + + debug(1, "sfPlayLoopedSound(%d)", param); } // Script function #72 (0x48) diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 8ea3fc4003..a27608dcf5 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -159,7 +159,7 @@ void SndRes::playSound(uint32 resourceId, int volume, bool loop) { return; } - _vm->_sound->playSound(buffer, volume, loop); + _vm->_sound->playSound(buffer, volume, loop, resourceId); } void SndRes::playVoice(uint32 resourceId) { diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 811ee709f7..db979e8104 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -105,10 +105,20 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffe _mixer->playStream(soundType, handle, Audio::makeLoopingAudioStream(stream, loop ? 0 : 1), -1, volume); } -void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) { +void Sound::playSound(SoundBuffer &buffer, int volume, bool loop, int resId) { + // WORKAROUND + // Prevent playing same looped sound for several times + // Fixes bug #2886141: "ITE: Cumulative Snoring sounds in Prince's Bedroom" + for (int i = 0; i < SOUND_HANDLES; i++) + if (_handles[i].type == kEffectHandle && _handles[i].resId == resId) { + debug(1, "Skipped playing SFX #%d", resId); + return; + } + SndHandle *handle = getHandle(); handle->type = kEffectHandle; + handle->resId = resId; playSoundBuffer(&handle->handle, buffer, 2 * volume, handle->type, loop); } @@ -129,6 +139,7 @@ void Sound::stopSound() { if (_handles[i].type == kEffectHandle) { _mixer->stopHandle(_handles[i].handle); _handles[i].type = kFreeHandle; + _handles[i].resId = -1; } } diff --git a/engines/saga/sound.h b/engines/saga/sound.h index 9cf8f29767..7ee2765a0f 100644 --- a/engines/saga/sound.h +++ b/engines/saga/sound.h @@ -63,6 +63,7 @@ enum sndHandleType { struct SndHandle { Audio::SoundHandle handle; sndHandleType type; + int resId; }; class Sound { @@ -71,7 +72,7 @@ public: Sound(SagaEngine *vm, Audio::Mixer *mixer); ~Sound(); - void playSound(SoundBuffer &buffer, int volume, bool loop); + void playSound(SoundBuffer &buffer, int volume, bool loop, int resId); void pauseSound(); void resumeSound(); void stopSound(); |