shithub: choc

Download patch

ref: d811a1bec4ec09153ee6fcf376e2a10ca3a274a2
parent: 2c2bfe845a64e7b68a375f00f3c84a8378661b8c
author: Jonathan Dowland <[email protected]>
date: Mon Jul 6 16:00:09 EDT 2015

Immediately free pitch-shifted sound effects

When we stop playing a sound effect on a channel, check to see
whether it is a pitch-shifted sound effect and whether it's not
used on any other channel. If so, immediately free it.

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -350,6 +350,13 @@
     channels_playing[channel] = NULL;
 
     UnlockAllocatedSound(snd);
+
+    // if the sound is a pitch-shift and it's not in use, immediately
+    // free it
+    if(snd->pitch != NORM_PITCH && snd->use_count <= 0)
+    {
+        FreeAllocatedSound(snd);
+    }
 }
 
 #ifdef HAVE_LIBSAMPLERATE