diff options
author | Chris Robinson <[email protected]> | 2019-03-10 16:29:06 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-10 16:29:06 -0700 |
commit | 2c67ab0d2cf8db4ec60118d3522213a50ca97de7 (patch) | |
tree | 28e2d793992b00843812d9445f19056be83478f6 | |
parent | 030b24a40de0258ef4e9047aae6d770435060858 (diff) |
Rename ALvoice fields for consistency
-rw-r--r-- | Alc/alc.cpp | 61 | ||||
-rw-r--r-- | Alc/alu.cpp | 216 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 103 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 52 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 142 |
5 files changed, 285 insertions, 289 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 8109f202..6e6bc2b4 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2146,13 +2146,13 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) std::for_each(context->Voices, voices_end, [device](ALvoice *voice) -> void { - delete voice->Update.exchange(nullptr, std::memory_order_acq_rel); + delete voice->mUpdate.exchange(nullptr, std::memory_order_acq_rel); /* Force the voice to stopped if it was stopping. */ ALvoice::State vstate{ALvoice::Stopping}; - voice->PlayState.compare_exchange_strong(vstate, ALvoice::Stopped, + voice->mPlayState.compare_exchange_strong(vstate, ALvoice::Stopped, std::memory_order_acquire, std::memory_order_acquire); - if(voice->SourceID.load(std::memory_order_relaxed) == 0u) + if(voice->mSourceID.load(std::memory_order_relaxed) == 0u) return; if(device->AvgSpeakerDist > 0.0f) @@ -2160,7 +2160,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) /* Reinitialize the NFC filters for new parameters. */ ALfloat w1 = SPEEDOFSOUNDMETRESPERSEC / (device->AvgSpeakerDist * device->Frequency); - std::for_each(voice->Direct.Params, voice->Direct.Params+voice->NumChannels, + std::for_each(voice->mDirect.Params, voice->mDirect.Params+voice->mNumChannels, [w1](DirectParams ¶ms) noexcept -> void { params.NFCtrlFilter.init(w1); } ); @@ -2624,49 +2624,48 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) /* Make sure the old voice's Update (if any) is cleared so it * doesn't get deleted on deinit. */ - voice->Update.store(old_voice->Update.exchange(nullptr, std::memory_order_relaxed), - std::memory_order_relaxed); + voice->mUpdate.store(old_voice->mUpdate.exchange(nullptr, std::memory_order_relaxed), + std::memory_order_relaxed); - voice->SourceID.store(old_voice->SourceID.load(std::memory_order_relaxed), - std::memory_order_relaxed); - voice->PlayState.store(old_voice->PlayState.load(std::memory_order_relaxed), - std::memory_order_relaxed); + voice->mSourceID.store(old_voice->mSourceID.load(std::memory_order_relaxed), + std::memory_order_relaxed); + voice->mPlayState.store(old_voice->mPlayState.load(std::memory_order_relaxed), + std::memory_order_relaxed); - voice->Props = old_voice->Props; + voice->mProps = old_voice->mProps; /* Clear extraneous property set sends. */ - std::fill(std::begin(voice->Props.Send)+s_count, std::end(voice->Props.Send), + std::fill(std::begin(voice->mProps.Send)+s_count, std::end(voice->mProps.Send), ALvoiceProps::SendData{}); - voice->position.store(old_voice->position.load(std::memory_order_relaxed), - std::memory_order_relaxed); - voice->position_fraction.store( - old_voice->position_fraction.load(std::memory_order_relaxed), + voice->mPosition.store(old_voice->mPosition.load(std::memory_order_relaxed), + std::memory_order_relaxed); + voice->mPositionFrac.store(old_voice->mPositionFrac.load(std::memory_order_relaxed), std::memory_order_relaxed); - voice->current_buffer.store(old_voice->current_buffer.load(std::memory_order_relaxed), + voice->mCurrentBuffer.store(old_voice->mCurrentBuffer.load(std::memory_order_relaxed), std::memory_order_relaxed); - voice->loop_buffer.store(old_voice->loop_buffer.load(std::memory_order_relaxed), + voice->mLoopBuffer.store(old_voice->mLoopBuffer.load(std::memory_order_relaxed), std::memory_order_relaxed); - voice->Frequency = old_voice->Frequency; - voice->Channels = old_voice->Channels; - voice->NumChannels = old_voice->NumChannels; - voice->SampleSize = old_voice->SampleSize; + voice->mFrequency = old_voice->mFrequency; + voice->mFmtChannels = old_voice->mFmtChannels; + voice->mNumChannels = old_voice->mNumChannels; + voice->mSampleSize = old_voice->mSampleSize; - voice->Step = old_voice->Step; - voice->Resampler = old_voice->Resampler; + voice->mStep = old_voice->mStep; + voice->mResampler = old_voice->mResampler; - voice->Flags = old_voice->Flags; + voice->mFlags = old_voice->mFlags; - voice->Offset = old_voice->Offset; + voice->mOffset = old_voice->mOffset; - std::copy(std::begin(old_voice->PrevSamples), std::end(old_voice->PrevSamples), - std::begin(voice->PrevSamples)); + std::copy(std::begin(old_voice->mPrevSamples), std::end(old_voice->mPrevSamples), + std::begin(voice->mPrevSamples)); - voice->ResampleState = old_voice->ResampleState; + voice->mResampleState = old_voice->mResampleState; - voice->Direct = old_voice->Direct; - std::copy_n(old_voice->Send.begin(), s_count, voice->Send.begin()); + voice->mDirect = old_voice->mDirect; + std::copy_n(old_voice->mSend.begin(), s_count, voice->mSend.begin()); /* Set this voice's reference. */ ALvoice *ret = voice; diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 08ccd003..30d2e73c 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -179,7 +179,7 @@ void aluInit(void) void DeinitVoice(ALvoice *voice) noexcept { - delete voice->Update.exchange(nullptr, std::memory_order_acq_rel); + delete voice->mUpdate.exchange(nullptr, std::memory_order_acq_rel); voice->~ALvoice(); } @@ -503,7 +503,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo ALsizei num_channels{0}; bool isbformat{false}; ALfloat downmix_gain{1.0f}; - switch(voice->Channels) + switch(voice->mFmtChannels) { case FmtMono: chans = MonoMap; @@ -569,14 +569,15 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo } ASSUME(num_channels > 0); - std::for_each(std::begin(voice->Direct.Params), std::begin(voice->Direct.Params)+num_channels, + std::for_each(std::begin(voice->mDirect.Params), + std::begin(voice->mDirect.Params)+num_channels, [](DirectParams ¶ms) -> void { params.Hrtf.Target = HrtfParams{}; ClearArray(params.Gains.Target); } ); - std::for_each(voice->Send.begin(), voice->Send.end(), + std::for_each(voice->mSend.begin(), voice->mSend.end(), [num_channels](ALvoice::SendData &send) -> void { std::for_each(std::begin(send.Params), std::begin(send.Params)+num_channels, @@ -585,11 +586,11 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo } ); - voice->Flags &= ~(VOICE_HAS_HRTF | VOICE_HAS_NFC); + voice->mFlags &= ~(VOICE_HAS_HRTF | VOICE_HAS_NFC); if(isbformat) /* Special handling for B-Format sources. */ { - voice->Direct.Buffer = Device->Dry.Buffer; - voice->Direct.Channels = Device->Dry.NumChannels; + voice->mDirect.Buffer = Device->Dry.Buffer; + voice->mDirect.Channels = Device->Dry.NumChannels; if(Distance > std::numeric_limits<float>::epsilon()) { @@ -607,12 +608,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)}; /* Only need to adjust the first channel of a B-Format source. */ - voice->Direct.Params[0].NFCtrlFilter.adjust(w0); + voice->mDirect.Params[0].NFCtrlFilter.adjust(w0); std::copy(std::begin(Device->NumChannelsPerOrder), std::end(Device->NumChannelsPerOrder), - std::begin(voice->Direct.ChannelsPerOrder)); - voice->Flags |= VOICE_HAS_NFC; + std::begin(voice->mDirect.ChannelsPerOrder)); + voice->mFlags |= VOICE_HAS_NFC; } ALfloat coeffs[MAX_AMBI_CHANNELS]; @@ -641,12 +642,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* NOTE: W needs to be scaled due to FuMa normalization. */ const ALfloat &scale0 = AmbiScale::FromFuMa[0]; ComputePanGains(&Device->Dry, coeffs, DryGain*scale0, - voice->Direct.Params[0].Gains.Target); + voice->mDirect.Params[0].Gains.Target); for(ALsizei i{0};i < NumSends;i++) { if(const ALeffectslot *Slot{SendSlots[i]}) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, - WetGain[i]*scale0, voice->Send[i].Params[0].Gains.Target); + WetGain[i]*scale0, voice->mSend[i].Params[0].Gains.Target); } } else @@ -657,13 +658,13 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo * is what we want for FOA input. The first channel may have * been previously re-adjusted if panned, so reset it. */ - voice->Direct.Params[0].NFCtrlFilter.adjust(0.0f); + voice->mDirect.Params[0].NFCtrlFilter.adjust(0.0f); - voice->Direct.ChannelsPerOrder[0] = 1; - voice->Direct.ChannelsPerOrder[1] = mini(voice->Direct.Channels-1, 3); - std::fill(std::begin(voice->Direct.ChannelsPerOrder)+2, - std::end(voice->Direct.ChannelsPerOrder), 0); - voice->Flags |= VOICE_HAS_NFC; + voice->mDirect.ChannelsPerOrder[0] = 1; + voice->mDirect.ChannelsPerOrder[1] = mini(voice->mDirect.Channels-1, 3); + std::fill(std::begin(voice->mDirect.ChannelsPerOrder)+2, + std::end(voice->mDirect.ChannelsPerOrder), 0); + voice->mFlags |= VOICE_HAS_NFC; } /* Local B-Format sources have their XYZ channels rotated according @@ -701,13 +702,13 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo for(ALsizei c{0};c < num_channels;c++) ComputePanGains(&Device->Dry, matrix[c], DryGain, - voice->Direct.Params[c].Gains.Target); + voice->mDirect.Params[c].Gains.Target); for(ALsizei i{0};i < NumSends;i++) { if(const ALeffectslot *Slot{SendSlots[i]}) for(ALsizei c{0};c < num_channels;c++) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), matrix[c], - WetGain[i], voice->Send[i].Params[c].Gains.Target); + WetGain[i], voice->mSend[i].Params[c].Gains.Target); } } } @@ -716,13 +717,13 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Direct source channels always play local. Skip the virtual channels * and write inputs to the matching real outputs. */ - voice->Direct.Buffer = Device->RealOut.Buffer; - voice->Direct.Channels = Device->RealOut.NumChannels; + voice->mDirect.Buffer = Device->RealOut.Buffer; + voice->mDirect.Channels = Device->RealOut.NumChannels; for(ALsizei c{0};c < num_channels;c++) { int idx{GetChannelIdxByName(Device->RealOut, chans[c].channel)}; - if(idx != -1) voice->Direct.Params[c].Gains.Target[idx] = DryGain; + if(idx != -1) voice->mDirect.Params[c].Gains.Target[idx] = DryGain; } /* Auxiliary sends still use normal channel panning since they mix to @@ -737,8 +738,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo { if(const ALeffectslot *Slot{SendSlots[i]}) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, - WetGain[i], voice->Send[i].Params[c].Gains.Target - ); + WetGain[i], voice->mSend[i].Params[c].Gains.Target); } } } @@ -747,8 +747,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Full HRTF rendering. Skip the virtual channels and render to the * real outputs. */ - voice->Direct.Buffer = Device->RealOut.Buffer; - voice->Direct.Channels = Device->RealOut.NumChannels; + voice->mDirect.Buffer = Device->RealOut.Buffer; + voice->mDirect.Channels = Device->RealOut.NumChannels; if(Distance > std::numeric_limits<float>::epsilon()) { @@ -763,16 +763,16 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo * source direction. */ GetHrtfCoeffs(Device->mHrtf, ev, az, Distance, Spread, - voice->Direct.Params[0].Hrtf.Target.Coeffs, - voice->Direct.Params[0].Hrtf.Target.Delay); - voice->Direct.Params[0].Hrtf.Target.Gain = DryGain * downmix_gain; + voice->mDirect.Params[0].Hrtf.Target.Coeffs, + voice->mDirect.Params[0].Hrtf.Target.Delay); + voice->mDirect.Params[0].Hrtf.Target.Gain = DryGain * downmix_gain; /* Remaining channels use the same results as the first. */ for(ALsizei c{1};c < num_channels;c++) { /* Skip LFE */ if(chans[c].channel != LFE) - voice->Direct.Params[c].Hrtf.Target = voice->Direct.Params[0].Hrtf.Target; + voice->mDirect.Params[c].Hrtf.Target = voice->mDirect.Params[0].Hrtf.Target; } /* Calculate the directional coefficients once, which apply to all @@ -789,8 +789,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Skip LFE */ if(chans[c].channel != LFE) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, - WetGain[i]*downmix_gain, voice->Send[i].Params[c].Gains.Target - ); + WetGain[i]*downmix_gain, voice->mSend[i].Params[c].Gains.Target); } } } @@ -811,9 +810,9 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo */ GetHrtfCoeffs(Device->mHrtf, chans[c].elevation, chans[c].angle, std::numeric_limits<float>::infinity(), Spread, - voice->Direct.Params[c].Hrtf.Target.Coeffs, - voice->Direct.Params[c].Hrtf.Target.Delay); - voice->Direct.Params[c].Hrtf.Target.Gain = DryGain; + voice->mDirect.Params[c].Hrtf.Target.Coeffs, + voice->mDirect.Params[c].Hrtf.Target.Delay); + voice->mDirect.Params[c].Hrtf.Target.Gain = DryGain; /* Normal panning for auxiliary sends. */ ALfloat coeffs[MAX_AMBI_CHANNELS]; @@ -823,19 +822,18 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo { if(const ALeffectslot *Slot{SendSlots[i]}) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, - WetGain[i], voice->Send[i].Params[c].Gains.Target - ); + WetGain[i], voice->mSend[i].Params[c].Gains.Target); } } } - voice->Flags |= VOICE_HAS_HRTF; + voice->mFlags |= VOICE_HAS_HRTF; } else { /* Non-HRTF rendering. Use normal panning to the output. */ - voice->Direct.Buffer = Device->Dry.Buffer; - voice->Direct.Channels = Device->Dry.NumChannels; + voice->mDirect.Buffer = Device->Dry.Buffer; + voice->mDirect.Channels = Device->Dry.NumChannels; if(Distance > std::numeric_limits<float>::epsilon()) { @@ -850,12 +848,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Adjust NFC filters. */ for(ALsizei c{0};c < num_channels;c++) - voice->Direct.Params[c].NFCtrlFilter.adjust(w0); + voice->mDirect.Params[c].NFCtrlFilter.adjust(w0); std::copy(std::begin(Device->NumChannelsPerOrder), std::end(Device->NumChannelsPerOrder), - std::begin(voice->Direct.ChannelsPerOrder)); - voice->Flags |= VOICE_HAS_NFC; + std::begin(voice->mDirect.ChannelsPerOrder)); + voice->mFlags |= VOICE_HAS_NFC; } /* Calculate the directional coefficients once, which apply to all @@ -883,13 +881,13 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo if(Device->Dry.Buffer == Device->RealOut.Buffer) { int idx = GetChannelIdxByName(Device->RealOut, chans[c].channel); - if(idx != -1) voice->Direct.Params[c].Gains.Target[idx] = DryGain; + if(idx != -1) voice->mDirect.Params[c].Gains.Target[idx] = DryGain; } continue; } ComputePanGains(&Device->Dry, coeffs, DryGain * downmix_gain, - voice->Direct.Params[c].Gains.Target); + voice->mDirect.Params[c].Gains.Target); } for(ALsizei i{0};i < NumSends;i++) @@ -900,8 +898,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Skip LFE */ if(chans[c].channel != LFE) ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, - WetGain[i]*downmix_gain, voice->Send[i].Params[c].Gains.Target - ); + WetGain[i]*downmix_gain, voice->mSend[i].Params[c].Gains.Target); } } } @@ -917,12 +914,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (Device->AvgSpeakerDist * Frequency)}; for(ALsizei c{0};c < num_channels;c++) - voice->Direct.Params[c].NFCtrlFilter.adjust(w0); + voice->mDirect.Params[c].NFCtrlFilter.adjust(w0); std::copy(std::begin(Device->NumChannelsPerOrder), std::end(Device->NumChannelsPerOrder), - std::begin(voice->Direct.ChannelsPerOrder)); - voice->Flags |= VOICE_HAS_NFC; + std::begin(voice->mDirect.ChannelsPerOrder)); + voice->mFlags |= VOICE_HAS_NFC; } for(ALsizei c{0};c < num_channels;c++) @@ -933,7 +930,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo if(Device->Dry.Buffer == Device->RealOut.Buffer) { int idx = GetChannelIdxByName(Device->RealOut, chans[c].channel); - if(idx != -1) voice->Direct.Params[c].Gains.Target[idx] = DryGain; + if(idx != -1) voice->mDirect.Params[c].Gains.Target[idx] = DryGain; } continue; } @@ -946,13 +943,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo ); ComputePanGains(&Device->Dry, coeffs, DryGain, - voice->Direct.Params[c].Gains.Target); + voice->mDirect.Params[c].Gains.Target); for(ALsizei i{0};i < NumSends;i++) { if(const ALeffectslot *Slot{SendSlots[i]}) - ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), - coeffs, WetGain[i], voice->Send[i].Params[c].Gains.Target - ); + ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs, + WetGain[i], voice->mSend[i].Params[c].Gains.Target); } } } @@ -964,19 +960,19 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo const ALfloat gainHF{maxf(DryGainHF, 0.001f)}; /* Limit -60dB */ const ALfloat gainLF{maxf(DryGainLF, 0.001f)}; - voice->Direct.FilterType = AF_None; - if(gainHF != 1.0f) voice->Direct.FilterType |= AF_LowPass; - if(gainLF != 1.0f) voice->Direct.FilterType |= AF_HighPass; - voice->Direct.Params[0].LowPass.setParams(BiquadType::HighShelf, + voice->mDirect.FilterType = AF_None; + if(gainHF != 1.0f) voice->mDirect.FilterType |= AF_LowPass; + if(gainLF != 1.0f) voice->mDirect.FilterType |= AF_HighPass; + voice->mDirect.Params[0].LowPass.setParams(BiquadType::HighShelf, gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f) ); - voice->Direct.Params[0].HighPass.setParams(BiquadType::LowShelf, + voice->mDirect.Params[0].HighPass.setParams(BiquadType::LowShelf, gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f) ); for(ALsizei c{1};c < num_channels;c++) { - voice->Direct.Params[c].LowPass.copyParamsFrom(voice->Direct.Params[0].LowPass); - voice->Direct.Params[c].HighPass.copyParamsFrom(voice->Direct.Params[0].HighPass); + voice->mDirect.Params[c].LowPass.copyParamsFrom(voice->mDirect.Params[0].LowPass); + voice->mDirect.Params[c].HighPass.copyParamsFrom(voice->mDirect.Params[0].HighPass); } } for(ALsizei i{0};i < NumSends;i++) @@ -986,19 +982,19 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo const ALfloat gainHF{maxf(WetGainHF[i], 0.001f)}; const ALfloat gainLF{maxf(WetGainLF[i], 0.001f)}; - voice->Send[i].FilterType = AF_None; - if(gainHF != 1.0f) voice->Send[i].FilterType |= AF_LowPass; - if(gainLF != 1.0f) voice->Send[i].FilterType |= AF_HighPass; - voice->Send[i].Params[0].LowPass.setParams(BiquadType::HighShelf, + voice->mSend[i].FilterType = AF_None; + if(gainHF != 1.0f) voice->mSend[i].FilterType |= AF_LowPass; + if(gainLF != 1.0f) voice->mSend[i].FilterType |= AF_HighPass; + voice->mSend[i].Params[0].LowPass.setParams(BiquadType::HighShelf, gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f) ); - voice->Send[i].Params[0].HighPass.setParams(BiquadType::LowShelf, + voice->mSend[i].Params[0].HighPass.setParams(BiquadType::LowShelf, gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f) ); for(ALsizei c{1};c < num_channels;c++) { - voice->Send[i].Params[c].LowPass.copyParamsFrom(voice->Send[i].Params[0].LowPass); - voice->Send[i].Params[c].HighPass.copyParamsFrom(voice->Send[i].Params[0].HighPass); + voice->mSend[i].Params[c].LowPass.copyParamsFrom(voice->mSend[i].Params[0].LowPass); + voice->mSend[i].Params[c].HighPass.copyParamsFrom(voice->mSend[i].Params[0].HighPass); } } } @@ -1008,8 +1004,8 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons const ALCdevice *Device{ALContext->Device}; ALeffectslot *SendSlots[MAX_SENDS]; - voice->Direct.Buffer = Device->Dry.Buffer; - voice->Direct.Channels = Device->Dry.NumChannels; + voice->mDirect.Buffer = Device->Dry.Buffer; + voice->mDirect.Channels = Device->Dry.NumChannels; for(ALsizei i{0};i < Device->NumAuxSends;i++) { SendSlots[i] = props->Send[i].Slot; @@ -1018,28 +1014,28 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons if(!SendSlots[i] || SendSlots[i]->Params.EffectType == AL_EFFECT_NULL) { SendSlots[i] = nullptr; - voice->Send[i].Buffer = nullptr; - voice->Send[i].Channels = 0; + voice->mSend[i].Buffer = nullptr; + voice->mSend[i].Channels = 0; } else { - voice->Send[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]); - voice->Send[i].Channels = SendSlots[i]->WetBuffer.size(); + voice->mSend[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]); + voice->mSend[i].Channels = SendSlots[i]->WetBuffer.size(); } } /* Calculate the stepping value */ - const auto Pitch = static_cast<ALfloat>(voice->Frequency) / + const auto Pitch = static_cast<ALfloat>(voice->mFrequency) / static_cast<ALfloat>(Device->Frequency) * props->Pitch; if(Pitch > static_cast<ALfloat>(MAX_PITCH)) - voice->Step = MAX_PITCH<<FRACTIONBITS; + voice->mStep = MAX_PITCH<<FRACTIONBITS; else - voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1); + voice->mStep = maxi(fastf2i(Pitch * FRACTIONONE), 1); if(props->mResampler == BSinc24Resampler) - BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc24); + BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc24); else if(props->mResampler == BSinc12Resampler) - BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc12); - voice->Resampler = SelectResampler(props->mResampler); + BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc12); + voice->mResampler = SelectResampler(props->mResampler); /* Calculate gains */ const ALlistener &Listener = ALContext->Listener; @@ -1069,8 +1065,8 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A const ALlistener &Listener = ALContext->Listener; /* Set mixing buffers and get send parameters. */ - voice->Direct.Buffer = Device->Dry.Buffer; - voice->Direct.Channels = Device->Dry.NumChannels; + voice->mDirect.Buffer = Device->Dry.Buffer; + voice->mDirect.Channels = Device->Dry.NumChannels; ALeffectslot *SendSlots[MAX_SENDS]; ALfloat RoomRolloff[MAX_SENDS]; ALfloat DecayDistance[MAX_SENDS]; @@ -1126,13 +1122,13 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A if(!SendSlots[i]) { - voice->Send[i].Buffer = nullptr; - voice->Send[i].Channels = 0; + voice->mSend[i].Buffer = nullptr; + voice->mSend[i].Channels = 0; } else { - voice->Send[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]); - voice->Send[i].Channels = SendSlots[i]->WetBuffer.size(); + voice->mSend[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]); + voice->mSend[i].Channels = SendSlots[i]->WetBuffer.size(); } } @@ -1368,16 +1364,16 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A /* Adjust pitch based on the buffer and output frequencies, and calculate * fixed-point stepping value. */ - Pitch *= static_cast<ALfloat>(voice->Frequency)/static_cast<ALfloat>(Device->Frequency); + Pitch *= static_cast<ALfloat>(voice->mFrequency)/static_cast<ALfloat>(Device->Frequency); if(Pitch > static_cast<ALfloat>(MAX_PITCH)) - voice->Step = MAX_PITCH<<FRACTIONBITS; + voice->mStep = MAX_PITCH<<FRACTIONBITS; else - voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1); + voice->mStep = maxi(fastf2i(Pitch * FRACTIONONE), 1); if(props->mResampler == BSinc24Resampler) - BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc24); + BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc24); else if(props->mResampler == BSinc12Resampler) - BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc12); - voice->Resampler = SelectResampler(props->mResampler); + BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc12); + voice->mResampler = SelectResampler(props->mResampler); ALfloat spread{0.0f}; if(props->Radius > Distance) @@ -1392,21 +1388,21 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force) { - ALvoiceProps *props{voice->Update.exchange(nullptr, std::memory_order_acq_rel)}; + ALvoiceProps *props{voice->mUpdate.exchange(nullptr, std::memory_order_acq_rel)}; if(!props && !force) return; if(props) { - voice->Props = *props; + voice->mProps = *props; AtomicReplaceHead(context->FreeVoiceProps, props); } - if(voice->Props.mSpatializeMode==SpatializeOn || - (voice->Props.mSpatializeMode==SpatializeAuto && voice->Channels==FmtMono)) - CalcAttnSourceParams(voice, &voice->Props, context); + if((voice->mProps.mSpatializeMode == SpatializeAuto && voice->mFmtChannels == FmtMono) || + voice->mProps.mSpatializeMode == SpatializeOn) + CalcAttnSourceParams(voice, &voice->mProps, context); else - CalcNonAttnSourceParams(voice, &voice->Props, context); + CalcNonAttnSourceParams(voice, &voice->mProps, context); } @@ -1425,7 +1421,7 @@ void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots) std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), [ctx,force](ALvoice *voice) -> void { - ALuint sid{voice->SourceID.load(std::memory_order_acquire)}; + ALuint sid{voice->mSourceID.load(std::memory_order_acquire)}; if(sid) CalcSourceParams(voice, ctx, force); } ); @@ -1455,10 +1451,10 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo) std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), [SamplesToDo,ctx](ALvoice *voice) -> void { - if(voice->PlayState.load(std::memory_order_acquire) == ALvoice::Stopped) + if(voice->mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped) return; - ALuint sid{voice->SourceID.load(std::memory_order_relaxed)}; - if(voice->Step < 1) return; + ALuint sid{voice->mSourceID.load(std::memory_order_relaxed)}; + if(voice->mStep < 1) return; MixSource(voice, sid, ctx, SamplesToDo); } @@ -1812,15 +1808,15 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) auto stop_voice = [ctx](ALvoice *voice) -> void { - if(voice->PlayState.load(std::memory_order_acquire) == ALvoice::Playing) + if(voice->mPlayState.load(std::memory_order_acquire) == ALvoice::Playing) return; - ALuint sid{voice->SourceID.load(std::memory_order_relaxed)}; + ALuint sid{voice->mSourceID.load(std::memory_order_relaxed)}; if(!sid) return; - voice->current_buffer.store(nullptr, std::memory_order_relaxed); - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->SourceID.store(0u, std::memory_order_relaxed); - voice->PlayState.store(ALvoice::Stopped, std::memory_order_release); + voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mSourceID.store(0u, std::memory_order_relaxed); + voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); /* If the source's voice was playing, it's now effectively stopped * (the source state will be updated the next time it's checked). */ diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index 4c8b2761..c2b2791b 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -449,15 +449,15 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const ASSUME(SamplesToDo > 0); /* Get source info */ - ALvoice::State vstate{voice->PlayState.load(std::memory_order_acquire)}; - const bool isstatic{(voice->Flags&VOICE_IS_STATIC) != 0}; - ALsizei DataPosInt{static_cast<ALsizei>(voice->position.load(std::memory_order_relaxed))}; - ALsizei DataPosFrac{voice->position_fraction.load(std::memory_order_relaxed)}; - ALbufferlistitem *BufferListItem{voice->current_buffer.load(std::memory_order_relaxed)}; - ALbufferlistitem *BufferLoopItem{voice->loop_buffer.load(std::memory_order_relaxed)}; - const ALsizei NumChannels{voice->NumChannels}; - const ALsizei SampleSize{voice->SampleSize}; - const ALint increment{voice->Step}; + ALvoice::State vstate{voice->mPlayState.load(std::memory_order_acquire)}; + const bool isstatic{(voice->mFlags&VOICE_IS_STATIC) != 0}; + ALsizei DataPosInt{static_cast<ALsizei>(voice->mPosition.load(std::memory_order_relaxed))}; + ALsizei DataPosFrac{voice->mPositionFrac.load(std::memory_order_relaxed)}; + ALbufferlistitem *BufferListItem{voice->mCurrentBuffer.load(std::memory_order_relaxed)}; + ALbufferlistitem *BufferLoopItem{voice->mLoopBuffer.load(std::memory_order_relaxed)}; + const ALsizei NumChannels{voice->mNumChannels}; + const ALsizei SampleSize{voice->mSampleSize}; + const ALint increment{voice->mStep}; ASSUME(DataPosInt >= 0); ASSUME(DataPosFrac >= 0); @@ -473,16 +473,16 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const ASSUME(IrSize >= 0); ResamplerFunc Resample{(increment == FRACTIONONE && DataPosFrac == 0) ? - Resample_<CopyTag,CTag> : voice->Resampler}; + Resample_<CopyTag,CTag> : voice->mResampler}; - ALsizei Counter{(voice->Flags&VOICE_IS_FADING) ? SamplesToDo : 0}; + ALsizei Counter{(voice->mFlags&VOICE_IS_FADING) ? SamplesToDo : 0}; if(!Counter) { /* No fading, just overwrite the old/current params. */ for(ALsizei chan{0};chan < NumChannels;chan++) { - DirectParams &parms = voice->Direct.Params[chan]; - if(!(voice->Flags&VOICE_HAS_HRTF)) + DirectParams &parms = voice->mDirect.Params[chan]; + if(!(voice->mFlags&VOICE_HAS_HRTF)) std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), std::begin(parms.Gains.Current)); else @@ -496,14 +496,14 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), std::begin(parms.Gains.Current)); }; - std::for_each(voice->Send.begin(), voice->Send.end(), set_current); + std::for_each(voice->mSend.begin(), voice->mSend.end(), set_current); } } - else if((voice->Flags&VOICE_HAS_HRTF)) + else if((voice->mFlags&VOICE_HAS_HRTF)) { for(ALsizei chan{0};chan < NumChannels;chan++) { - DirectParams &parms = voice->Direct.Params[chan]; + DirectParams &parms = voice->mDirect.Params[chan]; if(!(parms.Hrtf.Old.Gain > GAIN_SILENCE_THRESHOLD)) { /* The old HRTF params are silent, so overwrite the old @@ -557,16 +557,16 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const auto &SrcData = Device->SourceData; /* Load the previous samples into the source data first, and clear the rest. */ - auto srciter = std::copy_n(voice->PrevSamples[chan].begin(), MAX_RESAMPLE_PADDING, + auto srciter = std::copy_n(voice->mPrevSamples[chan].begin(), MAX_RESAMPLE_PADDING, std::begin(SrcData)); std::fill(srciter, std::end(SrcData), 0.0f); ALsizei FilledAmt{MAX_RESAMPLE_PADDING}; if(vstate != ALvoice::Playing) { - std::copy(voice->PrevSamples[chan].begin()+MAX_RESAMPLE_PADDING, - voice->PrevSamples[chan].end(), srciter); - FilledAmt = voice->PrevSamples[chan].size(); + std::copy(voice->mPrevSamples[chan].begin()+MAX_RESAMPLE_PADDING, + voice->mPrevSamples[chan].end(), srciter); + FilledAmt = voice->mPrevSamples[chan].size(); } else if(isstatic) { @@ -599,32 +599,33 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const /* Store the last source samples used for next time. */ std::copy_n(&SrcData[(increment*DstBufferSize + DataPosFrac)>>FRACTIONBITS], - voice->PrevSamples[chan].size(), std::begin(voice->PrevSamples[chan])); + voice->mPrevSamples[chan].size(), std::begin(voice->mPrevSamples[chan])); /* Resample, then apply ambisonic upsampling as needed. */ - const ALfloat *ResampledData{Resample(&voice->ResampleState, + const ALfloat *ResampledData{Resample(&voice->mResampleState, &SrcData[MAX_RESAMPLE_PADDING], DataPosFrac, increment, Device->ResampledData, DstBufferSize)}; - if((voice->Flags&VOICE_IS_AMBISONIC)) + if((voice->mFlags&VOICE_IS_AMBISONIC)) { - const ALfloat hfscale{voice->AmbiScales[chan]}; + const ALfloat hfscale{voice->mAmbiScales[chan]}; /* Beware the evil const_cast. It's safe since it's pointing to * either SrcData or Device->ResampledData (both non-const), * but the resample method takes its input as const float* and * may return it without copying to output, making it currently * unavoidable. */ - voice->AmbiSplitter[chan].applyHfScale(const_cast<ALfloat*>(ResampledData), + voice->mAmbiSplitter[chan].applyHfScale(const_cast<ALfloat*>(ResampledData), hfscale, DstBufferSize); } /* Now filter and mix to the appropriate outputs. */ { - DirectParams &parms = voice->Direct.Params[chan]; + DirectParams &parms = voice->mDirect.Params[chan]; const ALfloat *samples{DoFilters(&parms.LowPass, &parms.HighPass, - Device->FilteredData, ResampledData, DstBufferSize, voice->Direct.FilterType)}; + Device->FilteredData, ResampledData, DstBufferSize, + voice->mDirect.FilterType)}; - if((voice->Flags&VOICE_HAS_HRTF)) + if((voice->mFlags&VOICE_HAS_HRTF)) { const ALfloat TargetGain{UNLIKELY(vstate == ALvoice::Stopping) ? 0.0f : parms.Hrtf.Target.Gain}; @@ -658,8 +659,8 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix); MixHrtfBlendSamples( - voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx], - samples, voice->Offset, OutPos, IrSize, &parms.Hrtf.Old, + voice->mDirect.Buffer[OutLIdx], voice->mDirect.Buffer[OutRIdx], + samples, voice->mOffset, OutPos, IrSize, &parms.Hrtf.Old, &hrtfparams, &parms.Hrtf.State, fademix); /* Update the old parameters with the result. */ parms.Hrtf.Old = parms.Hrtf.Target; @@ -692,8 +693,8 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast<ALfloat>(todo); MixHrtfSamples( - voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx], - samples+fademix, voice->Offset+fademix, OutPos+fademix, IrSize, + voice->mDirect.Buffer[OutLIdx], voice->mDirect.Buffer[OutRIdx], + samples+fademix, voice->mOffset+fademix, OutPos+fademix, IrSize, &hrtfparams, &parms.Hrtf.State, todo); /* Store the interpolated gain or the final target gain * depending if the fade is done. @@ -704,27 +705,27 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const parms.Hrtf.Old.Gain = parms.Hrtf.Target.Gain; } } - else if((voice->Flags&VOICE_HAS_NFC)) + else if((voice->mFlags&VOICE_HAS_NFC)) { const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? SilentTarget : parms.Gains.Target}; - MixSamples(samples, voice->Direct.ChannelsPerOrder[0], - voice->Direct.Buffer, parms.Gains.Current, TargetGains, Counter, + MixSamples(samples, voice->mDirect.ChannelsPerOrder[0], + voice->mDirect.Buffer, parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize); ALfloat (&nfcsamples)[BUFFERSIZE] = Device->NfcSampleData; - ALsizei chanoffset{voice->Direct.ChannelsPerOrder[0]}; + ALsizei chanoffset{voice->mDirect.ChannelsPerOrder[0]}; using FilterProc = void (NfcFilter::*)(float*,const float*,int); auto apply_nfc = [voice,&parms,samples,TargetGains,DstBufferSize,Counter,OutPos,&chanoffset,&nfcsamples](FilterProc process, ALsizei order) -> void { - if(voice->Direct.ChannelsPerOrder[order] < 1) + if(voice->mDirect.ChannelsPerOrder[order] < 1) return; (parms.NFCtrlFilter.*process)(nfcsamples, samples, DstBufferSize); - MixSamples(nfcsamples, voice->Direct.ChannelsPerOrder[order], - voice->Direct.Buffer+chanoffset, parms.Gains.Current+chanoffset, + MixSamples(nfcsamples, voice->mDirect.ChannelsPerOrder[order], + voice->mDirect.Buffer+chanoffset, parms.Gains.Current+chanoffset, TargetGains+chanoffset, Counter, OutPos, DstBufferSize); - chanoffset += voice->Direct.ChannelsPerOrder[order]; + chanoffset += voice->mDirect.ChannelsPerOrder[order]; }; apply_nfc(&NfcFilter::process1, 1); apply_nfc(&NfcFilter::process2, 2); @@ -734,7 +735,7 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const { const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? SilentTarget : parms.Gains.Target}; - MixSamples(samples, voice->Direct.Channels, voice->Direct.Buffer, + MixSamples(samples, voice->mDirect.Channels, voice->mDirect.Buffer, parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize); } } @@ -754,7 +755,7 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const MixSamples(samples, send.Channels, send.Buffer, parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize); }; - std::for_each(voice->Send.begin(), voice->Send.end(), mix_send); + std::for_each(voice->mSend.begin(), voice->mSend.end(), mix_send); } /* Update positions */ DataPosFrac += increment*DstBufferSize; @@ -762,7 +763,7 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const DataPosFrac &= FRACTIONMASK; OutPos += DstBufferSize; - voice->Offset += DstBufferSize; + voice->mOffset += DstBufferSize; Counter = maxi(DstBufferSize, Counter) - DstBufferSize; if(UNLIKELY(vstate != ALvoice::Playing)) @@ -812,23 +813,23 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const } } while(OutPos < SamplesToDo); - voice->Flags |= VOICE_IS_FADING; + voice->mFlags |= VOICE_IS_FADING; /* Don't update positions and buffers if we were stopping. */ if(UNLIKELY(vstate == ALvoice::Stopping)) { - voice->PlayState.store(ALvoice::Stopped, std::memory_order_release); + voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); return; } /* Update source info */ - voice->position.store(DataPosInt, std::memory_order_relaxed); - voice->position_fraction.store(DataPosFrac, std::memory_order_relaxed); - voice->current_buffer.store(BufferListItem, std::memory_order_relaxed); + voice->mPosition.store(DataPosInt, std::memory_order_relaxed); + voice->mPositionFrac.store(DataPosFrac, std::memory_order_relaxed); + voice->mCurrentBuffer.store(BufferListItem, std::memory_order_relaxed); if(vstate == ALvoice::Stopped) { - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->SourceID.store(0u, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mSourceID.store(0u, std::memory_order_relaxed); } std::atomic_thread_fence(std::memory_order_release); @@ -853,7 +854,7 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const /* If the voice just ended, set it to Stopping so the next render * ensures any residual noise fades to 0 amplitude. */ - voice->PlayState.store(ALvoice::Stopping, std::memory_order_release); + voice->mPlayState.store(ALvoice::Stopping, std::memory_order_release); SendSourceStoppedEvent(Context, SourceID); } } diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 2b2432c4..1de184cb 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -213,51 +213,51 @@ struct ALvoice { Stopping = 2 }; - std::atomic<ALvoiceProps*> Update{nullptr}; + std::atomic<ALvoiceProps*> mUpdate{nullptr}; - std::atomic<ALuint> SourceID{0u}; - std::atomic<State> PlayState{Stopped}; + std::atomic<ALuint> mSourceID{0u}; + std::atomic<State> mPlayState{Stopped}; - ALvoicePropsBase Props; + ALvoicePropsBase mProps; /** * Source offset in samples, relative to the currently playing buffer, NOT - * the whole queue, and the fractional (fixed-point) offset to the next - * sample. + * the whole queue. */ - std::atomic<ALuint> position; - std::atomic<ALsizei> position_fraction; + std::atomic<ALuint> mPosition; + /** Fractional (fixed-point) offset to the next sample. */ + std::atomic<ALsizei> mPositionFrac; /* Current buffer queue item being played. */ - std::atomic<ALbufferlistitem*> current_buffer; + std::atomic<ALbufferlistitem*> mCurrentBuffer; /* Buffer queue item to loop to at end of queue (will be NULL for non- * looping voices). */ - std::atomic<ALbufferlistitem*> loop_buffer; + std::atomic<ALbufferlistitem*> mLoopBuffer; /* Properties for the attached buffer(s). */ - FmtChannels Channels; - ALuint Frequency; - ALsizei NumChannels; - ALsizei SampleSize; + FmtChannels mFmtChannels; + ALuint mFrequency; + ALsizei mNumChannels; + ALsizei mSampleSize; /** Current target parameters used for mixing. */ - ALint Step; + ALint mStep; - ResamplerFunc Resampler; + ResamplerFunc mResampler; - ALuint Flags; + ALuint mFlags; - ALuint Offset; /* Number of output samples mixed since starting. */ + ALuint mOffset; /* Number of output samples mixed since starting. */ using ResamplePaddingArray = std::array<ALfloat,MAX_RESAMPLE_PADDING*2>; - alignas(16) std::array<ResamplePaddingArray,MAX_INPUT_CHANNELS> PrevSamples; + alignas(16) std::array<ResamplePaddingArray,MAX_INPUT_CHANNELS> mPrevSamples; - InterpState ResampleState; + InterpState mResampleState; - std::array<ALfloat,MAX_INPUT_CHANNELS> AmbiScales; - BandSplitter AmbiSplitter[MAX_INPUT_CHANNELS]; + std::array<ALfloat,MAX_INPUT_CHANNELS> mAmbiScales; + BandSplitter mAmbiSplitter[MAX_INPUT_CHANNELS]; struct { int FilterType; @@ -266,7 +266,7 @@ struct ALvoice { ALfloat (*Buffer)[BUFFERSIZE]; ALsizei Channels; ALsizei ChannelsPerOrder[MAX_AMBI_ORDER+1]; - } Direct; + } mDirect; struct SendData { int FilterType; @@ -275,16 +275,16 @@ struct ALvoice { ALfloat (*Buffer)[BUFFERSIZE]; ALsizei Channels; }; - al::FlexArray<SendData> Send; + al::FlexArray<SendData> mSend; - ALvoice(size_t numsends) : Send{numsends} { } + ALvoice(size_t numsends) : mSend{numsends} { } ALvoice(const ALvoice&) = delete; ALvoice& operator=(const ALvoice&) = delete; static constexpr size_t Sizeof(size_t numsends) noexcept { return maxz(sizeof(ALvoice), - al::FlexArray<SendData>::Sizeof(numsends, offsetof(ALvoice, Send))); + al::FlexArray<SendData>::Sizeof(numsends, offsetof(ALvoice, mSend))); } }; diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index ed0b813f..17fbcb03 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -61,7 +61,7 @@ inline ALvoice *GetSourceVoice(ALsource *source, ALCcontext *context) { ALuint sid{source->id}; ALvoice *voice{context->Voices[idx]}; - if(voice->SourceID.load(std::memory_order_acquire) == sid) + if(voice->mSourceID.load(std::memory_order_acquire) == sid) return voice; } source->VoiceIdx = -1; @@ -138,7 +138,7 @@ void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *conte std::transform(source->Send.cbegin(), source->Send.cend(), props->Send, copy_send); /* Set the new container for updating internal parameters. */ - props = voice->Update.exchange(props, std::memory_order_acq_rel); + props = voice->mUpdate.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the @@ -173,10 +173,10 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono voice = GetSourceVoice(Source, context); if(voice) { - Current = voice->current_buffer.load(std::memory_order_relaxed); + Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); - readPos = uint64_t{voice->position.load(std::memory_order_relaxed)} << 32; - readPos |= int64_t{voice->position_fraction.load(std::memory_order_relaxed)} << + readPos = uint64_t{voice->mPosition.load(std::memory_order_relaxed)} << 32; + readPos |= int64_t{voice->mPositionFrac.load(std::memory_order_relaxed)} << (32-FRACTIONBITS); } std::atomic_thread_fence(std::memory_order_acquire); @@ -219,10 +219,10 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono:: voice = GetSourceVoice(Source, context); if(voice) { - Current = voice->current_buffer.load(std::memory_order_relaxed); + Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); - readPos = uint64_t{voice->position.load(std::memory_order_relaxed)} << FRACTIONBITS; - readPos |= voice->position_fraction.load(std::memory_order_relaxed); + readPos = uint64_t{voice->mPosition.load(std::memory_order_relaxed)} << FRACTIONBITS; + readPos |= voice->mPositionFrac.load(std::memory_order_relaxed); } std::atomic_thread_fence(std::memory_order_acquire); } while(refcount != device->MixCount.load(std::memory_order_relaxed)); @@ -278,10 +278,10 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) voice = GetSourceVoice(Source, context); if(voice) { - Current = voice->current_buffer.load(std::memory_order_relaxed); + Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); - readPos = voice->position.load(std::memory_order_relaxed); - readPosFrac = voice->position_fraction.load(std::memory_order_relaxed); + readPos = voice->mPosition.load(std::memory_order_relaxed); + readPosFrac = voice->mPositionFrac.load(std::memory_order_relaxed); } std::atomic_thread_fence(std::memory_order_acquire); } while(refcount != device->MixCount.load(std::memory_order_relaxed)); @@ -448,9 +448,9 @@ ALboolean ApplyOffset(ALsource *Source, ALvoice *voice) if(static_cast<ALuint>(BufferList->max_samples) > offset-totalBufferLen) { /* Offset is in this buffer */ - voice->position.store(offset - totalBufferLen, std::memory_order_relaxed); - voice->position_fraction.store(frac, std::memory_order_relaxed); - voice->current_buffer.store(BufferList, std::memory_order_release); + voice->mPosition.store(offset - totalBufferLen, std::memory_order_relaxed); + voice->mPositionFrac.store(frac, std::memory_order_relaxed); + voice->mCurrentBuffer.store(BufferList, std::memory_order_release); return AL_TRUE; } totalBufferLen += BufferList->max_samples; @@ -531,15 +531,15 @@ void FreeSource(ALCcontext *context, ALsource *source) BackendUniqueLock backlock{*device->Backend}; if(ALvoice *voice{GetSourceVoice(source, context)}) { - voice->current_buffer.store(nullptr, std::memory_order_relaxed); - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->SourceID.store(0u, std::memory_order_relaxed); + voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mSourceID.store(0u, std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_release); /* Don't set the voice to stopping if it was already stopped or * stopping. */ ALvoice::State oldvstate{ALvoice::Playing}; - voice->PlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, + voice->mPlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, std::memory_order_acq_rel, std::memory_order_acquire); } backlock.unlock(); @@ -1248,9 +1248,9 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co if(voice) { if(Source->Looping) - voice->loop_buffer.store(Source->queue, std::memory_order_release); + voice->mLoopBuffer.store(Source->queue, std::memory_order_release); else - voice->loop_buffer.store(nullptr, std::memory_order_release); + voice->mLoopBuffer.store(nullptr, std::memory_order_release); /* If the source is playing, wait for the current mix to finish * to ensure it isn't currently looping back or reaching the @@ -1864,7 +1864,7 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL ALvoice *voice{GetSourceVoice(Source, Context)}; if(voice != nullptr) - Current = voice->current_buffer.load(std::memory_order_relaxed); + Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); else if(Source->state == AL_INITIAL) Current = BufferList; @@ -2731,8 +2731,8 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) auto free_voices = std::accumulate(context->Voices, voices_end, ALsizei{0}, [](const ALsizei count, const ALvoice *voice) noexcept -> ALsizei { - if(voice->PlayState.load(std::memory_order_acquire) == ALvoice::Stopped && - voice->SourceID.load(std::memory_order_relaxed) == 0u) + if(voice->mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped && + voice->mSourceID.load(std::memory_order_relaxed) == 0u) return count + 1; return count; } @@ -2793,15 +2793,15 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) case AL_PLAYING: assert(voice != nullptr); /* A source that's already playing is restarted from the beginning. */ - voice->current_buffer.store(BufferList, std::memory_order_relaxed); - voice->position.store(0u, std::memory_order_relaxed); - voice->position_fraction.store(0, std::memory_order_release); + voice->mCurrentBuffer.store(BufferList, std::memory_order_relaxed); + voice->mPosition.store(0u, std::memory_order_relaxed); + voice->mPositionFrac.store(0, std::memory_order_release); return; case AL_PAUSED: assert(voice != nullptr); /* A source that's paused simply resumes. */ - voice->PlayState.store(ALvoice::Playing, std::memory_order_release); + voice->mPlayState.store(ALvoice::Playing, std::memory_order_release); source->state = AL_PLAYING; SendStateChangeEvent(context.get(), source->id, AL_PLAYING); return; @@ -2816,14 +2816,14 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) auto voice_iter = std::find_if(context->Voices, voices_end, [](const ALvoice *voice) noexcept -> bool { - return voice->PlayState.load(std::memory_order_acquire) == ALvoice::Stopped && - voice->SourceID.load(std::memory_order_relaxed) == 0u; + return voice->mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped && + voice->mSourceID.load(std::memory_order_relaxed) == 0u; } ); assert(voice_iter != voices_end); auto vidx = static_cast<ALint>(std::distance(context->Voices, voice_iter)); voice = *voice_iter; - voice->PlayState.store(ALvoice::Stopped, std::memory_order_release); + voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); source->PropsClean.test_and_set(std::memory_order_acquire); UpdateSourceProps(source, voice, context.get()); @@ -2832,56 +2832,56 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) * starts playing. */ if(source->Looping) - voice->loop_buffer.store(source->queue, std::memory_order_relaxed); + voice->mLoopBuffer.store(source->queue, std::memory_order_relaxed); else - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->current_buffer.store(BufferList, std::memory_order_relaxed); - voice->position.store(0u, std::memory_order_relaxed); - voice->position_fraction.store(0, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mCurrentBuffer.store(BufferList, std::memory_order_relaxed); + voice->mPosition.store(0u, std::memory_order_relaxed); + voice->mPositionFrac.store(0, std::memory_order_relaxed); bool start_fading{false}; if(ApplyOffset(source, voice) != AL_FALSE) - start_fading = voice->position.load(std::memory_order_relaxed) != 0 || - voice->position_fraction.load(std::memory_order_relaxed) != 0 || - voice->current_buffer.load(std::memory_order_relaxed) != BufferList; + start_fading = voice->mPosition.load(std::memory_order_relaxed) != 0 || + voice->mPositionFrac.load(std::memory_order_relaxed) != 0 || + voice->mCurrentBuffer.load(std::memory_order_relaxed) != BufferList; auto buffers_end = BufferList->buffers + BufferList->num_buffers; auto buffer = std::find_if(BufferList->buffers, buffers_end, std::bind(std::not_equal_to<const ALbuffer*>{}, _1, nullptr)); if(buffer != buffers_end) { - voice->Frequency = (*buffer)->Frequency; - voice->Channels = (*buffer)->mFmtChannels; - voice->NumChannels = ChannelsFromFmt((*buffer)->mFmtChannels); - voice->SampleSize = BytesFromFmt((*buffer)->mFmtType); + voice->mFrequency = (*buffer)->Frequency; + voice->mFmtChannels = (*buffer)->mFmtChannels; + voice->mNumChannels = ChannelsFromFmt((*buffer)->mFmtChannels); + voice->mSampleSize = BytesFromFmt((*buffer)->mFmtType); } /* Clear previous samples. */ - std::for_each(voice->PrevSamples.begin(), voice->PrevSamples.begin()+voice->NumChannels, + std::for_each(voice->mPrevSamples.begin(), voice->mPrevSamples.begin()+voice->mNumChannels, [](std::array<ALfloat,MAX_RESAMPLE_PADDING*2> &samples) -> void { std::fill(std::begin(samples), std::end(samples), 0.0f); }); /* Clear the stepping value so the mixer knows not to mix this until * the update gets applied. */ - voice->Step = 0; + voice->mStep = 0; - voice->Flags = start_fading ? VOICE_IS_FADING : 0; - if(source->SourceType == AL_STATIC) voice->Flags |= VOICE_IS_STATIC; + voice->mFlags = start_fading ? VOICE_IS_FADING : 0; + if(source->SourceType == AL_STATIC) voice->mFlags |= VOICE_IS_STATIC; /* Don't need to set the VOICE_IS_AMBISONIC flag if the device is * mixing in first order. No HF scaling is necessary to mix it. */ - if((voice->Channels == FmtBFormat2D || voice->Channels == FmtBFormat3D) && + if((voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtBFormat3D) && device->mAmbiOrder > 1) { auto scales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder); - if(voice->Channels == FmtBFormat2D) + if(voice->mFmtChannels == FmtBFormat2D) { static constexpr int Order2DFromChan[MAX_AMBI2D_CHANNELS]{ 0, 1,1, 2,2, 3,3 }; const size_t count{Ambi2DChannelsFromOrder(1u)}; - std::transform(Order2DFromChan, Order2DFromChan+count, voice->AmbiScales.begin(), + std::transform(Order2DFromChan, Order2DFromChan+count, voice->mAmbiScales.begin(), [&scales](size_t idx) -> ALfloat { return scales[idx]; }); } else @@ -2890,34 +2890,34 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3, }; const size_t count{Ambi2DChannelsFromOrder(1u)}; - std::transform(OrderFromChan, OrderFromChan+count, voice->AmbiScales.begin(), + std::transform(OrderFromChan, OrderFromChan+count, voice->mAmbiScales.begin(), [&scales](size_t idx) -> ALfloat { return scales[idx]; }); } - voice->AmbiSplitter[0].init(400.0f / static_cast<ALfloat>(device->Frequency)); - std::fill(std::begin(voice->AmbiSplitter)+1, - std::begin(voice->AmbiSplitter)+voice->NumChannels, voice->AmbiSplitter[0]); - voice->Flags |= VOICE_IS_AMBISONIC; + voice->mAmbiSplitter[0].init(400.0f / static_cast<ALfloat>(device->Frequency)); + std::fill_n(std::begin(voice->mAmbiSplitter)+1, voice->mNumChannels-1, + voice->mAmbiSplitter[0]); + voice->mFlags |= VOICE_IS_AMBISONIC; } - std::fill_n(std::begin(voice->Direct.Params), voice->NumChannels, DirectParams{}); - std::for_each(voice->Send.begin(), voice->Send.end(), + std::fill_n(std::begin(voice->mDirect.Params), voice->mNumChannels, DirectParams{}); + std::for_each(voice->mSend.begin(), voice->mSend.end(), [voice](ALvoice::SendData &send) -> void - { std::fill_n(std::begin(send.Params), voice->NumChannels, SendParams{}); } + { std::fill_n(std::begin(send.Params), voice->mNumChannels, SendParams{}); } ); if(device->AvgSpeakerDist > 0.0f) { ALfloat w1 = SPEEDOFSOUNDMETRESPERSEC / (device->AvgSpeakerDist * device->Frequency); - std::for_each(voice->Direct.Params+0, voice->Direct.Params+voice->NumChannels, + std::for_each(voice->mDirect.Params+0, voice->mDirect.Params+voice->mNumChannels, [w1](DirectParams &parms) noexcept -> void { parms.NFCtrlFilter.init(w1); } ); } - voice->SourceID.store(source->id, std::memory_order_relaxed); - voice->PlayState.store(ALvoice::Playing, std::memory_order_release); + voice->mSourceID.store(source->id, std::memory_order_relaxed); + voice->mPlayState.store(ALvoice::Playing, std::memory_order_release); source->state = AL_PLAYING; source->VoiceIdx = vidx; @@ -2956,7 +2956,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) { std::atomic_thread_fence(std::memory_order_release); ALvoice::State oldvstate{ALvoice::Playing}; - voice->PlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, + voice->mPlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, std::memory_order_acq_rel, std::memory_order_acquire); } if(GetSourceState(source, voice) == AL_PLAYING) @@ -2995,12 +2995,12 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) ALvoice *voice{GetSourceVoice(source, context.get())}; if(voice != nullptr) { - voice->current_buffer.store(nullptr, std::memory_order_relaxed); - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->SourceID.store(0u, std::memory_order_relaxed); + voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mSourceID.store(0u, std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_release); ALvoice::State oldvstate{ALvoice::Playing}; - voice->PlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, + voice->mPlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, std::memory_order_acq_rel, std::memory_order_acquire); voice = nullptr; } @@ -3043,12 +3043,12 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) ALvoice *voice{GetSourceVoice(source, context.get())}; if(voice != nullptr) { - voice->current_buffer.store(nullptr, std::memory_order_relaxed); - voice->loop_buffer.store(nullptr, std::memory_order_relaxed); - voice->SourceID.store(0u, std::memory_order_relaxed); + voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); + voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice->mSourceID.store(0u, std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_release); ALvoice::State oldvstate{ALvoice::Playing}; - voice->PlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, + voice->mPlayState.compare_exchange_strong(oldvstate, ALvoice::Stopping, std::memory_order_acq_rel, std::memory_order_acquire); voice = nullptr; } @@ -3313,7 +3313,7 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers(ALuint src, ALsizei nb, ALuint ALvoice *voice{GetSourceVoice(source, context.get())}; ALbufferlistitem *Current{nullptr}; if(voice) - Current = voice->current_buffer.load(std::memory_order_relaxed); + Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); else if(source->state == AL_INITIAL) Current = BufferList; if(UNLIKELY(BufferList == Current)) @@ -3482,7 +3482,7 @@ void UpdateAllSourceProps(ALCcontext *context) std::for_each(context->Voices, voices_end, [context](ALvoice *voice) -> void { - ALuint sid{voice->SourceID.load(std::memory_order_acquire)}; + ALuint sid{voice->mSourceID.load(std::memory_order_acquire)}; ALsource *source = sid ? LookupSource(context, sid) : nullptr; if(source && !source->PropsClean.test_and_set(std::memory_order_acq_rel)) UpdateSourceProps(source, voice, context); |