aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/sound.cpp
diff options
context:
space:
mode:
authorStrangerke2015-05-12 21:34:45 +0200
committerWillem Jan Palenstijn2015-05-13 14:43:50 +0200
commit72c9b9f56b99ca9c286de8618be4f473c0969983 (patch)
treeac785f04f7593cc707bb13db4152d3545fb599b8 /engines/sherlock/sound.cpp
parent3a74cb7b57e09e9826c6534c5d53a53753045524 (diff)
downloadscummvm-rg350-72c9b9f56b99ca9c286de8618be4f473c0969983.tar.gz
scummvm-rg350-72c9b9f56b99ca9c286de8618be4f473c0969983.tar.bz2
scummvm-rg350-72c9b9f56b99ca9c286de8618be4f473c0969983.zip
SHERLOCK: Implement sound priority
Diffstat (limited to 'engines/sherlock/sound.cpp')
-rw-r--r--engines/sherlock/sound.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 51563d17a6..09e55ec82b 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -38,6 +38,7 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer): _vm(vm), _mixer(mixer) {
_diskSoundPlaying = false;
_soundPlaying = false;
_soundIsOn = &_soundPlaying;
+ _curPriority = 0;
_soundOn = true;
_musicOn = true;
@@ -57,8 +58,7 @@ void Sound::syncSoundSettings() {
}
void Sound::loadSound(const Common::String &name, int priority) {
- // TODO
- warning("TODO: Sound::loadSound");
+ // No implementation required in ScummVM
}
char Sound::decodeSample(char sample, byte& prediction, int& step) {
@@ -86,8 +86,8 @@ char Sound::decodeSample(char sample, byte& prediction, int& step) {
return prediction;
}
-bool Sound::playSound(const Common::String &name, WaitType waitType) {
- _mixer->stopHandle(_effectsHandle);
+bool Sound::playSound(const Common::String &name, WaitType waitType, int priority) {
+ stopSound();
Common::String filename = name;
if (!filename.contains('.'))
@@ -103,7 +103,7 @@ bool Sound::playSound(const Common::String &name, WaitType waitType) {
byte *decoded = (byte *)malloc((size - 1) * 2);
- // +127 to eliminate the pop when the sound starts (signed vs unsignded PCM). Still does not help with the pop at the end
+ // +127 to eliminate the pop when the sound starts (signed vs unsigned PCM). Still does not help with the pop at the end
byte prediction = (ptr[0] & 0x0f) + 127;
int step = 0;
int counter = 0;
@@ -118,6 +118,7 @@ bool Sound::playSound(const Common::String &name, WaitType waitType) {
Audio::AudioStream *audioStream = Audio::makeRawStream(decoded, (size - 2) * 2, rate, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_effectsHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume);
_soundPlaying = true;
+ _curPriority = priority;
if (waitType == WAIT_RETURN_IMMEDIATELY) {
_diskSoundPlaying = true;
@@ -148,34 +149,24 @@ bool Sound::playSound(const Common::String &name, WaitType waitType) {
return retval;
}
-void Sound::cacheSound(const Common::String &name, int index) {
- // TODO
- warning("TODO: Sound::cacheSound");
-}
+void Sound::playLoadedSound(int bufNum, WaitType waitType) {
+ if (_mixer->isSoundHandleActive(_effectsHandle) && (_curPriority > _vm->_scene->_sounds[bufNum]._priority))
+ return;
-void Sound::playLoadedSound(int bufNum, int waitMode) {
- // TODO
- warning("TODO: Sound::playLoadedSound");
-}
+ stopSound();
+ playSound(_vm->_scene->_sounds[bufNum]._name, waitType, _vm->_scene->_sounds[bufNum]._priority);
-void Sound::playCachedSound(int index) {
- // TODO
- warning("TODO: Sound::playCachedSound");
+ return;
}
void Sound::freeLoadedSounds() {
- // TODO
- warning("TODO: Sound::clearLoadedSound");
-}
-
-void Sound::clearCache() {
- // TODO
- warning("TODO: Sound::clearCache");
+ // As sounds are played with DisposeAfterUse::YES, stopping the sounds also
+ // frees them
+ stopSound();
}
void Sound::stopSound() {
- // TODO
- warning("TODO: Sound::stopSound");
+ _mixer->stopHandle(_effectsHandle);
}
void Sound::playMusic(const Common::String &name) {