aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins/sound.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2012-11-12 20:09:29 +1100
committerPaul Gilbert2012-11-12 20:09:29 +1100
commitff9dc4ab248e47c15076dd822b635927f7b27161 (patch)
treedc4677fe35e91c9e51565c237da850257c6715a1 /engines/hopkins/sound.cpp
parent66ef127280debf3586ee1074b50fa193eb03d81e (diff)
downloadscummvm-rg350-ff9dc4ab248e47c15076dd822b635927f7b27161.tar.gz
scummvm-rg350-ff9dc4ab248e47c15076dd822b635927f7b27161.tar.bz2
scummvm-rg350-ff9dc4ab248e47c15076dd822b635927f7b27161.zip
HOPKINS: Bugfix for freeze when looking at the cat when voices are turned on.
Diffstat (limited to 'engines/hopkins/sound.cpp')
-rw-r--r--engines/hopkins/sound.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
index e23c7e525f..9cbfa39f71 100644
--- a/engines/hopkins/sound.cpp
+++ b/engines/hopkins/sound.cpp
@@ -331,6 +331,11 @@ void SoundManager::DEL_MUSIC() {
Music._currentIndex = -1;
}
+void SoundManager::checkSounds() {
+ checkMusic();
+ checkVoices();
+}
+
void SoundManager::checkMusic() {
if (Music._active && Music._isPlaying) {
int mwavIndex = Music._mwavIndexes[Music._currentIndex];
@@ -363,6 +368,20 @@ void SoundManager::checkMusic() {
}
}
+void SoundManager::checkVoices() {
+ // Check the status of each voice.
+ bool hasActiveVoice = false;
+ for (int i = 0; i < VOICE_COUNT; ++i) {
+ VOICE_STAT(i);
+ hasActiveVoice |= Voice[i]._status != 0;
+ }
+
+ if (!hasActiveVoice && SOUND_FLAG) {
+ SOUND_FLAG = false;
+ SOUND_NUM = 0;
+ }
+}
+
void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) {
if (!Mwav[mwavIndex]._active) {
Common::File f;
@@ -578,7 +597,8 @@ void SoundManager::PLAY_WAV(int wavIndex) {
int SoundManager::VOICE_STAT(int voiceIndex) {
if (Voice[voiceIndex]._status) {
- if (Voice[voiceIndex]._audioStream->endOfStream())
+ int wavIndex = Voice[voiceIndex]._wavIndex;
+ if (Swav[wavIndex]._audioStream->endOfStream())
STOP_VOICE(voiceIndex);
}
@@ -599,7 +619,6 @@ void SoundManager::STOP_VOICE(int voiceIndex) {
Voice[voiceIndex].fieldC = 0;
Voice[voiceIndex]._status = 0;
Voice[voiceIndex].field14 = 0;
- Voice[voiceIndex]._audioStream = NULL;
}
void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) {
@@ -691,9 +710,9 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) {
DEL_SAMPLE_SDL(wavIndex);
Voice[voiceIndex].fieldC = 0;
- Voice[voiceIndex]._audioStream = Swav[wavIndex]._audioStream;
Voice[voiceIndex]._status = 1;
Voice[voiceIndex].field14 = 4;
+ Voice[voiceIndex]._wavIndex = wavIndex;
int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16;