Avoid manually prefixing EventType_ enums
And use a better fitting type that matches how it's usedmaster
parent
87e88e97e2
commit
92b65fa15f
24
al/event.cpp
24
al/event.cpp
|
@ -54,10 +54,10 @@ static int EventThread(ALCcontext *context)
|
|||
al::destroy_at(evt_ptr);
|
||||
ring->readAdvance(1);
|
||||
|
||||
quitnow = evt.EnumType == EventType_KillThread;
|
||||
quitnow = evt.EnumType == AsyncEvent::KillThread;
|
||||
if(unlikely(quitnow)) break;
|
||||
|
||||
if(evt.EnumType == EventType_ReleaseEffectState)
|
||||
if(evt.EnumType == AsyncEvent::ReleaseEffectState)
|
||||
{
|
||||
evt.u.mEffectState->release();
|
||||
continue;
|
||||
|
@ -66,9 +66,9 @@ static int EventThread(ALCcontext *context)
|
|||
uint enabledevts{context->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if(!context->mEventCb) continue;
|
||||
|
||||
if(evt.EnumType == EventType_SourceStateChange)
|
||||
if(evt.EnumType == AsyncEvent::SourceStateChange)
|
||||
{
|
||||
if(!(enabledevts&EventType_SourceStateChange))
|
||||
if(!(enabledevts&AsyncEvent::SourceStateChange))
|
||||
continue;
|
||||
ALuint state{};
|
||||
std::string msg{"Source ID " + std::to_string(evt.u.srcstate.id)};
|
||||
|
@ -95,9 +95,9 @@ static int EventThread(ALCcontext *context)
|
|||
context->mEventCb(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, evt.u.srcstate.id,
|
||||
state, static_cast<ALsizei>(msg.length()), msg.c_str(), context->mEventParam);
|
||||
}
|
||||
else if(evt.EnumType == EventType_BufferCompleted)
|
||||
else if(evt.EnumType == AsyncEvent::BufferCompleted)
|
||||
{
|
||||
if(!(enabledevts&EventType_BufferCompleted))
|
||||
if(!(enabledevts&AsyncEvent::BufferCompleted))
|
||||
continue;
|
||||
std::string msg{std::to_string(evt.u.bufcomp.count)};
|
||||
if(evt.u.bufcomp.count == 1) msg += " buffer completed";
|
||||
|
@ -106,9 +106,9 @@ static int EventThread(ALCcontext *context)
|
|||
evt.u.bufcomp.count, static_cast<ALsizei>(msg.length()), msg.c_str(),
|
||||
context->mEventParam);
|
||||
}
|
||||
else if(evt.EnumType == EventType_Disconnected)
|
||||
else if(evt.EnumType == AsyncEvent::Disconnected)
|
||||
{
|
||||
if(!(enabledevts&EventType_Disconnected))
|
||||
if(!(enabledevts&AsyncEvent::Disconnected))
|
||||
continue;
|
||||
context->mEventCb(AL_EVENT_TYPE_DISCONNECTED_SOFT, 0, 0,
|
||||
static_cast<ALsizei>(strlen(evt.u.disconnect.msg)), evt.u.disconnect.msg,
|
||||
|
@ -143,7 +143,7 @@ void StopEventThrd(ALCcontext *ctx)
|
|||
evt_data = ring->getWriteVector().first;
|
||||
} while(evt_data.len == 0);
|
||||
}
|
||||
al::construct_at(reinterpret_cast<AsyncEvent*>(evt_data.buf), EventType_KillThread);
|
||||
al::construct_at(reinterpret_cast<AsyncEvent*>(evt_data.buf), AsyncEvent::KillThread);
|
||||
ring->writeAdvance(1);
|
||||
|
||||
ctx->mEventSem.post();
|
||||
|
@ -167,11 +167,11 @@ START_API_FUNC
|
|||
[&flags](ALenum type) noexcept -> bool
|
||||
{
|
||||
if(type == AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT)
|
||||
flags |= EventType_BufferCompleted;
|
||||
flags |= AsyncEvent::BufferCompleted;
|
||||
else if(type == AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT)
|
||||
flags |= EventType_SourceStateChange;
|
||||
flags |= AsyncEvent::SourceStateChange;
|
||||
else if(type == AL_EVENT_TYPE_DISCONNECTED_SOFT)
|
||||
flags |= EventType_Disconnected;
|
||||
flags |= AsyncEvent::Disconnected;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
|
|
10
alc/alu.cpp
10
alc/alu.cpp
|
@ -469,7 +469,7 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBa
|
|||
if LIKELY(evt_vec.first.len > 0)
|
||||
{
|
||||
AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
|
||||
EventType_ReleaseEffectState)};
|
||||
AsyncEvent::ReleaseEffectState)};
|
||||
evt->u.mEffectState = oldstate;
|
||||
ring->writeAdvance(1);
|
||||
}
|
||||
|
@ -1558,7 +1558,7 @@ void SendSourceStateEvent(ContextBase *context, uint id, VChangeState state)
|
|||
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;
|
||||
switch(state)
|
||||
{
|
||||
|
@ -1669,7 +1669,7 @@ void ProcessVoiceChanges(ContextBase *ctx)
|
|||
}
|
||||
oldvoice->mPendingChange.store(false, std::memory_order_release);
|
||||
}
|
||||
if(sendevt && (enabledevt&EventType_SourceStateChange))
|
||||
if(sendevt && (enabledevt&AsyncEvent::SourceStateChange))
|
||||
SendSourceStateEvent(ctx, cur->mSourceID, cur->mState);
|
||||
|
||||
next = cur->mNext.load(std::memory_order_acquire);
|
||||
|
@ -2020,7 +2020,7 @@ void DeviceBase::handleDisconnect(const char *msg, ...)
|
|||
if(!Connected.exchange(false, std::memory_order_acq_rel))
|
||||
return;
|
||||
|
||||
AsyncEvent evt{EventType_Disconnected};
|
||||
AsyncEvent evt{AsyncEvent::Disconnected};
|
||||
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
@ -2034,7 +2034,7 @@ void DeviceBase::handleDisconnect(const char *msg, ...)
|
|||
for(ContextBase *ctx : *mContexts.load())
|
||||
{
|
||||
const uint enabledevt{ctx->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if((enabledevt&EventType_Disconnected))
|
||||
if((enabledevt&AsyncEvent::Disconnected))
|
||||
{
|
||||
RingBuffer *ring{ctx->mAsyncEvents.get()};
|
||||
auto evt_data = ring->getWriteVector().first;
|
||||
|
|
|
@ -8,20 +8,20 @@ struct EffectState;
|
|||
using uint = unsigned int;
|
||||
|
||||
|
||||
enum {
|
||||
/* End event thread processing. */
|
||||
EventType_KillThread = 0,
|
||||
|
||||
/* User event types. */
|
||||
EventType_SourceStateChange = 1<<0,
|
||||
EventType_BufferCompleted = 1<<1,
|
||||
EventType_Disconnected = 1<<2,
|
||||
|
||||
/* Internal events. */
|
||||
EventType_ReleaseEffectState = 65536,
|
||||
};
|
||||
|
||||
struct AsyncEvent {
|
||||
enum : uint {
|
||||
/* End event thread processing. */
|
||||
KillThread = 0,
|
||||
|
||||
/* User event types. */
|
||||
SourceStateChange = 1<<0,
|
||||
BufferCompleted = 1<<1,
|
||||
Disconnected = 1<<2,
|
||||
|
||||
/* Internal events. */
|
||||
ReleaseEffectState = 65536,
|
||||
};
|
||||
|
||||
enum class SrcState {
|
||||
Reset,
|
||||
Stop,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue