diff options
author | Chris Robinson <[email protected]> | 2019-04-10 17:33:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-04-10 17:33:21 -0700 |
commit | 1d214dba1ebf92d4f3033ee831643424033fd0e8 (patch) | |
tree | 4906fe95b23f414e028eb602e63d47a381894aea /OpenAL32 | |
parent | b4a8615ea9308035262f565071ed37987411ff21 (diff) |
Add exception protection to effect, filter, and buffer functions
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.cpp | 59 | ||||
-rw-r--r-- | OpenAL32/alEffect.cpp | 24 | ||||
-rw-r--r-- | OpenAL32/alFilter.cpp | 23 |
3 files changed, 98 insertions, 8 deletions
diff --git a/OpenAL32/alBuffer.cpp b/OpenAL32/alBuffer.cpp index 68f0e40b..1dc37ec7 100644 --- a/OpenAL32/alBuffer.cpp +++ b/OpenAL32/alBuffer.cpp @@ -39,6 +39,7 @@ #include "alError.h" #include "alBuffer.h" #include "sample_cvt.h" +#include "alexcpt.h" namespace { @@ -417,6 +418,7 @@ DecompResult DecomposeUserFormat(ALenum format) AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -453,8 +455,10 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) std::copy(ids.begin(), ids.end(), buffers); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -502,8 +506,10 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) ); } } +END_API_FUNC AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) +START_API_FUNC { ContextRef context{GetContextRef()}; if(LIKELY(context)) @@ -515,12 +521,16 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) } return AL_FALSE; } +END_API_FUNC AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq) +START_API_FUNC { alBufferStorageSOFT(buffer, format, data, size, freq, 0); } +END_API_FUNC AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -554,8 +564,10 @@ AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const LoadData(context.get(), albuf, freq, size, srcchannels, srctype, data, flags); } } +END_API_FUNC AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return nullptr; @@ -604,8 +616,10 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei return nullptr; } +END_API_FUNC AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -625,8 +639,10 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer) albuf->MappedSize = 0; } } +END_API_FUNC AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -655,8 +671,10 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A std::atomic_thread_fence(std::memory_order_seq_cst); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -741,39 +759,47 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons } } } +END_API_FUNC AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint UNUSED(buffer), ALuint UNUSED(samplerate), ALenum UNUSED(internalformat), ALsizei UNUSED(samples), ALenum UNUSED(channels), ALenum UNUSED(type), const ALvoid *UNUSED(data)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; alSetError(context.get(), AL_INVALID_OPERATION, "alBufferSamplesSOFT not supported"); } +END_API_FUNC AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint UNUSED(buffer), ALsizei UNUSED(offset), ALsizei UNUSED(samples), ALenum UNUSED(channels), ALenum UNUSED(type), const ALvoid *UNUSED(data)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; alSetError(context.get(), AL_INVALID_OPERATION, "alBufferSubSamplesSOFT not supported"); } +END_API_FUNC AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint UNUSED(buffer), ALsizei UNUSED(offset), ALsizei UNUSED(samples), ALenum UNUSED(channels), ALenum UNUSED(type), ALvoid *UNUSED(data)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; alSetError(context.get(), AL_INVALID_OPERATION, "alGetBufferSamplesSOFT not supported"); } +END_API_FUNC AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum UNUSED(format)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(!context) return AL_FALSE; @@ -781,9 +807,11 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum UNUSED(format) alSetError(context.get(), AL_INVALID_OPERATION, "alIsBufferFormatSupportedSOFT not supported"); return AL_FALSE; } +END_API_FUNC AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat UNUSED(value)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -799,9 +827,10 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat UNUSED(va alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer float property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat UNUSED(value1), ALfloat UNUSED(value2), ALfloat UNUSED(value3)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -817,9 +846,10 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat UNUSED(v alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer 3-float property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -837,9 +867,11 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *v alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer float-vector property 0x%04x", param); } } +END_API_FUNC AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -870,9 +902,10 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value) alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer integer property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint UNUSED(value1), ALint UNUSED(value2), ALint UNUSED(value3)) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -888,9 +921,10 @@ AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint UNUSED(val alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer 3-integer property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values) +START_API_FUNC { if(values) { @@ -935,9 +969,11 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *val param); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -956,9 +992,10 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *val alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer float property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -976,9 +1013,10 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *valu alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer 3-float property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values) +START_API_FUNC { switch(param) { @@ -1003,9 +1041,11 @@ AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *valu alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer float-vector property 0x%04x", param); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -1047,9 +1087,10 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer integer property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -1066,9 +1107,10 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1 alSetError(context.get(), AL_INVALID_ENUM, "Invalid buffer 3-integer property 0x%04x", param); } } - +END_API_FUNC AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values) +START_API_FUNC { switch(param) { @@ -1107,6 +1149,7 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values param); } } +END_API_FUNC ALsizei BytesFromUserFmt(UserFmtType type) diff --git a/OpenAL32/alEffect.cpp b/OpenAL32/alEffect.cpp index 81ec26c6..36a09442 100644 --- a/OpenAL32/alEffect.cpp +++ b/OpenAL32/alEffect.cpp @@ -33,6 +33,8 @@ #include "alcontext.h" #include "alEffect.h" #include "alError.h" +#include "alexcpt.h" + #include "effects/base.h" @@ -202,6 +204,7 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) } // namespace AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -238,8 +241,10 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) std::copy(ids.begin(), ids.end(), effects); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -282,8 +287,10 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) ); } } +END_API_FUNC AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) +START_API_FUNC { ContextRef context{GetContextRef()}; if(LIKELY(context)) @@ -295,8 +302,10 @@ AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) } return AL_FALSE; } +END_API_FUNC AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -330,8 +339,10 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) } } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *values) +START_API_FUNC { switch(param) { @@ -355,8 +366,10 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *v ALeffect_setParamiv(aleffect, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -373,8 +386,10 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value) ALeffect_setParamf(aleffect, context.get(), param, value); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *values) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -391,8 +406,10 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat ALeffect_setParamfv(aleffect, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -414,8 +431,10 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value } } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *values) +START_API_FUNC { switch(param) { @@ -439,8 +458,10 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *valu ALeffect_getParamiv(aleffect, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -457,8 +478,10 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *val ALeffect_getParamf(aleffect, context.get(), param, value); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *values) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -475,6 +498,7 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *va ALeffect_getParamfv(aleffect, context.get(), param, values); } } +END_API_FUNC void InitEffect(ALeffect *effect) diff --git a/OpenAL32/alFilter.cpp b/OpenAL32/alFilter.cpp index 086f5289..cf393692 100644 --- a/OpenAL32/alFilter.cpp +++ b/OpenAL32/alFilter.cpp @@ -29,6 +29,7 @@ #include "alu.h" #include "alFilter.h" #include "alError.h" +#include "alexcpt.h" namespace { @@ -348,6 +349,7 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id) } // namespace AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -384,8 +386,10 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) std::copy(ids.begin(), ids.end(), filters); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -428,8 +432,10 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) ); } } +END_API_FUNC AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) +START_API_FUNC { ContextRef context{GetContextRef()}; if(LIKELY(context)) @@ -441,9 +447,11 @@ AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) } return AL_FALSE; } +END_API_FUNC AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -471,8 +479,10 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value) } } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *values) +START_API_FUNC { switch(param) { @@ -496,8 +506,10 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *v ALfilter_setParamiv(alfilt, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -514,8 +526,10 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value) ALfilter_setParamf(alfilt, context.get(), param, value); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *values) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -532,8 +546,10 @@ AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat ALfilter_setParamfv(alfilt, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -555,8 +571,10 @@ AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value } } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *values) +START_API_FUNC { switch(param) { @@ -580,8 +598,10 @@ AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *valu ALfilter_getParamiv(alfilt, context.get(), param, values); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *value) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -598,8 +618,10 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *val ALfilter_getParamf(alfilt, context.get(), param, value); } } +END_API_FUNC AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *values) +START_API_FUNC { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; @@ -616,6 +638,7 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *va ALfilter_getParamfv(alfilt, context.get(), param, values); } } +END_API_FUNC FilterSubList::~FilterSubList() |