mixer.c
changeset 442 884a700fb3ff
parent 412 4c1f81481f87
child 443 d842a759e68a
     1.1 --- a/mixer.c	Sat Oct 10 17:05:45 2009 +0000
     1.2 +++ b/mixer.c	Sun Oct 11 02:59:12 2009 +0000
     1.3 @@ -1276,11 +1276,11 @@
     1.4  }
     1.5  
     1.6  
     1.7 -int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f,
     1.8 +/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */
     1.9 +int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
    1.10  			Mix_EffectDone_t d, void *arg)
    1.11  {
    1.12  	effect_info **e = NULL;
    1.13 -	int retval;
    1.14  
    1.15  	if (channel == MIX_CHANNEL_POST) {
    1.16  		e = &posteffects;
    1.17 @@ -1292,17 +1292,24 @@
    1.18  		e = &mix_channel[channel].effects;
    1.19  	}
    1.20  
    1.21 -	SDL_LockAudio();
    1.22 -	retval = _Mix_register_effect(e, f, d, arg);
    1.23 -	SDL_UnlockAudio();
    1.24 -	return(retval);
    1.25 +	return _Mix_register_effect(e, f, d, arg);
    1.26  }
    1.27  
    1.28 +int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f,
    1.29 +			Mix_EffectDone_t d, void *arg)
    1.30 +{
    1.31 +    int retval;
    1.32 +	SDL_LockAudio();
    1.33 +	retval = _Mix_RegisterEffect_locked(channel, f, d, arg);
    1.34 +	SDL_UnlockAudio();
    1.35 +    return retval;
    1.36 +}
    1.37  
    1.38 -int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
    1.39 +
    1.40 +/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */
    1.41 +int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f)
    1.42  {
    1.43  	effect_info **e = NULL;
    1.44 -	int retval;
    1.45  
    1.46  	if (channel == MIX_CHANNEL_POST) {
    1.47  		e = &posteffects;
    1.48 @@ -1314,17 +1321,22 @@
    1.49  		e = &mix_channel[channel].effects;
    1.50  	}
    1.51  
    1.52 +	return _Mix_remove_effect(channel, e, f);
    1.53 +}
    1.54 +
    1.55 +int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
    1.56 +{
    1.57 +	int retval;
    1.58  	SDL_LockAudio();
    1.59 -	retval = _Mix_remove_effect(channel, e, f);
    1.60 +	retval = _Mix_UnregisterEffect_locked(channel, f);
    1.61  	SDL_UnlockAudio();
    1.62  	return(retval);
    1.63  }
    1.64  
    1.65 -
    1.66 -int Mix_UnregisterAllEffects(int channel)
    1.67 +/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */
    1.68 +int _Mix_UnregisterAllEffects_locked(int channel)
    1.69  {
    1.70  	effect_info **e = NULL;
    1.71 -	int retval;
    1.72  
    1.73  	if (channel == MIX_CHANNEL_POST) {
    1.74  		e = &posteffects;
    1.75 @@ -1336,8 +1348,14 @@
    1.76  		e = &mix_channel[channel].effects;
    1.77  	}
    1.78  
    1.79 +	return _Mix_remove_all_effects(channel, e);
    1.80 +}
    1.81 +
    1.82 +int Mix_UnregisterAllEffects(int channel)
    1.83 +{
    1.84 +	int retval;
    1.85  	SDL_LockAudio();
    1.86 -	retval = _Mix_remove_all_effects(channel, e);
    1.87 +	retval = _Mix_UnregisterAllEffects_locked(channel);
    1.88  	SDL_UnlockAudio();
    1.89  	return(retval);
    1.90  }