Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when loading plugin state in iOS GarageBand #251

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/chowdsp_utils
Submodule chowdsp_utils updated 276 files
2 changes: 1 addition & 1 deletion src/BYOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BYOD::BYOD() : chowdsp::PluginBase<BYOD> (&undoManager),
Logger::writeToLog (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (*this));

pluginSettings->initialise (settingsFilePath);
procs = std::make_unique<ProcessorChain> (procStore, vts, presetManager, [&] (int l)
procs = std::make_unique<ProcessorChain> (procStore, vts, presetManager, paramForwarder, [&] (int l)
{ updateSampleLatency (l); });
paramForwarder = std::make_unique<ParamForwardManager> (vts, *procs);
presetManager = std::make_unique<PresetManager> (procs.get(), vts);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/utils/HostContextProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ ReturnType HostContextProvider::doForParameterOrForwardedParameter (const Ranged
std::unique_ptr<HostProvidedContextMenu> HostContextProvider::getContextMenuForParameter (const RangedAudioParameter& param) const
{
return doForParameterOrForwardedParameter (param,
[this] (auto& p) -> std::unique_ptr<HostProvidedContextMenu> {
[this] (auto& p) -> std::unique_ptr<HostProvidedContextMenu>
{
return chowdsp::HostContextProvider::getContextMenuForParameter (p);
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/headless/tests/PresetsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 10 additions & 8 deletions src/processors/chain/ProcessorChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ namespace
ProcessorChain::ProcessorChain (ProcessorStore& store,
AudioProcessorValueTreeState& vts,
std::unique_ptr<chowdsp::PresetManager>& presetMgr,
std::function<void (int)>&& latencyChangedCallback) : procStore (store),
um (vts.undoManager),
inputProcessor (um),
outputProcessor (um),
ioProcessor (vts, std::move (latencyChangedCallback)),
presetManager (presetMgr)
std::unique_ptr<ParamForwardManager>& paramForwarder,
std::function<void (int)>&& latencyChangedCallback)
: procStore (store),
um (vts.undoManager),
inputProcessor (um),
outputProcessor (um),
ioProcessor (vts, std::move (latencyChangedCallback)),
presetManager (presetMgr),
paramForwardManager (paramForwarder)
{
actionHelper = std::make_unique<ProcessorChainActionHelper> (*this);
stateHelper = std::make_unique<ProcessorChainStateHelper> (*this, mainThreadAction);
Expand Down Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions src/processors/chain/ProcessorChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<chowdsp::PresetManager>& presetMgr,
std::unique_ptr<ParamForwardManager>& paramForwardManager,
std::function<void (int)>&& latencyChangedCallback);
~ProcessorChain() override;

Expand Down Expand Up @@ -73,6 +75,7 @@ class ProcessorChain : private AudioProcessorValueTreeState::Listener
std::unique_ptr<ProcessorChainPortMagnitudesHelper> portMagsHelper;

chowdsp::DeferredAction mainThreadAction;
std::unique_ptr<ParamForwardManager>& paramForwardManager;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProcessorChain)
};
10 changes: 7 additions & 3 deletions src/processors/chain/ProcessorChainStateHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ProcessorChainStateHelper.h"
#include "ProcessorChainActions.h"
#include "state/ParamForwardManager.h"
#include "state/presets/PresetManager.h"

namespace
Expand Down Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -102,6 +104,8 @@ void ProcessorChainStateHelper::loadProcChainInternal (const XmlElement* xml,
bool loadingPreset,
Component* associatedComp)
{
ParamForwardManager::ScopedForceDeferHostNotifications scopedDeferNotifs { *chain.paramForwardManager };

if (! loadingPreset)
um->beginNewTransaction();

Expand Down
2 changes: 1 addition & 1 deletion src/processors/drive/junior_b/JuniorB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void JuniorB::processAudio (AudioBuffer<float>& 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();
Expand Down
3 changes: 1 addition & 2 deletions src/processors/modulation/phaser/Phaser4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/processors/modulation/phaser/Phaser8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down