Browse Source

Fixed a memory leak in Sources created from SoundData.

Alex Szpakowski 11 years ago
parent
commit
346aa7d839
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/modules/audio/openal/Source.cpp

+ 4 - 1
src/modules/audio/openal/Source.cpp

@@ -68,7 +68,10 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
 	, toLoop(0)
 {
 	ALenum fmt = getFormat(soundData->getChannels(), soundData->getBitDepth());
-	staticBuffer = new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate());
+	staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate()));
+
+	// The buffer has a +2 retain count right now, but we want it to have +1.
+	staticBuffer->release();
 
 	float z[3] = {0, 0, 0};