diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2013-10-07 12:05:39 -0700 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2013-10-07 12:05:39 -0700 |
commit | b3841653c67276f23717b87b47899740ab0028f4 (patch) | |
tree | d219009aa448a78baaef9b952e0a53790ec944e9 /OpenAL32/alEffect.c | |
parent | 32d3bde261f461807d42d419ddba44b45798436b (diff) |
Remove the last of the al_try code
Diffstat (limited to 'OpenAL32/alEffect.c')
-rw-r--r-- | OpenAL32/alEffect.c | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index ca908a40..60f4fdfe 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -40,82 +40,79 @@ static void InitEffectParams(ALeffect *effect, ALenum type); AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) { - ALCcontext *Context; - ALsizei cur = 0; + ALCdevice *device; + ALCcontext *context; + ALsizei cur; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - ALenum err; + if(!(n >= 0)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); - CHECK_VALUE(Context, n >= 0); - for(cur = 0;cur < n;cur++) + device = context->Device; + for(cur = 0;cur < n;cur++) + { + ALeffect *effect = calloc(1, sizeof(ALeffect)); + ALenum err = AL_OUT_OF_MEMORY; + if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR) { - ALeffect *effect = calloc(1, sizeof(ALeffect)); - err = AL_OUT_OF_MEMORY; - if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR) - { - free(effect); - alDeleteEffects(cur, effects); - al_throwerr(Context, err); - } - - err = NewThunkEntry(&effect->id); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(effect->id); - memset(effect, 0, sizeof(ALeffect)); - free(effect); + free(effect); + alDeleteEffects(cur, effects); + SET_ERROR_AND_GOTO(context, err, done); + } - alDeleteEffects(cur, effects); - al_throwerr(Context, err); - } + err = NewThunkEntry(&effect->id); + if(err == AL_NO_ERROR) + err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect); + if(err != AL_NO_ERROR) + { + FreeThunkEntry(effect->id); + memset(effect, 0, sizeof(ALeffect)); + free(effect); - effects[cur] = effect->id; + alDeleteEffects(cur, effects); + SET_ERROR_AND_GOTO(context, err, done); } + + effects[cur] = effect->id; } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) { - ALCcontext *Context; - ALeffect *Effect; + ALCdevice *device; + ALCcontext *context; + ALeffect *effect; ALsizei i; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - CHECK_VALUE(Context, n >= 0); - for(i = 0;i < n;i++) - { - if(effects[i] && LookupEffect(device, effects[i]) == NULL) - al_throwerr(Context, AL_INVALID_NAME); - } + if(!(n >= 0)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); - for(i = 0;i < n;i++) - { - if((Effect=RemoveEffect(device, effects[i])) == NULL) - continue; - FreeThunkEntry(Effect->id); + device = context->Device; + for(i = 0;i < n;i++) + { + if(effects[i] && LookupEffect(device, effects[i]) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + } + for(i = 0;i < n;i++) + { + if((effect=RemoveEffect(device, effects[i])) == NULL) + continue; + FreeThunkEntry(effect->id); - memset(Effect, 0, sizeof(*Effect)); - free(Effect); - } + memset(effect, 0, sizeof(*effect)); + free(effect); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) |