diff options
author | Chris Robinson <[email protected]> | 2013-10-07 07:06:01 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-10-07 07:06:01 -0700 |
commit | e1d5be570e860b80db655ebeb8bb01e8eb13aaef (patch) | |
tree | 0fa8cb0f03af472df32ca1b2d2dc01f35ca46c85 /OpenAL32 | |
parent | b5fece03812dfe8edc1d3a613f3328a2df34f4cd (diff) |
Remove al_try usage from alBuffer.c
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 476 |
1 files changed, 230 insertions, 246 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index bac528fb..02c20fb4 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -604,253 +604,242 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format) AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; (void)value; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; (void)value1; (void)value2; (void)value3; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, values); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + if(!(values)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; (void)value; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; (void)value1; (void)value2; (void)value3; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - al_try + switch(param) { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); - - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values) { - ALCcontext *Context; - ALbuffer *ALBuf; + ALCdevice *device; + ALCcontext *context; + ALbuffer *albuf; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if((albuf=LookupBuffer(device, buffer)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, values); - switch(param) + if(!(values)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + case AL_LOOP_POINTS_SOFT: + WriteLock(&albuf->lock); + if(albuf->ref != 0) { - case AL_LOOP_POINTS_SOFT: - WriteLock(&ALBuf->lock); - if(ALBuf->ref != 0) - { - WriteUnlock(&ALBuf->lock); - al_throwerr(Context, AL_INVALID_OPERATION); - } - if(values[0] >= values[1] || values[0] < 0 || - values[1] > ALBuf->SampleLen) - { - WriteUnlock(&ALBuf->lock); - al_throwerr(Context, AL_INVALID_VALUE); - } + WriteUnlock(&albuf->lock); + SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); + } + if(values[0] >= values[1] || values[0] < 0 || + values[1] > albuf->SampleLen) + { + WriteUnlock(&albuf->lock); + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + } - ALBuf->LoopStart = values[0]; - ALBuf->LoopEnd = values[1]; - WriteUnlock(&ALBuf->lock); - break; + albuf->LoopStart = values[0]; + albuf->LoopEnd = values[1]; + WriteUnlock(&albuf->lock); + break; - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value) { - ALCcontext *Context; - ALbuffer *Buffer; + ALCdevice *device; + ALCcontext *context; + ALbuffer *albuf; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if((Buffer=LookupBuffer(device, buffer)) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if((albuf=LookupBuffer(device, buffer)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, value); - switch(param) - { - case AL_SEC_LENGTH_SOFT: - ReadLock(&Buffer->lock); - if(Buffer->SampleLen != 0) - *value = Buffer->SampleLen / (ALfloat)Buffer->Frequency; - else - *value = 0.0f; - ReadUnlock(&Buffer->lock); - break; + if(!(value)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + case AL_SEC_LENGTH_SOFT: + ReadLock(&albuf->lock); + if(albuf->SampleLen != 0) + *value = albuf->SampleLen / (ALfloat)albuf->Frequency; + else + *value = 0.0f; + ReadUnlock(&albuf->lock); + break; - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, value1 && value2 && value3); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + if(!(value1 && value2 && value3)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; switch(param) { @@ -859,116 +848,113 @@ AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *valu return; } - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, values); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + if(!(values)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value) { - ALCcontext *Context; - ALbuffer *Buffer; + ALCdevice *device; + ALCcontext *context; + ALbuffer *albuf; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if((Buffer=LookupBuffer(device, buffer)) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if((albuf=LookupBuffer(device, buffer)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, value); - switch(param) - { - case AL_FREQUENCY: - *value = Buffer->Frequency; - break; + if(!(value)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + case AL_FREQUENCY: + *value = albuf->Frequency; + break; - case AL_BITS: - *value = BytesFromFmt(Buffer->FmtType) * 8; - break; + case AL_BITS: + *value = BytesFromFmt(albuf->FmtType) * 8; + break; - case AL_CHANNELS: - *value = ChannelsFromFmt(Buffer->FmtChannels); - break; + case AL_CHANNELS: + *value = ChannelsFromFmt(albuf->FmtChannels); + break; - case AL_SIZE: - ReadLock(&Buffer->lock); - *value = Buffer->SampleLen * FrameSizeFromFmt(Buffer->FmtChannels, - Buffer->FmtType); - ReadUnlock(&Buffer->lock); - break; + case AL_SIZE: + ReadLock(&albuf->lock); + *value = albuf->SampleLen * FrameSizeFromFmt(albuf->FmtChannels, + albuf->FmtType); + ReadUnlock(&albuf->lock); + break; - case AL_INTERNAL_FORMAT_SOFT: - *value = Buffer->Format; - break; + case AL_INTERNAL_FORMAT_SOFT: + *value = albuf->Format; + break; - case AL_BYTE_LENGTH_SOFT: - *value = Buffer->OriginalSize; - break; + case AL_BYTE_LENGTH_SOFT: + *value = albuf->OriginalSize; + break; - case AL_SAMPLE_LENGTH_SOFT: - *value = Buffer->SampleLen; - break; + case AL_SAMPLE_LENGTH_SOFT: + *value = albuf->SampleLen; + break; - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) { - ALCcontext *Context; + ALCdevice *device; + ALCcontext *context; - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if(LookupBuffer(device, buffer) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if(LookupBuffer(device, buffer) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, value1 && value2 && value3); - switch(param) - { - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + if(!(value1 && value2 && value3)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values) { - ALCcontext *Context; - ALbuffer *ALBuf; + ALCdevice *device; + ALCcontext *context; + ALbuffer *albuf; switch(param) { @@ -983,32 +969,30 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values return; } - Context = GetContextRef(); - if(!Context) return; + context = GetContextRef(); + if(!context) return; - al_try - { - ALCdevice *device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - al_throwerr(Context, AL_INVALID_NAME); + device = context->Device; + if((albuf=LookupBuffer(device, buffer)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); - CHECK_VALUE(Context, values); - switch(param) - { - case AL_LOOP_POINTS_SOFT: - ReadLock(&ALBuf->lock); - values[0] = ALBuf->LoopStart; - values[1] = ALBuf->LoopEnd; - ReadUnlock(&ALBuf->lock); - break; + if(!(values)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(param) + { + case AL_LOOP_POINTS_SOFT: + ReadLock(&albuf->lock); + values[0] = albuf->LoopStart; + values[1] = albuf->LoopEnd; + ReadUnlock(&albuf->lock); + break; - default: - al_throwerr(Context, AL_INVALID_ENUM); - } + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - al_endtry; - ALCcontext_DecRef(Context); +done: + ALCcontext_DecRef(context); } |