aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-10-10 05:07:31 -0700
committerChris Robinson <[email protected]>2021-10-10 05:07:31 -0700
commit92b65fa15fa8d7ca064ef6178fc749b6a465ad5b (patch)
tree54d422102fdd8ef5ec0b6d7a39f778744f70b3c0 /core
parent87e88e97e2627bc14e8d001a8c6b272f43b1b654 (diff)
Avoid manually prefixing EventType_ enums
And use a better fitting type that matches how it's used
Diffstat (limited to 'core')
-rw-r--r--core/async_event.h22
-rw-r--r--core/voice.cpp8
2 files changed, 15 insertions, 15 deletions
diff --git a/core/async_event.h b/core/async_event.h
index 054f0563..750f38c9 100644
--- a/core/async_event.h
+++ b/core/async_event.h
@@ -8,20 +8,20 @@ struct EffectState;
using uint = unsigned int;
-enum {
- /* End event thread processing. */
- EventType_KillThread = 0,
+struct AsyncEvent {
+ enum : uint {
+ /* End event thread processing. */
+ KillThread = 0,
- /* User event types. */
- EventType_SourceStateChange = 1<<0,
- EventType_BufferCompleted = 1<<1,
- EventType_Disconnected = 1<<2,
+ /* User event types. */
+ SourceStateChange = 1<<0,
+ BufferCompleted = 1<<1,
+ Disconnected = 1<<2,
- /* Internal events. */
- EventType_ReleaseEffectState = 65536,
-};
+ /* Internal events. */
+ ReleaseEffectState = 65536,
+ };
-struct AsyncEvent {
enum class SrcState {
Reset,
Stop,
diff --git a/core/voice.cpp b/core/voice.cpp
index fd2b7089..f40be71a 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -165,7 +165,7 @@ void SendSourceStoppedEvent(ContextBase *context, uint id)
if(evt_vec.first.len < 1) return;
AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
- EventType_SourceStateChange)};
+ AsyncEvent::SourceStateChange)};
evt->u.srcstate.id = id;
evt->u.srcstate.state = AsyncEvent::SrcState::Stop;
@@ -787,14 +787,14 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo
/* Send any events now, after the position/buffer info was updated. */
const uint enabledevt{Context->mEnabledEvts.load(std::memory_order_acquire)};
- if(buffers_done > 0 && (enabledevt&EventType_BufferCompleted))
+ if(buffers_done > 0 && (enabledevt&AsyncEvent::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),
- EventType_BufferCompleted)};
+ AsyncEvent::BufferCompleted)};
evt->u.bufcomp.id = SourceID;
evt->u.bufcomp.count = buffers_done;
ring->writeAdvance(1);
@@ -807,7 +807,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo
* ensures any residual noise fades to 0 amplitude.
*/
mPlayState.store(Stopping, std::memory_order_release);
- if((enabledevt&EventType_SourceStateChange))
+ if((enabledevt&AsyncEvent::SourceStateChange))
SendSourceStoppedEvent(Context, SourceID);
}
}