diff options
author | Travis Howell | 2004-07-13 00:22:10 +0000 |
---|---|---|
committer | Travis Howell | 2004-07-13 00:22:10 +0000 |
commit | 0cbed40ae4f8b3df4b67a6c44cce919348081018 (patch) | |
tree | c527715372b5884c62c01e483110a3b056adcc6d /scumm | |
parent | fd8f64f005883eb0d125c54e1b12d49c0eaac462 (diff) | |
download | scummvm-rg350-0cbed40ae4f8b3df4b67a6c44cce919348081018.tar.gz scummvm-rg350-0cbed40ae4f8b3df4b67a6c44cce919348081018.tar.bz2 scummvm-rg350-0cbed40ae4f8b3df4b67a6c44cce919348081018.zip |
Fix memory leak
svn-id: r14198
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/sound.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp index fd36374b46..4d5d3d68e0 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -87,7 +87,7 @@ Sound::~Sound() { void Sound::addSoundToQueue(int sound) { _vm->VAR(_vm->VAR_LAST_SOUND) = sound; // Music resources are in separate file - if (!((_vm->_heversion == 70 || _vm->_heversion == 71) && sound >= 4000)) + if (!((_vm->_heversion >= 70) && sound >= 4000)) _vm->ensureResourceLoaded(rtSound, sound); addSoundToQueue2(sound); } @@ -195,14 +195,15 @@ void Sound::playSound(int soundID) { // Allocate a sound buffer, copy the data into it, and play sound = (char *)malloc(size); memcpy(sound, ptr, size); + free(ptr); _currentMusic = soundID; _vm->_mixer->stopHandle(_musicChannelHandle); _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, 11025, flags, soundID); return; } - } + } else + ptr = _vm->getResourceAddress(rtSound, soundID); - ptr = _vm->getResourceAddress(rtSound, soundID); if (!ptr) { return; } @@ -706,11 +707,9 @@ int Sound::isSoundRunning(int sound) const { return pollCD(); if (_vm->_features & GF_HUMONGOUS) { - if (sound == 10000) - return (_musicChannelHandle.isActive()) ? _currentMusic : 0; - else if (sound == -2) { + if (sound == -2 || sound == 10001) { return isSfxFinished(); - } else if (sound == -1) { + } else if (sound == -1 || sound == 10000) { // getSoundStatus(), with a -1, will return the // ID number of the first active music it finds. // TODO handle MRAW (pcm music) in humongous games @@ -790,9 +789,9 @@ void Sound::stopSound(int a) { int i; if (_vm->_features & GF_HUMONGOUS) { - if (a == -2) { + if (a == -2 || a == 10001) { // Stop current sfx - } else if (a == -1) { + } else if (a == -1 || a == 10000) { // Stop current music } } |