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/event.c | |
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/event.c')
-rw-r--r-- | OpenAL32/event.c | 65 |
1 files changed, 65 insertions, 0 deletions
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); +} |