fix sound buffer resource leak

Openal doesn't remove buffers unless they were disconnected form
their source.
This commit is contained in:
ThorstenB
2011-12-04 21:25:42 +01:00
parent e17b3a753e
commit 97fcf48caa
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -113,6 +113,8 @@ void SGSampleGroup::update( double dt ) {
sample->stop(); sample->stop();
if ( !sample->is_queue() ) { if ( !sample->is_queue() ) {
ALuint buffer = sample->get_buffer(); ALuint buffer = sample->get_buffer();
// disconnect buffer from its source - otherwise it cannot be deleted
alSourceUnqueueBuffers(sample->get_source(), 1, &buffer);
alDeleteBuffers( 1, &buffer ); alDeleteBuffers( 1, &buffer );
testForALError("buffer remove"); testForALError("buffer remove");
} }
+1 -1
View File
@@ -180,7 +180,7 @@ public:
/** /**
* Request to stop playing the refered audio sample. * Request to stop playing the refered audio sample.
* @param refname Reference name of the audio sample to stop * @param refname Reference name of the audio sample to stop
* @return true if the audio sample exsists and is scheduled to stop * @return true if the audio sample exists and is scheduled to stop
*/ */
bool stop( const string& refname ); bool stop( const string& refname );