diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 61 | ||||
-rw-r--r-- | Alc/alu.cpp | 216 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 103 |
3 files changed, 188 insertions, 192 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); } } |