aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp12
-rw-r--r--alc/voice.cpp3
-rw-r--r--alc/voice_change.h9
3 files changed, 16 insertions, 8 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 36113b80..7b7f5006 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -1564,7 +1564,7 @@ void CalcSourceParams(Voice *voice, ALCcontext *context, bool force)
}
-void SendSourceStateEvent(ALCcontext *context, ALuint id, ALenum state)
+void SendSourceStateEvent(ALCcontext *context, uint id, VChangeState state)
{
RingBuffer *ring{context->mAsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
@@ -1588,7 +1588,7 @@ void ProcessVoiceChanges(ALCcontext *ctx)
cur = next;
bool sendevt{false};
- if(cur->mState == AL_INITIAL || cur->mState == AL_STOPPED)
+ if(cur->mState == VChangeState::Reset || cur->mState == VChangeState::Stop)
{
if(Voice *voice{cur->mVoice})
{
@@ -1603,16 +1603,16 @@ void ProcessVoiceChanges(ALCcontext *ctx)
/* AL_INITIAL state change events are always sent, even if the
* voice is already stopped or even if there is no voice.
*/
- sendevt |= (cur->mState == AL_INITIAL);
+ sendevt |= (cur->mState == VChangeState::Reset);
}
- else if(cur->mState == AL_PAUSED)
+ else if(cur->mState == VChangeState::Pause)
{
Voice *voice{cur->mVoice};
Voice::State oldvstate{Voice::Playing};
sendevt = voice->mPlayState.compare_exchange_strong(oldvstate, Voice::Stopping,
std::memory_order_release, std::memory_order_acquire);
}
- else if(cur->mState == AL_PLAYING)
+ else if(cur->mState == VChangeState::Play)
{
/* NOTE: When playing a voice, sending a source state change event
* depends if there's an old voice to stop and if that stop is
@@ -1636,7 +1636,7 @@ void ProcessVoiceChanges(ALCcontext *ctx)
Voice *voice{cur->mVoice};
voice->mPlayState.store(Voice::Playing, std::memory_order_release);
}
- else if(cur->mState == AL_SAMPLE_OFFSET)
+ else if(cur->mState == VChangeState::Restart)
{
/* Changing a voice offset never sends a source change event. */
Voice *oldvoice{cur->mOldVoice};
diff --git a/alc/voice.cpp b/alc/voice.cpp
index 04ca51f3..6c00a6a2 100644
--- a/alc/voice.cpp
+++ b/alc/voice.cpp
@@ -60,6 +60,7 @@
#include "ringbuffer.h"
#include "threads.h"
#include "vector.h"
+#include "voice_change.h"
struct CTag;
#ifdef HAVE_SSE
@@ -184,7 +185,7 @@ void SendSourceStoppedEvent(ALCcontext *context, uint id)
AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_SourceStateChange}};
evt->u.srcstate.id = id;
- evt->u.srcstate.state = AL_STOPPED;
+ evt->u.srcstate.state = VChangeState::Stop;
ring->writeAdvance(1);
}
diff --git a/alc/voice_change.h b/alc/voice_change.h
index 1ce28f50..ddc6186f 100644
--- a/alc/voice_change.h
+++ b/alc/voice_change.h
@@ -10,11 +10,18 @@ struct Voice;
using uint = unsigned int;
+enum class VChangeState {
+ Reset,
+ Stop,
+ Play,
+ Pause,
+ Restart
+};
struct VoiceChange {
Voice *mOldVoice{nullptr};
Voice *mVoice{nullptr};
uint mSourceID{0};
- int mState{0};
+ VChangeState mState{};
std::atomic<VoiceChange*> mNext{nullptr};