aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h18
-rw-r--r--OpenAL32/alSource.c11
-rw-r--r--OpenAL32/event.c7
3 files changed, 23 insertions, 13 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index f1bc4469..86ac49dc 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -750,6 +750,10 @@ struct ALCdevice_struct {
enum {
+ /* End event thread processing. */
+ EventType_KillThread = 0,
+
+ /* User event types. */
EventType_SourceStateChange = 1<<0,
EventType_BufferCompleted = 1<<1,
EventType_Error = 1<<2,
@@ -760,11 +764,17 @@ enum {
typedef struct AsyncEvent {
unsigned int EnumType;
- ALenum Type;
- ALuint ObjectId;
- ALuint Param;
- ALchar Message[1008];
+ union {
+ char dummy;
+ struct {
+ ALenum type;
+ ALuint id;
+ ALuint param;
+ ALchar msg[1008];
+ } user;
+ } u;
} AsyncEvent;
+#define ASYNC_EVENT(t) { t, { 0 } }
struct ALCcontext_struct {
RefCount ref;
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 5ce439c7..81d8c262 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -229,17 +229,16 @@ static inline bool SourceShouldUpdate(ALsource *source, ALCcontext *context)
/** Can only be called while the mixer is locked! */
static void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state)
{
+ AsyncEvent evt = ASYNC_EVENT(EventType_SourceStateChange);
ALbitfieldSOFT enabledevt;
- AsyncEvent evt;
enabledevt = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_acquire);
if(!(enabledevt&EventType_SourceStateChange)) return;
- evt.EnumType = EventType_SourceStateChange;
- evt.Type = AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT;
- evt.ObjectId = id;
- evt.Param = state;
- snprintf(evt.Message, sizeof(evt.Message), "Source ID %u state changed to %s", id,
+ evt.u.user.type = AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT;
+ evt.u.user.id = id;
+ evt.u.user.param = state;
+ snprintf(evt.u.user.msg, sizeof(evt.u.user.msg), "Source ID %u state changed to %s", id,
(state==AL_INITIAL) ? "AL_INITIAL" :
(state==AL_PLAYING) ? "AL_PLAYING" :
(state==AL_PAUSED) ? "AL_PAUSED" :
diff --git a/OpenAL32/event.c b/OpenAL32/event.c
index b719c371..a76746bd 100644
--- a/OpenAL32/event.c
+++ b/OpenAL32/event.c
@@ -27,13 +27,14 @@ int EventThread(void *arg)
almtx_lock(&context->EventCbLock);
do {
- quitnow = !evt.EnumType;
+ quitnow = evt.EnumType == EventType_KillThread;
if(quitnow) break;
enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_acquire);
if(context->EventCb && (enabledevts&evt.EnumType) == evt.EnumType)
- context->EventCb(evt.Type, evt.ObjectId, evt.Param, (ALsizei)strlen(evt.Message),
- evt.Message, context->EventParam);
+ context->EventCb(evt.u.user.type, evt.u.user.id, evt.u.user.param,
+ (ALsizei)strlen(evt.u.user.msg), evt.u.user.msg, context->EventParam
+ );
} while(ll_ringbuffer_read(context->AsyncEvents, (char*)&evt, 1) != 0);
almtx_unlock(&context->EventCbLock);
}