From b8ef711ba3c6d057269f19fca1322d97d1641a60 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 16 Jan 2010 17:47:26 +0000 Subject: [PATCH] (svn r18829) -Codechange: Don't free memory from within audio mixer callback handler as it may be required to be real-time safe. --- src/mixer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mixer.cpp b/src/mixer.cpp index 7a94f6edaa..30f788aec8 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -141,9 +141,7 @@ static void mix_int8_to_int16(MixerChannel *sc, int16 *buffer, uint samples) static void MxCloseChannel(MixerChannel *mc) { - free(mc->memory); mc->active = false; - mc->memory = NULL; } void MxMixSamples(void *buffer, uint samples) @@ -170,8 +168,9 @@ MixerChannel *MxAllocateChannel() { MixerChannel *mc; for (mc = _channels; mc != endof(_channels); mc++) - if (mc->memory == NULL) { - mc->active = false; + if (!mc->active) { + free(mc->memory); + mc->memory = NULL; return mc; } return NULL;