diff options
author | Chris Robinson <[email protected]> | 2018-12-25 09:32:38 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-25 09:32:38 -0800 |
commit | 63df7cd537bd43fb2548a112b051a1790ff1140e (patch) | |
tree | 99cc9c4ef001c2b3731a4768a8983d7c6f25b47f /Alc/mixvoice.cpp | |
parent | 3b7f668b28dbc5ef156bad9aa79f16b32efb2eb3 (diff) |
Construct AsyncEvent objects directly in the ringbuffer
Diffstat (limited to 'Alc/mixvoice.cpp')
-rw-r--r-- | Alc/mixvoice.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index 680f4a31..f68c0f0a 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -721,11 +721,15 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize ALbitfieldSOFT enabledevt{Context->EnabledEvts.load(std::memory_order_acquire)}; if(buffers_done > 0 && (enabledevt&EventType_BufferCompleted)) { - AsyncEvent evt{EventType_BufferCompleted}; - evt.u.bufcomp.id = SourceID; - evt.u.bufcomp.count = buffers_done; - if(ll_ringbuffer_write(Context->AsyncEvents, &evt, 1) == 1) + auto evt_data = ll_ringbuffer_get_write_vector(Context->AsyncEvents).first; + if(evt_data.len > 0) + { + AsyncEvent *evt{new (evt_data.buf) AsyncEvent{EventType_BufferCompleted}}; + evt->u.bufcomp.id = SourceID; + evt->u.bufcomp.count = buffers_done; + ll_ringbuffer_write_advance(Context->AsyncEvents, 1); Context->EventSem.post(); + } } return isplaying; |