diff options
| author | Paul Gilbert | 2012-11-12 20:09:29 +1100 | 
|---|---|---|
| committer | Paul Gilbert | 2012-11-12 20:09:29 +1100 | 
| commit | ff9dc4ab248e47c15076dd822b635927f7b27161 (patch) | |
| tree | dc4677fe35e91c9e51565c237da850257c6715a1 | |
| parent | 66ef127280debf3586ee1074b50fa193eb03d81e (diff) | |
| download | scummvm-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.
| -rw-r--r-- | engines/hopkins/events.cpp | 2 | ||||
| -rw-r--r-- | engines/hopkins/sound.cpp | 25 | ||||
| -rw-r--r-- | engines/hopkins/sound.h | 19 | 
3 files changed, 36 insertions, 10 deletions
| diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index 3a54e8788d..81ca05b236 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -154,7 +154,7 @@ void EventsManager::CHANGE_MOUSE(int id) {  // Check Events  void EventsManager::CONTROLE_MES() { -	_vm->_soundManager.checkMusic(); +	_vm->_soundManager.checkSounds();  	pollEvents();  } 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; diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h index 88cecbbea7..36184715ba 100644 --- a/engines/hopkins/sound.h +++ b/engines/hopkins/sound.h @@ -35,7 +35,6 @@ class VoiceItem {  public:  	int _status;  	int _wavIndex; -	Audio::RewindableAudioStream *_audioStream;  	int fieldC;  	int field14;  }; @@ -96,6 +95,18 @@ private:  	void PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex);  	void LOAD_MSAMPLE(int mwavIndex, const Common::String &file);  	void DEL_MSAMPLE(int mwavIndex); + +	/** +	 * Checks the music structure to see if music playback is active, and whether +	 * it needs to move to the next WAV file +	 */ +	void checkMusic(); + +	/** +	 * Checks voices to see if they're finished +	 */ +	void checkVoices(); +  public:  	int SPECIAL_SOUND;  	int SOUNDVOL; @@ -137,11 +148,6 @@ public:  	void STOP_MUSIC();  	void DEL_MUSIC(); -	/** -	 * Checks the music structure to see if music playback is active, and whether -	 * it needs to move to the next WAV file -	 */ -	void checkMusic();  	bool VOICE_MIX(int voiceId, int voiceMode);  	void DEL_SAMPLE(int soundIndex); @@ -156,6 +162,7 @@ public:  	void syncSoundSettings();  	void updateScummVMSoundSettings(); +	void checkSounds();  };  } // End of namespace Hopkins | 
