Move async_event.h to core

This commit is contained in:
Chris Robinson 2021-04-25 14:29:21 -07:00
parent 0fe38c053d
commit 8d09d03ed3
6 changed files with 38 additions and 18 deletions

View File

@ -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

View File

@ -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);

View File

@ -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"

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;