aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/event.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-30 21:39:59 -0800
committerChris Robinson <[email protected]>2018-11-30 21:39:59 -0800
commit7b1548af3cdda7f0023510a9ec12813a137a1668 (patch)
tree22339a93ca37352cdaebc5eda29e76c065ba2762 /OpenAL32/event.cpp
parent1e6e84374b9928b614e7f36a26499d806f3c89cc (diff)
Handle source state changed events uniquely in the event loop
To avoid the need of constructing the string in the mixer thread, which is commonly formatted anyway.
Diffstat (limited to 'OpenAL32/event.cpp')
-rw-r--r--OpenAL32/event.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp
index b7599a02..4980abee 100644
--- a/OpenAL32/event.cpp
+++ b/OpenAL32/event.cpp
@@ -39,7 +39,26 @@ static int EventThread(ALCcontext *context)
}
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_acquire)};
- if(context->EventCb && (enabledevts&evt.EnumType) == evt.EnumType)
+ if(!context->EventCb) continue;
+
+ if(evt.EnumType == EventType_SourceStateChange)
+ {
+ if(!(enabledevts&EventType_SourceStateChange))
+ continue;
+ char msg[1024]{};
+ int msglen{snprintf(msg, sizeof(msg), "Source ID %u state changed to %s",
+ evt.u.srcstate.id,
+ (evt.u.srcstate.state==AL_INITIAL) ? "AL_INITIAL" :
+ (evt.u.srcstate.state==AL_PLAYING) ? "AL_PLAYING" :
+ (evt.u.srcstate.state==AL_PAUSED) ? "AL_PAUSED" :
+ (evt.u.srcstate.state==AL_STOPPED) ? "AL_STOPPED" : "<unknown>"
+ )};
+ if(msglen < 1) msglen = strlen(msg);
+ context->EventCb(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, evt.u.srcstate.id,
+ evt.u.srcstate.state, msglen, msg, context->EventParam
+ );
+ }
+ else if((enabledevts&evt.EnumType) == evt.EnumType)
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
);