From 83238973ed08225adf03e76b6933e0c209f93fd9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 14 May 2022 21:23:03 -0700 Subject: Use virtual functions for the decoder --- core/voice.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'core/voice.cpp') diff --git a/core/voice.cpp b/core/voice.cpp index e269c4a9..48a2de51 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -637,8 +637,8 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo if(mDecoder) { SrcBufferSize = SrcBufferSize - PostPadding + MaxResamplerEdge; - ((*mDecoder).*mDecoderFunc)(MixingSamples, SrcBufferSize, - srcOffset * likely(vstate == Playing)); + mDecoder->decode(MixingSamples, SrcBufferSize, + likely(vstate == Playing) ? srcOffset : 0.0f); } /* Store the last source samples used for next time. */ if(likely(vstate == Playing)) @@ -853,17 +853,12 @@ void Voice::prepare(DeviceBase *device) mPrevSamples.reserve(maxu(2, num_channels)); mPrevSamples.resize(num_channels); - if(IsUHJ(mFmtChannels)) - { + if(mFmtChannels == FmtSuperStereo) + mDecoder = std::make_unique(); + else if(IsUHJ(mFmtChannels)) mDecoder = std::make_unique(); - mDecoderFunc = (mFmtChannels == FmtSuperStereo) ? &UhjDecoder::decodeStereo - : &UhjDecoder::decode; - } else - { mDecoder = nullptr; - mDecoderFunc = nullptr; - } /* Clear the stepping value explicitly so the mixer knows not to mix this * until the update gets applied. -- cgit v1.2.3