Skip to content
Permalink
Browse files

On shutdown, deallocate global memory we might have allocated for eff…

…ects.

  Partially fixes Bugzilla #385.
  • Loading branch information
icculus committed Jul 15, 2007
1 parent 3e0ba04 commit 2665f69cb0fbc1959a66736a45b2f3d6d6b57a0a
Showing with 28 additions and 2 deletions.
  1. +14 −0 effect_position.c
  2. +8 −0 effects_internal.c
  3. +2 −0 effects_internal.h
  4. +4 −2 mixer.c
@@ -79,6 +79,20 @@ static position_args **pos_args_array = NULL;
static position_args *pos_args_global = NULL;
static int position_channels = 0;

void _Eff_PositionDeinit(void)
{
int i;
for (i = 0; i < position_channels; i++) {
free(pos_args_array[i]);
}

free(pos_args_global);
pos_args_global = NULL;
free(pos_args_array);
pos_args_array = NULL;
}


/* This just frees up the callback-specific data. */
static void _Eff_PositionDone(int channel, void *udata)
{
@@ -32,6 +32,9 @@
#include <stdlib.h>
#include "SDL_mixer.h"

#define __MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* Should we favor speed over memory usage and/or quality of output? */
int _Mix_effects_max_speed = 0;

@@ -41,6 +44,11 @@ void _Mix_InitEffects(void)
_Mix_effects_max_speed = (getenv(MIX_EFFECTSMAXSPEED) != NULL);
}

void _Mix_DeinitEffects(void)
{
_Eff_PositionDeinit();
}


void *_Eff_volume_table = NULL;

@@ -41,6 +41,8 @@ extern void *_Eff_volume_table;
void *_Eff_build_volume_table_u8(void);
void *_Eff_build_volume_table_s8(void);

void _Eff_PositionDeinit(void);

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
}
@@ -35,6 +35,9 @@
#include "load_voc.h"
#include "load_ogg.h"

#define __MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* Magic numbers for various audio file formats */
#define RIFF 0x46464952 /* "RIFF" */
#define WAVE 0x45564157 /* "WAVE" */
@@ -266,8 +269,6 @@ static void PrintFormat(char *title, SDL_AudioSpec *fmt)
}


void _Mix_InitEffects(void);

/* Open the mixer with a certain desired audio format */
int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
{
@@ -960,6 +961,7 @@ void Mix_CloseAudio(void)
Mix_UnregisterAllEffects(MIX_CHANNEL_POST);
close_music();
Mix_HaltChannel(-1);
_Eff_PositionDeinit();
SDL_CloseAudio();
free(mix_channel);
mix_channel = NULL;

0 comments on commit 2665f69

Please sign in to comment.