From 63df7cd537bd43fb2548a112b051a1790ff1140e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 25 Dec 2018 09:32:38 -0800 Subject: Construct AsyncEvent objects directly in the ringbuffer --- Alc/mixvoice.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Alc/mixvoice.cpp') 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; -- cgit v1.2.3