diff options
author | Chris Robinson <[email protected]> | 2022-05-14 21:23:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-05-14 21:23:03 -0700 |
commit | 83238973ed08225adf03e76b6933e0c209f93fd9 (patch) | |
tree | 7e5a1d68cba91ae46cddaa7a2506a54eb4f3c19b /core/voice.cpp | |
parent | 0a57ebdd495149156736aea3e1aba4d2b3e55dd4 (diff) |
Use virtual functions for the decoder
Diffstat (limited to 'core/voice.cpp')
-rw-r--r-- | core/voice.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
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<UhjStereoDecoder>(); + else if(IsUHJ(mFmtChannels)) mDecoder = std::make_unique<UhjDecoder>(); - 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. |