aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-09-20 21:59:38 -0700
committerChris Robinson <[email protected]>2018-09-20 21:59:38 -0700
commitebbbeb0d660e442324c2b563c7b59e9f74ad15e9 (patch)
treefcddcd84260e58b2ba6c79762d92e286978b8dfc /Alc
parentcb8545346d227ba85a4a98c3897b5cdb1ea86d26 (diff)
Put user events in a union structure
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/ALu.c30
-rw-r--r--Alc/mixvoice.c11
3 files changed, 20 insertions, 23 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 89c0fc63..57ae4ace 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2680,7 +2680,7 @@ static ALvoid InitContext(ALCcontext *Context)
*/
static void FreeContext(ALCcontext *context)
{
- static const AsyncEvent kill_evt = { 0 };
+ static const AsyncEvent kill_evt = ASYNC_EVENT(EventType_KillThread);
ALlistener *listener = context->Listener;
struct ALeffectslotArray *auxslots;
struct ALeffectslotProps *eprops;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 2af32439..c8c583ef 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -211,32 +211,31 @@ void aluInit(void)
static void SendSourceStoppedEvent(ALCcontext *context, ALuint id)
{
+ AsyncEvent evt = ASYNC_EVENT(EventType_SourceStateChange);
ALbitfieldSOFT enabledevt;
- AsyncEvent evt;
size_t strpos;
ALuint scale;
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 = AL_STOPPED;
+ evt.u.user.type = AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT;
+ evt.u.user.id = id;
+ evt.u.user.param = AL_STOPPED;
/* Normally snprintf would be used, but this is called from the mixer and
* that function's not real-time safe, so we have to construct it manually.
*/
- strcpy(evt.Message, "Source ID "); strpos = 10;
+ strcpy(evt.u.user.msg, "Source ID "); strpos = 10;
scale = 1000000000;
while(scale > 0 && scale > id)
scale /= 10;
while(scale > 0)
{
- evt.Message[strpos++] = '0' + ((id/scale)%10);
+ evt.u.user.msg[strpos++] = '0' + ((id/scale)%10);
scale /= 10;
}
- strcpy(evt.Message+strpos, " state changed to AL_STOPPED");
+ strcpy(evt.u.user.msg+strpos, " state changed to AL_STOPPED");
if(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) == 1)
alsem_post(&context->EventSem);
@@ -1846,25 +1845,24 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
{
+ AsyncEvent evt = ASYNC_EVENT(EventType_Disconnected);
ALCcontext *ctx;
- AsyncEvent evt;
va_list args;
int msglen;
if(!ATOMIC_EXCHANGE(&device->Connected, AL_FALSE, almemory_order_acq_rel))
return;
- evt.EnumType = EventType_Disconnected;
- evt.Type = AL_EVENT_TYPE_DISCONNECTED_SOFT;
- evt.ObjectId = 0;
- evt.Param = 0;
+ evt.u.user.type = AL_EVENT_TYPE_DISCONNECTED_SOFT;
+ evt.u.user.id = 0;
+ evt.u.user.param = 0;
va_start(args, msg);
- msglen = vsnprintf(evt.Message, sizeof(evt.Message), msg, args);
+ msglen = vsnprintf(evt.u.user.msg, sizeof(evt.u.user.msg), msg, args);
va_end(args);
- if(msglen < 0 || (size_t)msglen >= sizeof(evt.Message))
- evt.Message[sizeof(evt.Message)-1] = 0;
+ if(msglen < 0 || (size_t)msglen >= sizeof(evt.u.user.msg))
+ evt.u.user.msg[sizeof(evt.u.user.msg)-1] = 0;
ctx = ATOMIC_LOAD_SEQ(&device->ContextList);
while(ctx)
diff --git a/Alc/mixvoice.c b/Alc/mixvoice.c
index a2365886..d019b898 100644
--- a/Alc/mixvoice.c
+++ b/Alc/mixvoice.c
@@ -197,12 +197,11 @@ void aluInitMixer(void)
static void SendAsyncEvent(ALCcontext *context, ALuint enumtype, ALenum type,
ALuint objid, ALuint param, const char *msg)
{
- AsyncEvent evt;
- evt.EnumType = enumtype;
- evt.Type = type;
- evt.ObjectId = objid;
- evt.Param = param;
- strcpy(evt.Message, msg);
+ AsyncEvent evt = ASYNC_EVENT(enumtype);
+ evt.u.user.type = type;
+ evt.u.user.id = objid;
+ evt.u.user.param = param;
+ strcpy(evt.u.user.msg, msg);
if(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) == 1)
alsem_post(&context->EventSem);
}