diff options
author | Be <be@mixxx.org> | 2020-04-04 17:34:39 -0500 |
---|---|---|
committer | Be <be@mixxx.org> | 2020-04-04 17:36:00 -0500 |
commit | e1acbb30c5fce4740f0ff7c0f1de7e75e814c56a (patch) | |
tree | 539a182bae79450fef79a2bb3a4f069344a7c2a4 /src/effects/effectchainslot.cpp | |
parent | 68d88ccb774031d1f3abc93b114f06b0b9d5b455 (diff) |
Effect(Chain)Slot: refactor creation of EffectStatesMaps
Diffstat (limited to 'src/effects/effectchainslot.cpp')
-rw-r--r-- | src/effects/effectchainslot.cpp | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/effects/effectchainslot.cpp b/src/effects/effectchainslot.cpp index bd8bdb560f..8395031e08 100644 --- a/src/effects/effectchainslot.cpp +++ b/src/effects/effectchainslot.cpp @@ -341,32 +341,17 @@ void EffectChainSlot::enableForInputChannel(const ChannelHandleAndGroup& handle_ // EffectStates are passed to the EffectRequest and the EffectProcessorImpls // store the pointers. The containers of EffectState* pointers get deleted // by ~EffectsRequest, but the EffectStates are managed by EffectProcessorImpl. - auto pEffectStatesMapArray = new EffectStatesMapArray; - //TODO: get actual configuration of engine - const mixxx::EngineParameters bufferParameters( - mixxx::AudioSignal::SampleRate(96000), - MAX_BUFFER_LEN / mixxx::kEngineChannelCount); + // The EffectStates for one EngineEffectChain must be sent all together in + // the same message using an EffectStatesMapArray. If they were separated + // into a message for each effect, there would be a chance that the + // EngineEffectChain could get activated in one cycle of the audio callback + // thread but the EffectStates for an EngineEffect would not be received by + // EngineEffectsManager until the next audio callback cycle. - // TODO: Simplify by defining a method to create an EffectState for the input channel + auto pEffectStatesMapArray = new EffectStatesMapArray; for (int i = 0; i < m_effectSlots.size(); ++i) { - auto& statesMap = (*pEffectStatesMapArray)[i]; - if (m_effectSlots[i]->isLoaded()) { - for (const auto& outputChannel : m_pEffectsManager->registeredOutputChannels()) { - if (kEffectDebugOutput) { - qDebug() << debugString() << "EffectChain::enableForInputChannel creating EffectState for input" << handle_group << "output" << outputChannel; - } - statesMap.insert(outputChannel.handle(), - m_effectSlots[i]->createState(bufferParameters)); - } - } else { - for (EffectState* pState : statesMap) { - if (pState != nullptr) { - delete pState; - } - } - statesMap.clear(); - } + m_effectSlots[i]->fillEffectStatesMap(&(*pEffectStatesMapArray)[i]); } request->EnableInputChannelForChain.pEffectStatesMapArray = pEffectStatesMapArray; |