aboutsummaryrefslogtreecommitdiffstats
path: root/al/event.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-16 01:18:11 -0800
committerChris Robinson <[email protected]>2020-12-16 01:40:15 -0800
commitc96b50fb657f6760636becab70dbbdaa1bfb2974 (patch)
tree81fa749a7a1fbc8333531ebf08a7fe01807abfc4 /al/event.cpp
parent5ad28f8cbaa52f3f6bf4c4cdbfbdbeb3087020e1 (diff)
Use a separate enum for the VoiceChange state
Diffstat (limited to 'al/event.cpp')
-rw-r--r--al/event.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/al/event.cpp b/al/event.cpp
index 6014a4a1..9db36137 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -27,6 +27,7 @@
#include "opthelpers.h"
#include "ringbuffer.h"
#include "threads.h"
+#include "voice_change.h"
static int EventThread(ALCcontext *context)
@@ -68,15 +69,33 @@ static int EventThread(ALCcontext *context)
{
if(!(enabledevts&EventType_SourceStateChange))
continue;
+ ALuint state{};
std::string msg{"Source ID " + std::to_string(evt.u.srcstate.id)};
msg += " state has changed to ";
- msg += (evt.u.srcstate.state==AL_INITIAL) ? "AL_INITIAL" :
- (evt.u.srcstate.state==AL_PLAYING) ? "AL_PLAYING" :
- (evt.u.srcstate.state==AL_PAUSED) ? "AL_PAUSED" :
- (evt.u.srcstate.state==AL_STOPPED) ? "AL_STOPPED" : "<unknown>";
+ switch(evt.u.srcstate.state)
+ {
+ case VChangeState::Reset:
+ msg += "AL_INITIAL";
+ state = AL_INITIAL;
+ break;
+ case VChangeState::Stop:
+ msg += "AL_STOPPED";
+ state = AL_STOPPED;
+ break;
+ case VChangeState::Play:
+ msg += "AL_PLAYING";
+ state = AL_PLAYING;
+ break;
+ case VChangeState::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,
- static_cast<ALuint>(evt.u.srcstate.state), static_cast<ALsizei>(msg.length()),
- msg.c_str(), context->mEventParam);
+ state, static_cast<ALsizei>(msg.length()), msg.c_str(), context->mEventParam);
}
else if(evt.EnumType == EventType_BufferCompleted)
{