diff options
author | Chris Robinson <[email protected]> | 2023-05-08 20:01:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-08 20:01:14 -0700 |
commit | d2b000c7602bcc337a4f4e5590ef65c1cfcb4cb2 (patch) | |
tree | 8caeb4a6d06f8d017bd3c2c0e286e6d8cab1fa23 /core/voice.cpp | |
parent | e1e375e5238282c36ab7dddf148461c4370de39d (diff) |
Use a variant for AsyncEvent
Diffstat (limited to 'core/voice.cpp')
-rw-r--r-- | core/voice.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/voice.cpp b/core/voice.cpp index 478ea81f..3e78b176 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -226,10 +226,10 @@ void SendSourceStoppedEvent(ContextBase *context, uint id) auto evt_vec = ring->getWriteVector(); if(evt_vec.first.len < 1) return; - AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), - AsyncEvent::SourceStateChange)}; - evt->u.srcstate.id = id; - evt->u.srcstate.state = AsyncEvent::SrcState::Stop; + AsyncSourceStateEvent &evt = InitAsyncEvent<AsyncSourceStateEvent>( + reinterpret_cast<AsyncEvent*>(evt_vec.first.buf)); + evt.mId = id; + evt.mState = AsyncSrcState::Stop; ring->writeAdvance(1); } @@ -1145,16 +1145,16 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi /* Send any events now, after the position/buffer info was updated. */ const auto enabledevt = Context->mEnabledEvts.load(std::memory_order_acquire); - if(buffers_done > 0 && enabledevt.test(AsyncEvent::BufferCompleted)) + if(buffers_done > 0 && enabledevt.test(al::to_underlying(AsyncEnableBits::BufferCompleted))) { RingBuffer *ring{Context->mAsyncEvents.get()}; auto evt_vec = ring->getWriteVector(); if(evt_vec.first.len > 0) { - AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), - AsyncEvent::BufferCompleted)}; - evt->u.bufcomp.id = SourceID; - evt->u.bufcomp.count = buffers_done; + AsyncBufferCompleteEvent &evt = InitAsyncEvent<AsyncBufferCompleteEvent>( + reinterpret_cast<AsyncEvent*>(evt_vec.first.buf)); + evt.mId = SourceID; + evt.mCount = buffers_done; ring->writeAdvance(1); } } @@ -1165,7 +1165,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi * ensures any residual noise fades to 0 amplitude. */ mPlayState.store(Stopping, std::memory_order_release); - if(enabledevt.test(AsyncEvent::SourceStateChange)) + if(enabledevt.test(al::to_underlying(AsyncEnableBits::SourceState))) SendSourceStoppedEvent(Context, SourceID); } } |