diff options
author | Chris Robinson <[email protected]> | 2021-04-25 14:29:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-04-25 14:29:21 -0700 |
commit | 8d09d03ed363ab1735b1933588d8242ba85ddf10 (patch) | |
tree | 515b4149211d29b04f7076ee943bed6bb62d0a90 | |
parent | 0fe38c053d8dd827e774fbe0aef121e7aa0a0f28 (diff) |
Move async_event.h to core
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | al/event.cpp | 13 | ||||
-rw-r--r-- | alc/alc.cpp | 2 | ||||
-rw-r--r-- | alc/alu.cpp | 21 | ||||
-rw-r--r-- | alc/voice.cpp | 4 | ||||
-rw-r--r-- | core/async_event.h (renamed from alc/async_event.h) | 14 |
6 files changed, 38 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ba04aa28..58d512e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -646,6 +646,7 @@ set(CORE_OBJS core/ambdec.h core/ambidefs.cpp core/ambidefs.h + core/async_event.h core/bs2b.cpp core/bs2b.h core/bsinc_defs.h @@ -758,7 +759,6 @@ set(ALC_OBJS alc/alconfig.cpp alc/alconfig.h alc/alcontext.h - alc/async_event.h alc/bformatdec.cpp alc/bformatdec.h alc/buffer_storage.cpp diff --git a/al/event.cpp b/al/event.cpp index a5d7be38..0bba4280 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -20,7 +20,7 @@ #include "albyte.h" #include "alcontext.h" #include "almalloc.h" -#include "async_event.h" +#include "core/async_event.h" #include "core/except.h" #include "core/logging.h" #include "effects/base.h" @@ -75,25 +75,22 @@ static int EventThread(ALCcontext *context) msg += " state has changed to "; switch(evt.u.srcstate.state) { - case VChangeState::Reset: + case AsyncEvent::SrcState::Reset: msg += "AL_INITIAL"; state = AL_INITIAL; break; - case VChangeState::Stop: + case AsyncEvent::SrcState::Stop: msg += "AL_STOPPED"; state = AL_STOPPED; break; - case VChangeState::Play: + case AsyncEvent::SrcState::Play: msg += "AL_PLAYING"; state = AL_PLAYING; break; - case VChangeState::Pause: + case AsyncEvent::SrcState::Pause: msg += "AL_PAUSED"; state = AL_PAUSED; break; - /* Shouldn't happen */ - case VChangeState::Restart: - break; } context->mEventCb(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, evt.u.srcstate.id, state, static_cast<ALsizei>(msg.length()), msg.c_str(), context->mEventParam); diff --git a/alc/alc.cpp b/alc/alc.cpp index 1d96cef0..8ba1c8a2 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -76,10 +76,10 @@ #include "alspan.h" #include "alstring.h" #include "alu.h" -#include "async_event.h" #include "atomic.h" #include "bformatdec.h" #include "core/ambidefs.h" +#include "core/async_event.h" #include "core/bs2b.h" #include "core/cpu_caps.h" #include "core/devformat.h" diff --git a/alc/alu.cpp b/alc/alu.cpp index 7221ce27..a97bc18b 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -50,10 +50,10 @@ #include "alnumeric.h" #include "alspan.h" #include "alstring.h" -#include "async_event.h" #include "atomic.h" #include "bformatdec.h" #include "core/ambidefs.h" +#include "core/async_event.h" #include "core/bs2b.h" #include "core/bsinc_tables.h" #include "core/cpu_caps.h" @@ -1581,7 +1581,24 @@ void SendSourceStateEvent(ContextBase *context, uint id, VChangeState state) AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_SourceStateChange}}; evt->u.srcstate.id = id; - evt->u.srcstate.state = state; + switch(state) + { + case VChangeState::Reset: + evt->u.srcstate.state = AsyncEvent::SrcState::Reset; + break; + case VChangeState::Stop: + evt->u.srcstate.state = AsyncEvent::SrcState::Stop; + break; + case VChangeState::Play: + evt->u.srcstate.state = AsyncEvent::SrcState::Play; + break; + case VChangeState::Pause: + evt->u.srcstate.state = AsyncEvent::SrcState::Pause; + break; + /* Shouldn't happen. */ + case VChangeState::Restart: + ASSUME(0); + } ring->writeAdvance(1); } diff --git a/alc/voice.cpp b/alc/voice.cpp index 8782e916..6abfcf59 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -42,9 +42,9 @@ #include "alspan.h" #include "alstring.h" #include "alu.h" -#include "async_event.h" #include "buffer_storage.h" #include "core/ambidefs.h" +#include "core/async_event.h" #include "core/cpu_caps.h" #include "core/devformat.h" #include "core/device.h" @@ -185,7 +185,7 @@ void SendSourceStoppedEvent(ContextBase *context, uint id) AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_SourceStateChange}}; evt->u.srcstate.id = id; - evt->u.srcstate.state = VChangeState::Stop; + evt->u.srcstate.state = AsyncEvent::SrcState::Stop; ring->writeAdvance(1); } diff --git a/alc/async_event.h b/core/async_event.h index 1ee58b10..054f0563 100644 --- a/alc/async_event.h +++ b/core/async_event.h @@ -1,10 +1,9 @@ -#ifndef ALC_EVENT_H -#define ALC_EVENT_H +#ifndef CORE_EVENT_H +#define CORE_EVENT_H #include "almalloc.h" struct EffectState; -enum class VChangeState; using uint = unsigned int; @@ -23,12 +22,19 @@ enum { }; struct AsyncEvent { + enum class SrcState { + Reset, + Stop, + Play, + Pause + }; + uint EnumType{0u}; union { char dummy; struct { uint id; - VChangeState state; + SrcState state; } srcstate; struct { uint id; |