Skip to content

Commit

Permalink
Fixing state loading for AAX
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Jul 29, 2023
1 parent 03317b2 commit fba57e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/state/StateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ StateManager::StateManager (AudioProcessorValueTreeState& vtState, ProcessorChai
: vts (vtState),
procChain (procs),
presetManager (presetMgr),
uiState (vts, GUIConstants::defaultWidth, GUIConstants::defaultHeight)
uiState (vts, GUIConstants::defaultWidth, GUIConstants::defaultHeight),
pluginWrapperType (vts.processor.wrapperType)
{
}

Expand Down Expand Up @@ -53,7 +54,9 @@ void StateManager::loadState (XmlElement* xmlState)

const auto [presetWasDirty, pluginVersion] = [&]
{
const MessageManagerLock mml;
std::optional<MessageManagerLock> mml {};
if (pluginWrapperType != AudioProcessor::WrapperType::wrapperType_AAX)
mml.emplace();
presetManager.loadXmlState (xmlState->getChildByName (chowdsp::PresetManager::presetStateTag));
const auto wasDirty = presetManager.getIsDirty();

Expand All @@ -63,11 +66,16 @@ void StateManager::loadState (XmlElement* xmlState)
return std::make_tuple (wasDirty, savedPluginVersion);
}();

WaitableEvent waiter;
procChain.getStateHelper().loadProcChain (procChainXml, pluginVersion, false, nullptr, &waiter);
waiter.wait (1000);
std::unique_ptr<WaitableEvent> waiter;
if (pluginWrapperType != AudioProcessor::WrapperType::wrapperType_AAX)
waiter = std::make_unique<WaitableEvent>();
procChain.getStateHelper().loadProcChain (procChainXml, pluginVersion, false, nullptr, waiter.get());
if (waiter != nullptr)
waiter->wait (1000);

const MessageManagerLock mml;
std::optional<MessageManagerLock> mml {};
if (pluginWrapperType != AudioProcessor::WrapperType::wrapperType_AAX)
mml.emplace();
presetManager.setIsDirty (presetWasDirty);

if (auto* um = vts.undoManager)
Expand Down
1 change: 1 addition & 0 deletions src/state/StateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StateManager
chowdsp::PresetManager& presetManager;

chowdsp::UIState uiState;
const juce::AudioProcessor::WrapperType pluginWrapperType;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StateManager)
};

0 comments on commit fba57e0

Please sign in to comment.