[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.343,1.344
Travis Howell
kirben at users.sourceforge.net
Mon Jul 12 17:23:11 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21359/scumm
Modified Files:
sound.cpp
Log Message:
Fix memory leak
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.343
retrieving revision 1.344
diff -u -d -r1.343 -r1.344
--- sound.cpp 12 Jul 2004 14:21:16 -0000 1.343
+++ sound.cpp 13 Jul 2004 00:22:10 -0000 1.344
@@ -87,7 +87,7 @@
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 @@
// 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 @@
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 @@
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
}
}
More information about the Scummvm-git-logs
mailing list