diff options
author | Chris Robinson <[email protected]> | 2018-12-06 22:24:20 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-06 22:24:20 -0800 |
commit | 0f24139b57460c71d66b9a090217d34706d64dde (patch) | |
tree | 29138a2a4d6ff0734f4c205983cc7d6711790c6e /OpenAL32 | |
parent | 42d26472eb514a2fcb1eafbed93f56a697ebb3a0 (diff) |
Use a constructor instead of a macro to initialize AsyncEvent
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 8 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 2 | ||||
-rw-r--r-- | OpenAL32/event.cpp | 4 |
3 files changed, 8 insertions, 6 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 75dc6c74..cbf00c50 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -842,7 +842,7 @@ enum { }; struct AsyncEvent { - unsigned int EnumType; + unsigned int EnumType{0u}; union { char dummy; struct { @@ -860,9 +860,11 @@ struct AsyncEvent { ALchar msg[1008]; } user; EffectState *mEffectState; - } u; + } u{}; + + AsyncEvent() noexcept = default; + constexpr AsyncEvent(unsigned int type) noexcept : EnumType{type} { } }; -#define ASYNC_EVENT(t) AsyncEvent{ t, { 0 } } void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends); diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 872bc9ee..f257da83 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -687,7 +687,7 @@ void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state) ALbitfieldSOFT enabledevt{context->EnabledEvts.load(std::memory_order_acquire)}; if(!(enabledevt&EventType_SourceStateChange)) return; - AsyncEvent evt{ASYNC_EVENT(EventType_SourceStateChange)}; + AsyncEvent evt{EventType_SourceStateChange}; evt.u.srcstate.id = id; evt.u.srcstate.state = state; diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp index 1a4e1df0..ad3fd4ab 100644 --- a/OpenAL32/event.cpp +++ b/OpenAL32/event.cpp @@ -18,9 +18,9 @@ static int EventThread(ALCcontext *context) { bool quitnow{false}; + AsyncEvent evt{}; while(LIKELY(!quitnow)) { - AsyncEvent evt; if(ll_ringbuffer_read(context->AsyncEvents, &evt, 1) == 0) { context->EventSem.wait(); @@ -90,7 +90,7 @@ void StartEventThrd(ALCcontext *ctx) void StopEventThrd(ALCcontext *ctx) { - static constexpr AsyncEvent kill_evt = ASYNC_EVENT(EventType_KillThread); + static constexpr AsyncEvent kill_evt{EventType_KillThread}; while(ll_ringbuffer_write(ctx->AsyncEvents, &kill_evt, 1) == 0) std::this_thread::yield(); ctx->EventSem.post(); |