Audio Memory (solved)
by John Casamassina · in Torque Game Builder · 07/10/2009 (2:49 pm) · 6 replies
Audio memory was not being freed when the profile was deleted. This fix ensures the buffer is cleared when a sound finished playing and when it is stopped. An onRemove callback for audio profiles is also included to deconstruct the buffer directly without having to call purgeResources.
audio.cc in alxCloseHandles() add:
audio.cc in alxStop() add:
audioBuffer.cc replace ~AudioBuffer() with:
audioDataBlock.cc add onRemove() under onAdd():
audioDataBlock.h in AudioProfile - public add:
audio.cc in alxCloseHandles() add:
alSourcei(mSource[i], AL_BUFFER, AL_NONE);above
mHandle[i] = NULL_AUDIOHANDLE;
audio.cc in alxStop() add:
alSourcei(mSource[i], AL_BUFFER, AL_NONE);above
mSampleEnvironment[index] = 0;
audioBuffer.cc replace ~AudioBuffer() with:
AudioBuffer::~AudioBuffer()
{
if(malBuffer != 0)
{
alGetError();
alDeleteBuffers( 1, &malBuffer );
ALenum error = alGetError();
AssertWarn( error == AL_NO_ERROR, "AudioBuffer::~AudioBuffer() - failed to release buffer" );
}
}audioDataBlock.cc add onRemove() under onAdd():
//--------------------------------------------------------------------------
void AudioProfile::onRemove()
{
// Purge buffer if it exists
if(bool(mBuffer))
mBuffer.purge();
// Move up heirarchy
Parent::onRemove();
}audioDataBlock.h in AudioProfile - public add:
virtual void onRemove();below
virtual bool onAdd();
About the author
#2
Thanks!
07/30/2009 (10:06 pm)
I can confirm that this works as-is in TGE 1.5.2 (+AFX +VMPlayer +CustomStuff). I can also confirm that this builds perfectly on Linux.Thanks!
#3
04/07/2010 (6:26 pm)
This fix works perfectly with TGB 1.7.4 also. Many thanks for sharing!
#4
06/10/2010 (3:03 am)
Fantastic!!!!
#5
08/01/2010 (11:22 pm)
Did this fix get put into TGB 1.75, or do we still need to merge this in?
#6
08/02/2010 (1:51 am)
Yep, it's been added to 1.7.5.
Associate William Lee Sims
Machine Code Games