[Scummvm-cvs-logs] scummvm master -> 980810703e66a82d9868ac2fd4968261299e7468

dreammaster dreammaster at scummvm.org
Sat Oct 10 23:03:45 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:
980810703e SHERLOCK: SS: Clean up speech playback to use playSpeech


Commit: 980810703e66a82d9868ac2fd4968261299e7468
    https://github.com/scummvm/scummvm/commit/980810703e66a82d9868ac2fd4968261299e7468
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-10-10T17:03:11-04:00

Commit Message:
SHERLOCK: SS: Clean up speech playback to use playSpeech

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



diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp
index 2fb2221..375b27b 100644
--- a/engines/sherlock/scalpel/scalpel_talk.cpp
+++ b/engines/sherlock/scalpel/scalpel_talk.cpp
@@ -498,7 +498,7 @@ OpcodeReturn ScalpelTalk::cmdSfxCommand(const byte *&str) {
 	if (sound._voices) {
 		for (int idx = 0; idx < 8 && str[idx] != '~'; ++idx)
 			tempString += str[idx];
-		sound.playSound(tempString, WAIT_RETURN_IMMEDIATELY);
+		sound.playSpeech(tempString);
 
 		// Set voices to wait for more
 		sound._voices = 2;
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 1d809cf..36ca67b 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -123,23 +123,7 @@ byte Sound::decodeSample(byte sample, byte &reference, int16 &scale) {
 bool Sound::playSound(const Common::String &name, WaitType waitType, int priority, const char *libraryFilename) {
 	stopSound();
 
-	Common::String filename = name;
-	if (!filename.contains('.')) {
-		if (!IS_3DO) {
-			if (IS_SERRATED_SCALPEL) {
-				filename += ".SND";
-			} else {
-				filename += ".WAV";
-			}
-		} else {
-			// 3DO uses .aiff extension
-			filename += ".AIFF";
-			if (!filename.contains('/')) {
-				// if no directory was given, use the room sounds directory
-				filename = "rooms/sounds/" + filename;
-			}
-		}
-	}
+	Common::String filename = formFilename(name);
 
 	Audio::SoundHandle &soundHandle = (IS_SERRATED_SCALPEL) ? _scalpelEffectsHandle : getFreeSoundHandle();
 	if (!playSoundResource(filename, libraryFilename, Audio::Mixer::kSFXSoundType, soundHandle))
@@ -168,6 +152,29 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit
 	return retval;
 }
 
+Common::String Sound::formFilename(const Common::String &name) {
+	Common::String filename = name;
+
+	if (!filename.contains('.')) {
+		if (!IS_3DO) {
+			if (IS_SERRATED_SCALPEL) {
+				filename += ".SND";
+			} else {
+				filename += ".WAV";
+			}
+		} else {
+			// 3DO uses .aiff extension
+			filename += ".AIFF";
+			if (!filename.contains('/')) {
+				// if no directory was given, use the room sounds directory
+				filename = "rooms/sounds/" + filename;
+			}
+		}
+	}
+
+	return filename;
+}
+
 void Sound::playAiff(const Common::String &name, int volume, bool loop) {
 	Common::File *file = new Common::File();
 	if (!file->open(name)) {
@@ -238,46 +245,41 @@ void Sound::setVolume(int volume) {
 void Sound::playSpeech(const Common::String &name) {
 	Resources &res = *_vm->_res;
 	Scene &scene = *_vm->_scene;
-	assert(IS_ROSE_TATTOO);
 
 	// Stop any previously playing speech
 	stopSpeech();
 
-	// Figure out which speech library to use
-	Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
-	if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
-			|| (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
-		libraryName = "SPEECH12.LIB";
-
-	// If the speech library file doesn't even exist, then we can't play anything
-	Common::File f;
-	if (!f.exists(libraryName))
-		return;
+	if (IS_SERRATED_SCALPEL) {
+		Common::String filename = formFilename(name);
+		if (playSoundResource(filename, nullptr, Audio::Mixer::kSFXSoundType, _speechHandle))
+			_speechPlaying = true;
+	} else {
+		// Figure out which speech library to use
+		Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
+		if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
+				|| (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
+			libraryName = "SPEECH12.LIB";
+
+		// If the speech library file doesn't even exist, then we can't play anything
+		Common::File f;
+		if (!f.exists(libraryName))
+			return;
 
-	// Ensure the given library is in the cache
-	res.addToCache(libraryName);
+		// Ensure the given library is in the cache
+		res.addToCache(libraryName);
 
-	if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
-		_speechPlaying = true;
+		if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
+			_speechPlaying = true;
+	}
 }
 
 void Sound::stopSpeech() {
-	if (IS_SERRATED_SCALPEL) {
-		_mixer->stopHandle(_scalpelEffectsHandle);
-	} else {
-		_mixer->stopHandle(_speechHandle);
-	}
+	_mixer->stopHandle(_speechHandle);
 	_speechPlaying = false;
 }
 
 bool Sound::isSpeechPlaying() {
 	_speechPlaying = _mixer->isSoundHandleActive(_speechHandle);
-
-	if (IS_SERRATED_SCALPEL) {
-		_soundPlaying = _mixer->isSoundHandleActive(_scalpelEffectsHandle);
-		return _soundPlaying;
-	}
-
 	return _speechPlaying;
 }
 
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
index d086bcd..0a0ff83 100644
--- a/engines/sherlock/sound.h
+++ b/engines/sherlock/sound.h
@@ -61,6 +61,11 @@ private:
 	 */
 	bool playSoundResource(const Common::String &name, const Common::String &libFilename,
 		Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle);
+
+	/**
+	 * Form a filename from a passed sound resource name
+	 */
+	Common::String formFilename(const Common::String &name);
 public:
 	bool _digitized;
 	int _voices;






More information about the Scummvm-git-logs mailing list