diff options
author | Chris Robinson <[email protected]> | 2020-08-28 06:42:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-28 06:44:05 -0700 |
commit | 7266cd8b6c3a1f515d1bdb4c91e49e6994f72951 (patch) | |
tree | af589925c2456b3263095c020c68b3e8af558aab | |
parent | 52531d8b72e3d876b6692a8b72dfeccfd4ebcfb8 (diff) |
Don't dereference a null convolution filter
-rw-r--r-- | alc/effects/convolution.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 8acf6010..2700cb6e 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -138,7 +138,7 @@ struct ConvolutionState final : public EffectState { void NormalMix(const al::span<FloatBufferLine> samplesOut, const size_t samplesToDo); void UpsampleMix(const al::span<FloatBufferLine> samplesOut, const size_t samplesToDo); - void (ConvolutionState::*Mix)(const al::span<FloatBufferLine>,const size_t) + void (ConvolutionState::*mMix)(const al::span<FloatBufferLine>,const size_t) {&ConvolutionState::NormalMix}; void deviceUpdate(const ALCdevice *device) override; @@ -273,8 +273,10 @@ void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slo const EffectProps* /*props*/, const EffectTarget target) { mFilter = static_cast<ConvolutionFilter*>(slot->Params.mEffectBuffer); - mNumChannels = ChannelsFromFmt(mFilter->mChannels, mFilter->mAmbiOrder); - Mix = &ConvolutionState::NormalMix; + if(!mFilter) return; + + mNumChannels = mFilter ? ChannelsFromFmt(mFilter->mChannels, mFilter->mAmbiOrder) : 0u; + mMix = &ConvolutionState::NormalMix; /* The iFFT'd response is scaled up by the number of bins, so apply the * inverse to the output mixing gain. @@ -286,7 +288,7 @@ void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slo ALCdevice *device{context->mDevice.get()}; if(device->mAmbiOrder > mFilter->mAmbiOrder) { - Mix = &ConvolutionState::UpsampleMix; + mMix = &ConvolutionState::UpsampleMix; const auto scales = BFormatDec::GetHFOrderScales(mFilter->mAmbiOrder, device->mAmbiOrder); mOutChans[0].mHfScale = scales[0]; @@ -419,7 +421,7 @@ void ConvolutionState::process(const size_t samplesToDo, mFilter->mCurrentSegment = curseg; /* Finally, mix to the output. */ - (this->*Mix)(samplesOut, samplesToDo); + (this->*mMix)(samplesOut, samplesToDo); } |