diff options
author | Chris Robinson <[email protected]> | 2018-01-23 18:25:59 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-23 18:25:59 -0800 |
commit | caa3b4f7f833278498a78f261e8badb85fd2896b (patch) | |
tree | 8f733392944198cb06e17aad5b9db67b79fc4d64 /OpenAL32 | |
parent | 2266a9e01ef68f112e87eb49bf1621a6456531a9 (diff) |
Handle event properties
This just implements the event methods insofar as tracked state. No events are
generated/reported yet.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 16 | ||||
-rw-r--r-- | OpenAL32/alState.c | 58 | ||||
-rw-r--r-- | OpenAL32/event.c | 65 |
3 files changed, 137 insertions, 2 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 4b0f3b81..438f7ed5 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -80,12 +80,12 @@ typedef void (AL_APIENTRY*ALEVENTPROCSOFT)(ALenum eventType, ALuint object, ALui typedef void (AL_APIENTRY*LPALEVENTCONTROLSOFT)(ALsizei count, const ALenum *types, ALboolean enable); typedef void (AL_APIENTRY*LPALEVENTCALLBACKSOFT)(ALEVENTPROCSOFT callback, void *userParam); typedef void* (AL_APIENTRY*LPALGETPOINTERSOFT)(ALenum pname); -typedef void (AL_APIENTRY*LPALGETPOINTERVSOFT)(ALenum pname, void **params); +typedef void (AL_APIENTRY*LPALGETPOINTERVSOFT)(ALenum pname, void **values); #ifdef AL_ALEXT_PROTOTYPES AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, ALboolean enable); AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *userParam); AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname); -AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **params); +AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **values); #endif #endif @@ -565,6 +565,13 @@ struct ALCdevice_struct #define RECORD_THREAD_NAME "alsoft-record" +enum { + EventType_SourceStateChange = 1<<0, + EventType_BufferCompleted = 1<<1, + EventType_Error = 1<<2, + EventType_Performance = 1<<3, +}; + struct ALCcontext_struct { RefCount ref; @@ -612,6 +619,11 @@ struct ALCcontext_struct { ATOMIC(struct ALeffectslotArray*) ActiveAuxSlots; + almtx_t EventLock; + ALbitfieldSOFT EnabledEvts; + ALEVENTPROCSOFT EventCb; + void *EventParam; + /* Default effect slot */ struct ALeffectslot *DefaultSlot; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index c8c81065..36afd46e 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -415,6 +415,64 @@ done: return value; } +AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname) +{ + ALCcontext *context; + void *value = NULL; + + context = GetContextRef(); + if(!context) return NULL; + + switch(pname) + { + case AL_EVENT_CALLBACK_FUNCTION_SOFT: + value = context->EventCb; + break; + + case AL_EVENT_CALLBACK_USER_PARAM_SOFT: + value = context->EventParam; + break; + + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); + + return value; +} + +AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **values) +{ + ALCcontext *context; + + if(values) + { + switch(pname) + { + case AL_EVENT_CALLBACK_FUNCTION_SOFT: + case AL_EVENT_CALLBACK_USER_PARAM_SOFT: + values[0] = alGetPointerSOFT(pname); + return; + } + } + + context = GetContextRef(); + if(!context) return; + + if(!(values)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + switch(pname) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); +} + AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname, ALboolean *values) { ALCcontext *context; diff --git a/OpenAL32/event.c b/OpenAL32/event.c new file mode 100644 index 00000000..4e844ce9 --- /dev/null +++ b/OpenAL32/event.c @@ -0,0 +1,65 @@ + +#include "config.h" + +#include "AL/alc.h" +#include "AL/al.h" +#include "AL/alext.h" +#include "alMain.h" +#include "alError.h" + + +AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, ALboolean enable) +{ + ALCcontext *context; + ALbitfieldSOFT flags = 0; + ALsizei i; + + context = GetContextRef(); + if(!context) return; + + if(count < 0) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + if(count == 0) goto done; + if(!types) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + + for(i = 0;i < count;i++) + { + if(types[i] == AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT) + flags |= EventType_BufferCompleted; + else if(types[i] == AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT) + flags |= EventType_SourceStateChange; + else if(types[i] == AL_EVENT_TYPE_ERROR_SOFT) + flags |= EventType_Error; + else if(types[i] == AL_EVENT_TYPE_PERFORMANCE_SOFT) + flags |= EventType_Performance; + else + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + + almtx_lock(&context->EventLock); + + if(enable) + context->EnabledEvts |= flags; + else + context->EnabledEvts &= ~flags; + + almtx_unlock(&context->EventLock); +done: + ALCcontext_DecRef(context); +} + +AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *userParam) +{ + ALCcontext *context; + + context = GetContextRef(); + if(!context) return; + + almtx_lock(&context->EventLock); + context->EventCb = callback; + context->EventParam = userParam; + almtx_unlock(&context->EventLock); + + ALCcontext_DecRef(context); +} |