From e9dcfad9faa6cbe5df184551a2565a67dcd8c932 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 19 Dec 2022 23:23:33 -0800 Subject: [PATCH 1/2] Fix crash when loading plugin state in iOS GarageBand --- .github/workflows/auto-format.yml | 10 ++++------ modules/chowdsp_utils | 2 +- src/BYOD.cpp | 2 +- src/processors/chain/ProcessorChain.cpp | 18 ++++++++++-------- src/processors/chain/ProcessorChain.h | 3 +++ .../chain/ProcessorChainStateHelper.cpp | 10 +++++++--- src/processors/drive/junior_b/JuniorB.cpp | 2 +- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml index 80930fe2..2c48ebb4 100644 --- a/.github/workflows/auto-format.yml +++ b/.github/workflows/auto-format.yml @@ -20,11 +20,9 @@ jobs: steps: - name: Install Linux Deps run: | - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 12 - sudo apt-get install clang-format-12 - clang-format-12 --version + sudo apt update + sudo apt -y install clang-format-14 + clang-format-14 --version - name: Checkout code uses: actions/checkout@v2 @@ -34,7 +32,7 @@ jobs: - name: Run clang-format shell: bash - run: find src/ -iname *.h -o -iname *.cpp | xargs clang-format-12 -style=file -verbose -i + run: find src/ -iname *.h -o -iname *.cpp | xargs clang-format-14 -style=file -verbose -i - name: Commit & Push changes uses: actions-js/push@master diff --git a/modules/chowdsp_utils b/modules/chowdsp_utils index a1b3197b..9f2c640a 160000 --- a/modules/chowdsp_utils +++ b/modules/chowdsp_utils @@ -1 +1 @@ -Subproject commit a1b3197bb0852ae8e58d954f92be8d968ccb75ad +Subproject commit 9f2c640a50500ecc5d163e840d5199447ed62c82 diff --git a/src/BYOD.cpp b/src/BYOD.cpp index aa1a2c46..b9dae450 100644 --- a/src/BYOD.cpp +++ b/src/BYOD.cpp @@ -16,7 +16,7 @@ BYOD::BYOD() : chowdsp::PluginBase (&undoManager), Logger::writeToLog (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (*this)); pluginSettings->initialise (settingsFilePath); - procs = std::make_unique (procStore, vts, presetManager, [&] (int l) + procs = std::make_unique (procStore, vts, presetManager, paramForwarder, [&] (int l) { updateSampleLatency (l); }); paramForwarder = std::make_unique (vts, *procs); presetManager = std::make_unique (procs.get(), vts); diff --git a/src/processors/chain/ProcessorChain.cpp b/src/processors/chain/ProcessorChain.cpp index 7c0b1a09..9c7524d4 100644 --- a/src/processors/chain/ProcessorChain.cpp +++ b/src/processors/chain/ProcessorChain.cpp @@ -21,12 +21,15 @@ namespace ProcessorChain::ProcessorChain (ProcessorStore& store, AudioProcessorValueTreeState& vts, std::unique_ptr& presetMgr, - std::function&& latencyChangedCallback) : procStore (store), - um (vts.undoManager), - inputProcessor (um), - outputProcessor (um), - ioProcessor (vts, std::move (latencyChangedCallback)), - presetManager (presetMgr) + std::unique_ptr& paramForwarder, + std::function&& latencyChangedCallback) + : procStore (store), + um (vts.undoManager), + inputProcessor (um), + outputProcessor (um), + ioProcessor (vts, std::move (latencyChangedCallback)), + presetManager (presetMgr), + paramForwardManager (paramForwarder) { actionHelper = std::make_unique (*this); stateHelper = std::make_unique (*this, mainThreadAction); @@ -214,7 +217,6 @@ void ProcessorChain::parameterChanged (const juce::String& /*parameterID*/, floa jassert (presetManager != nullptr); if (! presetManager->getIsDirty()) - presetManager->setIsDirty (true); - }, + presetManager->setIsDirty (true); }, true); } diff --git a/src/processors/chain/ProcessorChain.h b/src/processors/chain/ProcessorChain.h index e3ccb93b..73d22ae1 100644 --- a/src/processors/chain/ProcessorChain.h +++ b/src/processors/chain/ProcessorChain.h @@ -9,12 +9,14 @@ class ProcessorChainActionHelper; class ProcessorChainPortMagnitudesHelper; class ProcessorChainStateHelper; +class ParamForwardManager; class ProcessorChain : private AudioProcessorValueTreeState::Listener { public: ProcessorChain (ProcessorStore& store, AudioProcessorValueTreeState& vts, std::unique_ptr& presetMgr, + std::unique_ptr& paramForwardManager, std::function&& latencyChangedCallback); ~ProcessorChain() override; @@ -73,6 +75,7 @@ class ProcessorChain : private AudioProcessorValueTreeState::Listener std::unique_ptr portMagsHelper; chowdsp::DeferredAction mainThreadAction; + std::unique_ptr& paramForwardManager; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProcessorChain) }; diff --git a/src/processors/chain/ProcessorChainStateHelper.cpp b/src/processors/chain/ProcessorChainStateHelper.cpp index a3892901..5ec8470a 100644 --- a/src/processors/chain/ProcessorChainStateHelper.cpp +++ b/src/processors/chain/ProcessorChainStateHelper.cpp @@ -1,5 +1,6 @@ #include "ProcessorChainStateHelper.h" #include "ProcessorChainActions.h" +#include "state/ParamForwardManager.h" #include "state/presets/PresetManager.h" namespace @@ -30,9 +31,10 @@ String getProcessorName (const String& tag) } } // namespace -ProcessorChainStateHelper::ProcessorChainStateHelper (ProcessorChain& thisChain, chowdsp::DeferredAction& deferredAction) : chain (thisChain), - um (chain.um), - mainThreadStateLoader (deferredAction) +ProcessorChainStateHelper::ProcessorChainStateHelper (ProcessorChain& thisChain, chowdsp::DeferredAction& deferredAction) + : chain (thisChain), + um (chain.um), + mainThreadStateLoader (deferredAction) { } @@ -102,6 +104,8 @@ void ProcessorChainStateHelper::loadProcChainInternal (const XmlElement* xml, bool loadingPreset, Component* associatedComp) { + ParamForwardManager::ScopedForceDeferHostNotifications scopedDeferNotifs { *chain.paramForwardManager }; + if (! loadingPreset) um->beginNewTransaction(); diff --git a/src/processors/drive/junior_b/JuniorB.cpp b/src/processors/drive/junior_b/JuniorB.cpp index 68d67df4..55a95391 100644 --- a/src/processors/drive/junior_b/JuniorB.cpp +++ b/src/processors/drive/junior_b/JuniorB.cpp @@ -69,7 +69,7 @@ void JuniorB::processAudio (AudioBuffer& buffer) const auto numSamples = buffer.getNumSamples(); dryBuffer.setCurrentSize (numChannels, numSamples); - chowdsp::BufferMath::copyBufferData (chowdsp::BufferView { buffer }, dryBuffer); + chowdsp::BufferMath::copyBufferData (buffer, dryBuffer); const auto drivePercent = driveParamPct->getCurrentValue(); const auto blendPercent = blendParamPct->getCurrentValue(); From daf3cd4dd55b34bc943994a8bccc3c280f3d7ee4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 20 Dec 2022 07:25:09 +0000 Subject: [PATCH 2/2] Apply clang-format --- src/gui/utils/HostContextProvider.cpp | 3 ++- src/headless/tests/PresetsTest.cpp | 3 +-- src/processors/modulation/phaser/Phaser4.cpp | 3 +-- src/processors/modulation/phaser/Phaser8.cpp | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/gui/utils/HostContextProvider.cpp b/src/gui/utils/HostContextProvider.cpp index c9477ec3..6e291d70 100644 --- a/src/gui/utils/HostContextProvider.cpp +++ b/src/gui/utils/HostContextProvider.cpp @@ -24,7 +24,8 @@ ReturnType HostContextProvider::doForParameterOrForwardedParameter (const Ranged std::unique_ptr HostContextProvider::getContextMenuForParameter (const RangedAudioParameter& param) const { return doForParameterOrForwardedParameter (param, - [this] (auto& p) -> std::unique_ptr { + [this] (auto& p) -> std::unique_ptr + { return chowdsp::HostContextProvider::getContextMenuForParameter (p); }); } diff --git a/src/headless/tests/PresetsTest.cpp b/src/headless/tests/PresetsTest.cpp index e6e46acc..0d122e1d 100644 --- a/src/headless/tests/PresetsTest.cpp +++ b/src/headless/tests/PresetsTest.cpp @@ -38,8 +38,7 @@ class PresetsTest : public UnitTest plugin.processBlock (buffer, midi); bufferCount++; } - waiter.signal(); - }); + waiter.signal(); }); int numPrograms = plugin.getNumPrograms(); for (int i = 0; i < numPrograms; ++i) diff --git a/src/processors/modulation/phaser/Phaser4.cpp b/src/processors/modulation/phaser/Phaser4.cpp index 6a1c035e..a5bfde6c 100644 --- a/src/processors/modulation/phaser/Phaser4.cpp +++ b/src/processors/modulation/phaser/Phaser4.cpp @@ -33,8 +33,7 @@ Phaser4::Phaser4 (UndoManager* um) : BaseProcessor ("Phaser4", lfoShaper.initialise ([] (float x) { static constexpr auto skewFactor = gcem::pow (2.0f, -0.5f); - return 2.0f * std::pow ((x + 1.0f) * 0.5f, skewFactor) - 1.0f; - }, + return 2.0f * std::pow ((x + 1.0f) * 0.5f, skewFactor) - 1.0f; }, -1.0f, 1.0f, 2048); diff --git a/src/processors/modulation/phaser/Phaser8.cpp b/src/processors/modulation/phaser/Phaser8.cpp index 75999e4e..f37ac4de 100644 --- a/src/processors/modulation/phaser/Phaser8.cpp +++ b/src/processors/modulation/phaser/Phaser8.cpp @@ -35,8 +35,7 @@ Phaser8::Phaser8 (UndoManager* um) : BaseProcessor ("Phaser8", lfoShaper.initialise ([] (float x) { static constexpr auto skewFactor = gcem::pow (2.0f, -0.25f); - return 2.0f * std::pow ((x + 1.0f) * 0.5f, skewFactor) - 1.0f; - }, + return 2.0f * std::pow ((x + 1.0f) * 0.5f, skewFactor) - 1.0f; }, -1.0f, 1.0f, 2048);