diff options
author | Sylvain Dupont | 2010-11-12 22:31:04 +0000 |
---|---|---|
committer | Sylvain Dupont | 2010-11-12 22:31:04 +0000 |
commit | 8a4cc14b1ae2b81055b710699854e25b02db9be9 (patch) | |
tree | 363e1feb3958be82e88fc75fda819877384fe782 /engines/toon/audio.cpp | |
parent | fd82c3783d1e563e9c3526aeb0d75e79ebcc0d76 (diff) | |
download | scummvm-rg350-8a4cc14b1ae2b81055b710699854e25b02db9be9.tar.gz scummvm-rg350-8a4cc14b1ae2b81055b710699854e25b02db9be9.tar.bz2 scummvm-rg350-8a4cc14b1ae2b81055b710699854e25b02db9be9.zip |
TOON: Fix audio crashs and more memory leaks
svn-id: r54219
Diffstat (limited to 'engines/toon/audio.cpp')
-rw-r--r-- | engines/toon/audio.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/engines/toon/audio.cpp b/engines/toon/audio.cpp index 3fba7d6cd8..2a1e1c2019 100644 --- a/engines/toon/audio.cpp +++ b/engines/toon/audio.cpp @@ -64,6 +64,7 @@ AudioManager::AudioManager(ToonEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixe } AudioManager::~AudioManager(void) { + _mixer->stopAll(); for (int32 i = 0; i < 4; i++) { closeAudioPack(i); } @@ -130,7 +131,7 @@ void AudioManager::playMusic(Common::String dir, Common::String music) { _currentMusicChannel = 0; } - delete _channels[_currentMusicChannel]; + // no need to delete instance here it will automatically deleted by the mixer is done with it _channels[_currentMusicChannel] = new AudioStreamInstance(this, _mixer, srs, true); _channels[_currentMusicChannel]->setVolume(_musicMuted ? 0 : 255); _channels[_currentMusicChannel]->play(true, Audio::Mixer::kMusicSoundType); @@ -157,7 +158,7 @@ void AudioManager::playVoice(int32 id, bool genericVoice) { else stream = _audioPacks[1]->getStream(id); - delete _channels[2]; + // no need to delete channel 2, it will be deleted by the mixer when the stream is finished _channels[2] = new AudioStreamInstance(this, _mixer, stream); _channels[2]->play(false, Audio::Mixer::kSpeechSoundType); _channels[2]->setVolume(_voiceMuted ? 0 : 255); @@ -278,6 +279,9 @@ AudioStreamInstance::~AudioStreamInstance() { int AudioStreamInstance::readBuffer(int16 *buffer, const int numSamples) { debugC(5, kDebugAudio, "readBuffer(buffer, %d)", numSamples); + if(_stopped) + return 0; + handleFade(numSamples); int32 leftSamples = numSamples; int32 destOffset = 0; |