diff options
-rw-r--r-- | al/source.cpp | 17 | ||||
-rw-r--r-- | al/source.h | 15 |
2 files changed, 12 insertions, 20 deletions
diff --git a/al/source.cpp b/al/source.cpp index 5ba36524..a021cd1a 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -75,15 +75,15 @@ using namespace std::placeholders; inline ALvoice *GetSourceVoice(ALsource *source, ALCcontext *context) { - ALint idx{source->VoiceIdx}; - if(idx >= 0 && static_cast<ALuint>(idx) < context->mVoiceCount.load(std::memory_order_relaxed)) + ALuint idx{source->VoiceIdx}; + if(idx < context->mVoiceCount.load(std::memory_order_relaxed)) { ALuint sid{source->id}; ALvoice &voice = (*context->mVoices)[idx]; if(voice.mSourceID.load(std::memory_order_acquire) == sid) return &voice; } - source->VoiceIdx = -1; + source->VoiceIdx = INVALID_VOICE_IDX; return nullptr; } @@ -2894,7 +2894,7 @@ START_API_FUNC } ); assert(voice != voices_end); - auto vidx = static_cast<ALint>(std::distance(context->mVoices->begin(), voice)); + auto vidx = static_cast<ALuint>(std::distance(context->mVoices->begin(), voice)); voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); source->PropsClean.test_and_set(std::memory_order_acquire); @@ -3554,16 +3554,7 @@ ALsource::ALsource(ALsizei num_sends) send.LFReference = HIGHPASSFREQREF; } - Offset = 0.0; - OffsetType = AL_NONE; - SourceType = AL_UNDETERMINED; - state = AL_INITIAL; - - queue = nullptr; - PropsClean.test_and_set(std::memory_order_relaxed); - - VoiceIdx = -1; } ALsource::~ALsource() diff --git a/al/source.h b/al/source.h index 1aafafab..a5d10cf9 100644 --- a/al/source.h +++ b/al/source.h @@ -20,6 +20,7 @@ struct ALeffectslot; #define DEFAULT_SENDS 2 +#define INVALID_VOICE_IDX static_cast<ALuint>(-1) struct ALbufferlistitem { using element_type = ALbuffer*; @@ -139,27 +140,27 @@ struct ALsource { * Last user-specified offset, and the offset type (bytes, samples, or * seconds). */ - ALdouble Offset; - ALenum OffsetType; + ALdouble Offset{0.0}; + ALenum OffsetType{AL_NONE}; /** Source type (static, streaming, or undetermined) */ - ALint SourceType; + ALint SourceType{AL_UNDETERMINED}; /** Source state (initial, playing, paused, or stopped) */ - ALenum state; + ALenum state{AL_INITIAL}; /** Source Buffer Queue head. */ - ALbufferlistitem *queue; + ALbufferlistitem *queue{nullptr}; std::atomic_flag PropsClean; /* Index into the context's Voices array. Lazily updated, only checked and * reset when looking up the voice. */ - ALint VoiceIdx; + ALuint VoiceIdx{INVALID_VOICE_IDX}; /** Self ID */ - ALuint id; + ALuint id{0}; ALsource(ALsizei num_sends); |