diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2020-10-21 10:39:00 -0700 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2020-10-21 10:39:00 -0700 |
commit | b8f5e1f4247e8a1d1ebdbe39dad6b235d6d50daa (patch) | |
tree | 32f0465fdb9a3b6e5a63c8d3e549b9b1d2e30547 /alc | |
parent | a3ea46f77385a2a489a06209d47d1fe1b911848f (diff) |
Change some more macros into constexpr variables
Diffstat (limited to 'alc')
-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 |
4 files changed, 28 insertions, 31 deletions
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 { |