Change some more macros into constexpr variables
This commit is contained in:
+7
-7
@@ -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);
|
||||
|
||||
+3
-3
@@ -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)
|
||||
|
||||
+5
-5
@@ -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++)
|
||||
|
||||
+13
-14
@@ -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)
|
||||
|
||||
+7
-9
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user