From cafbd9461e869d7915268c7c6adf14314bc80138 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 24 Apr 2012 23:06:10 -0700 Subject: [PATCH] Fix up alEffect.c and alFilter.c a bit --- OpenAL32/alEffect.c | 66 ++++++++++++++++++++++++++++++--------------------- OpenAL32/alFilter.c | 68 ++++++++++++++++++++++++----------------------------- 2 files changed, 70 insertions(+), 64 deletions(-) diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index 974d2657..a2fbbc5f 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -154,7 +154,9 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { if(param == AL_EFFECT_TYPE) { @@ -178,8 +180,6 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) ALeffect_SetParami(ALEffect, Context, param, value); } } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -190,17 +190,24 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *v ALCdevice *Device; ALeffect *ALEffect; + switch(param) + { + case AL_EFFECT_TYPE: + alEffecti(effect, param, values[0]); + return; + } + Context = GetContextRef(); if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_SetParamiv(ALEffect, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -215,13 +222,13 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value) if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_SetParamf(ALEffect, Context, param, value); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -236,13 +243,13 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_SetParamfv(ALEffect, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -257,20 +264,18 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { if(param == AL_EFFECT_TYPE) - { *value = ALEffect->type; - } else { /* Call the appropriate handler */ - ALeffect_GetParamiv(ALEffect, Context, param, value); + ALeffect_GetParami(ALEffect, Context, param, value); } } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -281,17 +286,24 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *valu ALCdevice *Device; ALeffect *ALEffect; + switch(param) + { + case AL_EFFECT_TYPE: + alGetEffecti(effect, param, values); + return; + } + Context = GetContextRef(); if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_GetParamiv(ALEffect, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -306,13 +318,13 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *val if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_GetParamf(ALEffect, Context, param, value); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -327,13 +339,13 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *va if(!Context) return; Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) + if((ALEffect=LookupEffect(Device, effect)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALeffect_GetParamfv(ALEffect, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 31a62e52..d3abb7b3 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -150,25 +150,23 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value) if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { - switch(param) + if(param == AL_FILTER_TYPE) { - case AL_FILTER_TYPE: if(value == AL_FILTER_NULL || value == AL_FILTER_LOWPASS) InitFilterParams(ALFilter, value); else alSetError(Context, AL_INVALID_VALUE); - break; - - default: + } + else + { /* Call the appropriate handler */ ALfilter_SetParami(ALFilter, Context, param, value); - break; } } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -190,13 +188,13 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *v if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_SetParamiv(ALFilter, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -211,13 +209,13 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value) if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_SetParamf(ALFilter, Context, param, value); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -232,13 +230,13 @@ AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_SetParamfv(ALFilter, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -253,22 +251,18 @@ AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { - switch(param) - { - case AL_FILTER_TYPE: + if(param == AL_FILTER_TYPE) *value = ALFilter->type; - break; - - default: + else + { /* Call the appropriate handler */ ALfilter_GetParami(ALFilter, Context, param, value); - break; } } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -290,13 +284,13 @@ AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *valu if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_GetParamiv(ALFilter, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -311,13 +305,13 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *val if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_GetParamf(ALFilter, Context, param, value); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } @@ -332,13 +326,13 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *va if(!Context) return; Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) + if((ALFilter=LookupFilter(Device, filter)) == NULL) + alSetError(Context, AL_INVALID_NAME); + else { /* Call the appropriate handler */ ALfilter_GetParamfv(ALFilter, Context, param, values); } - else - alSetError(Context, AL_INVALID_NAME); ALCcontext_DecRef(Context); } -- 2.11.4.GIT