diff options
author | Travis Howell | 2003-12-13 01:54:17 +0000 |
---|---|---|
committer | Travis Howell | 2003-12-13 01:54:17 +0000 |
commit | 3d04b69cbd3ab86b480eab124404c086b03cbbbc (patch) | |
tree | ef4169a5f2a8f17884ce2b914b143156daca6caa /simon | |
parent | c7a6458849fac8db44c05eb74209ad33afc0812c (diff) | |
download | scummvm-rg350-3d04b69cbd3ab86b480eab124404c086b03cbbbc.tar.gz scummvm-rg350-3d04b69cbd3ab86b480eab124404c086b03cbbbc.tar.bz2 scummvm-rg350-3d04b69cbd3ab86b480eab124404c086b03cbbbc.zip |
Don't switch voice file in simon2mac unless needed.
svn-id: r11608
Diffstat (limited to 'simon')
-rw-r--r-- | simon/sound.cpp | 35 | ||||
-rw-r--r-- | simon/sound.h | 1 |
2 files changed, 21 insertions, 15 deletions
diff --git a/simon/sound.cpp b/simon/sound.cpp index c8258ab08a..0512ddbc2a 100644 --- a/simon/sound.cpp +++ b/simon/sound.cpp @@ -242,6 +242,7 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C _ambient_paused = false; _filenums = 0; + _last_voice_file = 0; _offsets = 0; _voice_handle = 0; @@ -396,21 +397,25 @@ void SimonSound::readVoiceFile(const char *filename, const Common::String &gameD void SimonSound::playVoice(uint sound) { if (_game == GAME_SIMON2MAC && _filenums) { - stopAll(); - - char filename[16]; - sprintf(filename, "voices%d.dat", _filenums[sound]); - File *file = new File(); - file->open(filename, _gameDataPath); - if (file->isOpen() == false) { - warning("playVoice: Can't load voice file %s", filename); - return; - } - // FIXME freeing voice at this point causes frequent game crashes - // Maybe related to sound effects and speech using same sound format ? - // In any case, this means we currently leak. - // delete _voice; - _voice = new WavSound(_mixer, file, _offsets); + if (_last_voice_file != _filenums[sound]) { + warning("Loading voice file %d", _filenums[sound]); + stopAll(); + + char filename[16]; + _last_voice_file = _filenums[sound]; + sprintf(filename, "voices%d.dat", _filenums[sound]); + File *file = new File(); + file->open(filename, _gameDataPath); + if (file->isOpen() == false) { + warning("playVoice: Can't load voice file %s", filename); + return; + } + // FIXME freeing voice at this point causes frequent game crashes + // Maybe related to sound effects and speech using same sound format ? + // In any case, this means we currently leak. + // delete _voice; + _voice = new WavSound(_mixer, file, _offsets); + } } if (!_voice) diff --git a/simon/sound.h b/simon/sound.h index c7da0bfdf0..a6217540a5 100644 --- a/simon/sound.h +++ b/simon/sound.h @@ -46,6 +46,7 @@ private: uint16 *_filenums; uint32 *_offsets; + uint16 _last_voice_file; public: PlayingSoundHandle _voice_handle; |