[Scummvm-cvs-logs] scummvm master -> 9e1ae6d82a7c6dbf08f78488d99daaff416c47ae

bluegr bluegr at gmail.com
Sun Jun 14 12:35:47 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9e1ae6d82a SHERLOCK: RT: Initial support for multiple sound effects


Commit: 9e1ae6d82a7c6dbf08f78488d99daaff416c47ae
    https://github.com/scummvm/scummvm/commit/9e1ae6d82a7c6dbf08f78488d99daaff416c47ae
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-06-14T13:34:37+03:00

Commit Message:
SHERLOCK: RT: Initial support for multiple sound effects

The paper boy in the intro sounds correct now

Changed paths:
    engines/sherlock/sound.cpp
    engines/sherlock/sound.h



diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 3389732..795ccb0 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 9dd2edb..8514559 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






More information about the Scummvm-git-logs mailing list