aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-10-07 12:05:39 -0700
committerChris Robinson <[email protected]>2013-10-07 12:05:39 -0700
commitb3841653c67276f23717b87b47899740ab0028f4 (patch)
treed219009aa448a78baaef9b952e0a53790ec944e9 /OpenAL32
parent32d3bde261f461807d42d419ddba44b45798436b (diff)
Remove the last of the al_try code
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h32
-rw-r--r--OpenAL32/alEffect.c109
-rw-r--r--OpenAL32/alExtension.c44
-rw-r--r--OpenAL32/alFilter.c110
4 files changed, 128 insertions, 167 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 535975f3..47f1934c 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -911,38 +911,6 @@ void FillCPUCaps(ALuint capfilter);
goto lbl; \
} while(0)
-/**
- * Starts a try block. Must not be nested within another try block within the
- * same function.
- */
-#define al_try do { \
- int _al_in_try_block = 1;
-/** Marks the end of the try block. */
-#define al_endtry _al_endtry_label: \
- (void)_al_in_try_block; \
-} while(0)
-
-/**
- * The try block is terminated, and execution jumps to al_endtry.
- */
-#define al_throw do { \
- _al_in_try_block = 0; \
- goto _al_endtry_label; \
-} while(0)
-/** Sets an AL error on the given context, before throwing. */
-#define al_throwerr(ctx, err) do { \
- alSetError((ctx), (err)); \
- al_throw; \
-} while(0)
-
-/**
- * Throws an AL_INVALID_VALUE error with the given ctx if the given condition
- * is false.
- */
-#define CHECK_VALUE(ctx, cond) do { \
- if(!(cond)) \
- al_throwerr((ctx), AL_INVALID_VALUE); \
-} while(0)
#ifdef __cplusplus
}
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)
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index 785f172e..fc23a932 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -55,38 +55,36 @@ const struct EffectList EffectList[] = {
AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
{
ALboolean ret = AL_FALSE;
- ALCcontext *Context;
+ ALCcontext *context;
const char *ptr;
size_t len;
- Context = GetContextRef();
- if(!Context) return AL_FALSE;
+ context = GetContextRef();
+ if(!context) return AL_FALSE;
- al_try
- {
- CHECK_VALUE(Context, extName);
+ if(!(extName))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
- len = strlen(extName);
- ptr = Context->ExtensionList;
- while(ptr && *ptr)
+ len = strlen(extName);
+ ptr = context->ExtensionList;
+ while(ptr && *ptr)
+ {
+ if(strncasecmp(ptr, extName, len) == 0 &&
+ (ptr[len] == '\0' || isspace(ptr[len])))
+ {
+ ret = AL_TRUE;
+ break;
+ }
+ if((ptr=strchr(ptr, ' ')) != NULL)
{
- if(strncasecmp(ptr, extName, len) == 0 &&
- (ptr[len] == '\0' || isspace(ptr[len])))
- {
- ret = AL_TRUE;
- break;
- }
- if((ptr=strchr(ptr, ' ')) != NULL)
- {
- do {
- ++ptr;
- } while(isspace(*ptr));
- }
+ do {
+ ++ptr;
+ } while(isspace(*ptr));
}
}
- al_endtry;
- ALCcontext_DecRef(Context);
+done:
+ ALCcontext_DecRef(context);
return ret;
}
diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c
index c8ac7dd3..026a5814 100644
--- a/OpenAL32/alFilter.c
+++ b/OpenAL32/alFilter.c
@@ -34,81 +34,79 @@ static void InitFilterParams(ALfilter *filter, ALenum type);
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
- ALCcontext *Context;
- ALsizei cur = 0;
+ ALCdevice *device;
+ ALCcontext *context;
+ ALsizei cur = 0;
+ ALenum err;
- Context = GetContextRef();
- if(!Context) return;
+ context = GetContextRef();
+ if(!context) return;
- al_try
+ if(!(n >= 0))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+
+ device = context->Device;
+ for(cur = 0;cur < n;cur++)
{
- ALCdevice *device = Context->Device;
- ALenum err;
+ ALfilter *filter = calloc(1, sizeof(ALfilter));
+ if(!filter)
+ {
+ alDeleteFilters(cur, filters);
+ SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
+ }
+ InitFilterParams(filter, AL_FILTER_NULL);
- CHECK_VALUE(Context, n >= 0);
- for(cur = 0;cur < n;cur++)
+ err = NewThunkEntry(&filter->id);
+ if(err == AL_NO_ERROR)
+ err = InsertUIntMapEntry(&device->FilterMap, filter->id, filter);
+ if(err != AL_NO_ERROR)
{
- ALfilter *filter = calloc(1, sizeof(ALfilter));
- if(!filter)
- {
- alDeleteFilters(cur, filters);
- al_throwerr(Context, AL_OUT_OF_MEMORY);
- }
- InitFilterParams(filter, AL_FILTER_NULL);
-
- err = NewThunkEntry(&filter->id);
- if(err == AL_NO_ERROR)
- err = InsertUIntMapEntry(&device->FilterMap, filter->id, filter);
- if(err != AL_NO_ERROR)
- {
- FreeThunkEntry(filter->id);
- memset(filter, 0, sizeof(ALfilter));
- free(filter);
-
- alDeleteFilters(cur, filters);
- al_throwerr(Context, err);
- }
-
- filters[cur] = filter->id;
+ FreeThunkEntry(filter->id);
+ memset(filter, 0, sizeof(ALfilter));
+ free(filter);
+
+ alDeleteFilters(cur, filters);
+ SET_ERROR_AND_GOTO(context, err, done);
}
+
+ filters[cur] = filter->id;
}
- al_endtry;
- ALCcontext_DecRef(Context);
+done:
+ ALCcontext_DecRef(context);
}
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
{
- ALCcontext *Context;
- ALfilter *Filter;
+ ALCdevice *device;
+ ALCcontext *context;
+ ALfilter *filter;
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(filters[i] && LookupFilter(device, filters[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((Filter=RemoveFilter(device, filters[i])) == NULL)
- continue;
- FreeThunkEntry(Filter->id);
+ device = context->Device;
+ for(i = 0;i < n;i++)
+ {
+ if(filters[i] && LookupFilter(device, filters[i]) == NULL)
+ SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ }
+ for(i = 0;i < n;i++)
+ {
+ if((filter=RemoveFilter(device, filters[i])) == NULL)
+ continue;
+ FreeThunkEntry(filter->id);
- memset(Filter, 0, sizeof(*Filter));
- free(Filter);
- }
+ memset(filter, 0, sizeof(*filter));
+ free(filter);
}
- al_endtry;
- ALCcontext_DecRef(Context);
+done:
+ ALCcontext_DecRef(context);
}
AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)