aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-07-25 06:51:19 +0530
committerEugene Sandulenko2019-09-03 17:17:28 +0200
commit123b65931e366ee759344a54dcbdf012f030b1cf (patch)
tree4fc06b59a6412f501b4118e9060b316ee2165b6c
parenta09ac7b1140b3b1db32b5f6cb553643744544400 (diff)
downloadscummvm-rg350-123b65931e366ee759344a54dcbdf012f030b1cf.tar.gz
scummvm-rg350-123b65931e366ee759344a54dcbdf012f030b1cf.tar.bz2
scummvm-rg350-123b65931e366ee759344a54dcbdf012f030b1cf.zip
HDB: Add playVoice()
-rw-r--r--engines/hdb/sound.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 88bede7d9a..752f80f529 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1455,7 +1455,36 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
}
bool Sound::playVoice(int index, int actor) {
- warning("STUB: Play Voice");
+ if (!_voicesOn)
+ return false;
+
+ // make sure we aren't playing a line more than once this time (only on CHANNEL 0)
+ if (!actor && _voicePlayed[index - FIRST_VOICE])
+ return false;
+
+ // is voice channel already active? if so, shut 'er down (automagically called StopVoice via callback)
+ if (_voices[actor].active) {
+ g_hdb->_mixer->stopHandle(*_voices[actor].handle);
+ }
+
+#ifdef USE_MAD
+ Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
+ if (stream == nullptr)
+ return false;
+ Audio::AudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+ if (audioStream == nullptr) {
+ delete stream;
+ return false;
+ }
+
+ g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+
+ g_hdb->_mixer->playStream(Audio::Mixer::kSpeechSoundType, _voices[actor].handle, audioStream);
+
+ _voices[actor].active = true;
+ _voicePlayed[index - FIRST_VOICE] = 1;
+
+#endif
return true;
}