diff options
author | Chris Robinson <[email protected]> | 2018-11-30 21:39:59 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-30 21:39:59 -0800 |
commit | 7b1548af3cdda7f0023510a9ec12813a137a1668 (patch) | |
tree | 22339a93ca37352cdaebc5eda29e76c065ba2762 /Alc | |
parent | 1e6e84374b9928b614e7f36a26499d806f3c89cc (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 'Alc')
-rw-r--r-- | Alc/alu.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index b9fe95f0..197d554d 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -287,31 +287,12 @@ aluVector aluMatrixfVector(const aluMatrixf *mtx, const aluVector *vec) void SendSourceStoppedEvent(ALCcontext *context, ALuint id) { - AsyncEvent evt = ASYNC_EVENT(EventType_SourceStateChange); - ALbitfieldSOFT enabledevt; - size_t strpos; - ALuint scale; - - enabledevt = context->EnabledEvts.load(std::memory_order_acquire); + ALbitfieldSOFT enabledevt{context->EnabledEvts.load(std::memory_order_acquire)}; if(!(enabledevt&EventType_SourceStateChange)) return; - 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.u.user.msg, "Source ID "); strpos = 10; - scale = 1000000000; - while(scale > 0 && scale > id) - scale /= 10; - while(scale > 0) - { - evt.u.user.msg[strpos++] = '0' + ((id/scale)%10); - scale /= 10; - } - strcpy(evt.u.user.msg+strpos, " state changed to AL_STOPPED"); + AsyncEvent evt{ASYNC_EVENT(EventType_SourceStateChange)}; + evt.u.srcstate.id = id; + evt.u.srcstate.state = AL_STOPPED; if(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) == 1) context->EventSem.post(); |