diff options
author | Max Horn | 2003-11-29 11:56:24 +0000 |
---|---|---|
committer | Max Horn | 2003-11-29 11:56:24 +0000 |
commit | d98479ee5dd0b70c88c37ea2c405694bf070ea88 (patch) | |
tree | ea3f9671b111cfcec164620de3f50820822cdb33 | |
parent | d636ee7855593a4d6342b48fa9ac13e75b231710 (diff) | |
download | scummvm-rg350-d98479ee5dd0b70c88c37ea2c405694bf070ea88.tar.gz scummvm-rg350-d98479ee5dd0b70c88c37ea2c405694bf070ea88.tar.bz2 scummvm-rg350-d98479ee5dd0b70c88c37ea2c405694bf070ea88.zip |
cleanup; fix some memory leaks; more memory leaks remaining
svn-id: r11419
-rw-r--r-- | simon/sound.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/simon/sound.cpp b/simon/sound.cpp index 8bc071a53a..4c241810ad 100644 --- a/simon/sound.cpp +++ b/simon/sound.cpp @@ -256,14 +256,17 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C #ifdef USE_MAD file->open(gss->mp3_filename, gameDataPath); - if (file->isOpen() == false) { + if (file->isOpen()) { + _voice_file = true; + _voice = new MP3Sound(_mixer, file); + } #endif + if (!file->isOpen()) { // for simon2 mac/amiga, only read index file if (_game == GAME_SIMON2MAC) { file->open("voices.idx", gameDataPath); if (file->isOpen() == false) { warning("Can't open voice index file 'voices.idx'"); - delete file; } else { file->seek(0, SEEK_END); int end = file->pos(); @@ -277,11 +280,13 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C } _voice_file = true; } + delete file; } else if (_game & GF_WIN) { s = gss->wav_filename; file->open(s, gameDataPath); if (file->isOpen() == false) { warning("Can't open voice file %s", s); + delete file; } else { _voice_file = true; _voice = new WavSound(_mixer, file); @@ -294,24 +299,23 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C file->open(s, gameDataPath); if (file->isOpen() == false) { warning("Can't open voice file %s", s); + delete file; } else { _voice_file = true; _voice = new VocSound(_mixer, file); } } -#ifdef USE_MAD - } else { - _voice_file = true; - _voice = new MP3Sound(_mixer, file); } -#endif if (_game == GAME_SIMON1ACORN || _game == GAME_SIMON1TALKIE) { file = new File(); #ifdef USE_MAD file->open(gss->mp3_effects_filename, gameDataPath); - if (file->isOpen() == false) { + if (file->isOpen()) { + _effects = new MP3Sound(_mixer, file); + } #endif + if (!file->isOpen()) { s = gss->voc_effects_filename; file->open(s, gameDataPath); if (file->isOpen() == false) { @@ -319,11 +323,7 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C } else { _effects = new VocSound(_mixer, file); } -#ifdef USE_MAD - } else { - _effects = new MP3Sound(_mixer, file); } -#endif } } @@ -408,6 +408,7 @@ void SimonSound::playVoice(uint sound) { } // 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); } |