2018-01-23 18:25:59 -08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(count < 0) SETERR_GOTO(context, AL_INVALID_VALUE, 0, "Controlling negative events", done);
|
2018-01-23 18:25:59 -08:00
|
|
|
if(count == 0) goto done;
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!types) SETERR_GOTO(context, AL_INVALID_VALUE, 0, "NULL pointer", done);
|
2018-01-23 18:25:59 -08:00
|
|
|
|
|
|
|
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
|
2018-01-24 17:07:01 -08:00
|
|
|
SETERR_GOTO(context, AL_INVALID_ENUM, 0, "Invalid event type", done);
|
2018-01-23 18:25:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
almtx_lock(&context->EventLock);
|
|
|
|
if(enable)
|
|
|
|
context->EnabledEvts |= flags;
|
|
|
|
else
|
|
|
|
context->EnabledEvts &= ~flags;
|
|
|
|
almtx_unlock(&context->EventLock);
|
2018-01-24 17:07:01 -08:00
|
|
|
|
2018-01-23 18:25:59 -08:00
|
|
|
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);
|
|
|
|
}
|