diff options
-rw-r--r-- | al/source.cpp | 14 | ||||
-rw-r--r-- | alc/alc.cpp | 6 | ||||
-rw-r--r-- | alc/alu.cpp | 10 | ||||
-rw-r--r-- | alc/voice.cpp | 27 | ||||
-rw-r--r-- | alc/voice.h | 16 |
5 files changed, 35 insertions, 38 deletions
diff --git a/al/source.cpp b/al/source.cpp index b519025b..42c2d028 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -450,8 +450,8 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferlistitem *BufferList, ALC voice->mAmbiScaling = buffer->mBuffer.mAmbiScaling; voice->mAmbiOrder = buffer->mBuffer.mAmbiOrder; - if(buffer->mBuffer.mCallback) voice->mFlags |= VOICE_IS_CALLBACK; - else if(source->SourceType == AL_STATIC) voice->mFlags |= VOICE_IS_STATIC; + if(buffer->mBuffer.mCallback) voice->mFlags |= VoiceIsCallback; + else if(source->SourceType == AL_STATIC) voice->mFlags |= VoiceIsStatic; voice->mNumCallbackSamples = 0; /* Clear the stepping value explicitly so the mixer knows not to mix this @@ -485,7 +485,7 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferlistitem *BufferList, ALC std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{}); } - voice->mFlags |= VOICE_IS_AMBISONIC; + voice->mFlags |= VoiceIsAmbisonic; } else { @@ -605,7 +605,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC newvoice->mPositionFrac.store(vpos.frac, std::memory_order_relaxed); newvoice->mCurrentBuffer.store(vpos.bufferitem, std::memory_order_relaxed); newvoice->mFlags = (vpos.pos > 0 || vpos.frac > 0 || vpos.bufferitem != source->queue) ? - VOICE_IS_FADING : 0; + VoiceIsFading : 0u; InitVoice(newvoice, source, source->queue, context, device); source->VoiceIdx = vidx; @@ -1145,7 +1145,7 @@ bool SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a if(Voice *voice{GetSourceVoice(Source, Context)}) { - if((voice->mFlags&VOICE_IS_CALLBACK)) + if((voice->mFlags&VoiceIsCallback)) SETERR_RETURN(Context, AL_INVALID_VALUE, false, "Source offset for callback is invalid"); auto vpos = GetSampleOffset(Source->queue, prop, values[0]); @@ -1356,7 +1356,7 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a if(Voice *voice{GetSourceVoice(Source, Context)}) { - if((voice->mFlags&VOICE_IS_CALLBACK)) + if((voice->mFlags&VoiceIsCallback)) SETERR_RETURN(Context, AL_INVALID_VALUE, false, "Source offset for callback is invalid"); auto vpos = GetSampleOffset(Source->queue, prop, values[0]); @@ -2939,7 +2939,7 @@ START_API_FUNC voice->mPositionFrac.store(vpos->frac, std::memory_order_relaxed); voice->mCurrentBuffer.store(vpos->bufferitem, std::memory_order_relaxed); if(vpos->pos != 0 || vpos->frac != 0 || vpos->bufferitem != source->queue) - voice->mFlags |= VOICE_IS_FADING; + voice->mFlags |= VoiceIsFading; } } InitVoice(voice, source, BufferList, context.get(), device); diff --git a/alc/alc.cpp b/alc/alc.cpp index 64fddafc..6a599dda 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2202,7 +2202,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) continue; voice->mStep = 0; - voice->mFlags |= VOICE_IS_FADING; + voice->mFlags |= VoiceIsFading; if(voice->mAmbiOrder && device->mAmbiOrder > voice->mAmbiOrder) { @@ -2223,7 +2223,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) std::fill_n(chandata.mWetParams.begin(), num_sends, SendParams{}); } - voice->mFlags |= VOICE_IS_AMBISONIC; + voice->mFlags |= VoiceIsAmbisonic; } else { @@ -2235,7 +2235,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) std::fill_n(chandata.mWetParams.begin(), num_sends, SendParams{}); } - voice->mFlags &= ~VOICE_IS_AMBISONIC; + voice->mFlags &= ~VoiceIsAmbisonic; } if(device->AvgSpeakerDist > 0.0f) diff --git a/alc/alu.cpp b/alc/alu.cpp index ba44980c..722ef1e1 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -818,7 +818,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con break; } - voice->mFlags &= ~(VOICE_HAS_HRTF | VOICE_HAS_NFC); + voice->mFlags &= ~(VoiceHasHrtf | VoiceHasNfc); if(voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtBFormat3D) { /* Special handling for B-Format sources. */ @@ -845,7 +845,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con voice->mChans[0].mDryParams.NFCtrlFilter.adjust(w0); } - voice->mFlags |= VOICE_HAS_NFC; + voice->mFlags |= VoiceHasNfc; } /* Panning a B-Format sound toward some direction is easy. Just pan the @@ -1076,7 +1076,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con } } - voice->mFlags |= VOICE_HAS_HRTF; + voice->mFlags |= VoiceHasHrtf; } else { @@ -1097,7 +1097,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(size_t c{0};c < num_channels;c++) voice->mChans[c].mDryParams.NFCtrlFilter.adjust(w0); - voice->mFlags |= VOICE_HAS_NFC; + voice->mFlags |= VoiceHasNfc; } /* Calculate the directional coefficients once, which apply to all @@ -1148,7 +1148,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(size_t c{0};c < num_channels;c++) voice->mChans[c].mDryParams.NFCtrlFilter.adjust(w0); - voice->mFlags |= VOICE_HAS_NFC; + voice->mFlags |= VoiceHasNfc; } for(size_t c{0};c < num_channels;c++) diff --git a/alc/voice.cpp b/alc/voice.cpp index 6b1fc3d4..cf726bef 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -480,7 +480,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD ResamplerFunc Resample{(increment == FRACTIONONE && DataPosFrac == 0) ? Resample_<CopyTag,CTag> : mResampler}; - ALuint Counter{(mFlags&VOICE_IS_FADING) ? SamplesToDo : 0}; + ALuint Counter{(mFlags&VoiceIsFading) ? SamplesToDo : 0}; if(!Counter) { /* No fading, just overwrite the old/current params. */ @@ -488,7 +488,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD { { DirectParams &parms = chandata.mDryParams; - if(!(mFlags&VOICE_HAS_HRTF)) + if(!(mFlags&VoiceHasHrtf)) parms.Gains.Current = parms.Gains.Target; else parms.Hrtf.Old = parms.Hrtf.Target; @@ -553,8 +553,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } } - if((mFlags&(VOICE_IS_CALLBACK|VOICE_CALLBACK_STOPPED)) == VOICE_IS_CALLBACK - && BufferListItem) + if((mFlags&(VoiceIsCallback|VoiceCallbackStopped)) == VoiceIsCallback && BufferListItem) { ALbuffer *buffer{BufferListItem->mBuffer}; @@ -568,10 +567,10 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD const ALsizei gotBytes{buffer->mBuffer.mCallback(buffer->mBuffer.mUserData, &buffer->mBuffer.mData[byteOffset], static_cast<ALsizei>(needBytes))}; if(gotBytes < 1) - mFlags |= VOICE_CALLBACK_STOPPED; + mFlags |= VoiceCallbackStopped; else if(static_cast<ALuint>(gotBytes) < needBytes) { - mFlags |= VOICE_CALLBACK_STOPPED; + mFlags |= VoiceCallbackStopped; mNumCallbackSamples += static_cast<ALuint>(static_cast<ALuint>(gotBytes) / FrameSize); } @@ -597,10 +596,10 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD if UNLIKELY(!BufferListItem) srciter = std::copy(chandata.mPrevSamples.begin()+(MAX_RESAMPLER_PADDING>>1), chandata.mPrevSamples.end(), srciter); - else if((mFlags&VOICE_IS_STATIC)) + else if((mFlags&VoiceIsStatic)) srciter = LoadBufferStatic(BufferListItem, BufferLoopItem, num_chans, SampleSize, chan, DataPosInt, {srciter, SrcData.end()}); - else if((mFlags&VOICE_IS_CALLBACK)) + else if((mFlags&VoiceIsCallback)) srciter = LoadBufferCallback(BufferListItem, num_chans, SampleSize, chan, mNumCallbackSamples, {srciter, SrcData.end()}); else @@ -626,7 +625,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD const float *ResampledData{Resample(&mResampleState, &SrcData[MAX_RESAMPLER_PADDING>>1], DataPosFrac, increment, {Device->ResampledData, DstBufferSize})}; - if((mFlags&VOICE_IS_AMBISONIC)) + if((mFlags&VoiceIsAmbisonic)) { const float hfscale{chandata.mAmbiScale}; /* Beware the evil const_cast. It's safe since it's pointing to @@ -646,14 +645,14 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD const float *samples{DoFilters(parms.LowPass, parms.HighPass, FilterBuf, {ResampledData, DstBufferSize}, mDirect.FilterType)}; - if((mFlags&VOICE_HAS_HRTF)) + if((mFlags&VoiceHasHrtf)) { const float TargetGain{UNLIKELY(vstate == Stopping) ? 0.0f : parms.Hrtf.Target.Gain}; DoHrtfMix(samples, DstBufferSize, parms, TargetGain, Counter, OutPos, IrSize, Device); } - else if((mFlags&VOICE_HAS_NFC)) + else if((mFlags&VoiceHasNfc)) { const float *TargetGains{UNLIKELY(vstate == Stopping) ? SilentTarget.data() : parms.Gains.Target.data()}; @@ -697,7 +696,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD { /* Do nothing extra when there's no buffers. */ } - else if((mFlags&VOICE_IS_STATIC)) + else if((mFlags&VoiceIsStatic)) { if(BufferLoopItem) { @@ -721,7 +720,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } } } - else if((mFlags&VOICE_IS_CALLBACK)) + else if((mFlags&VoiceIsCallback)) { ALbuffer *buffer{BufferListItem->mBuffer}; if(SrcSamplesDone < mNumCallbackSamples) @@ -754,7 +753,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } } while(OutPos < SamplesToDo); - mFlags |= VOICE_IS_FADING; + mFlags |= VoiceIsFading; /* Don't update positions and buffers if we were stopping. */ if UNLIKELY(vstate == Stopping) diff --git a/alc/voice.h b/alc/voice.h index 29ca0484..a9774fd3 100644 --- a/alc/voice.h +++ b/alc/voice.h @@ -175,15 +175,13 @@ struct VoicePropsItem : public VoiceProps { DEF_NEWDEL(VoicePropsItem) }; -#define VOICE_IS_STATIC (1u<<0) -#define VOICE_IS_CALLBACK (1u<<1) -#define VOICE_IS_AMBISONIC (1u<<2) /* Voice needs HF scaling for ambisonic upsampling. */ -#define VOICE_CALLBACK_STOPPED (1u<<3) -#define VOICE_IS_FADING (1u<<4) /* Fading sources use gain stepping for smooth transitions. */ -#define VOICE_HAS_HRTF (1u<<5) -#define VOICE_HAS_NFC (1u<<6) - -#define VOICE_TYPE_MASK (VOICE_IS_STATIC | VOICE_IS_CALLBACK) +constexpr ALuint VoiceIsStatic{ 1u<<0}; +constexpr ALuint VoiceIsCallback{ 1u<<1}; +constexpr ALuint VoiceIsAmbisonic{ 1u<<2}; /* Needs HF scaling for ambisonic upsampling. */ +constexpr ALuint VoiceCallbackStopped{1u<<3}; +constexpr ALuint VoiceIsFading{ 1u<<4}; /* Use gain stepping for smooth transitions. */ +constexpr ALuint VoiceHasHrtf{ 1u<<5}; +constexpr ALuint VoiceHasNfc{ 1u<<6}; struct Voice { enum State { |