commit d811a1bec4ec09153ee6fcf376e2a10ca3a274a2
Author: Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Mon Jul 6 20:00:09 2015 +0100
Commit: Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Wed Jul 8 21:02:01 2015 +0100
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.
---
src/i_sdlsound.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 142b5b0a..12476b4f 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -350,6 +350,13 @@ static void ReleaseSoundOnChannel(int channel)
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