From b3fd9318dca6cbb991e8cc8d83d7a6b8ebd30cbd Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 26 Aug 2014 03:44:38 +0100 Subject: [PATCH] Ignore internal patchbay changes when in external mode --- source/backend/engine/CarlaEngineGraph.cpp | 23 +++++++++++++++---- source/backend/engine/CarlaEngineGraph.hpp | 1 + source/backend/engine/CarlaEngineInternal.hpp | 2 ++ source/backend/engine/CarlaEngineJack.cpp | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index d43e8312e..1ac17e28a 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -1110,6 +1110,7 @@ PatchbayGraph::PatchbayGraph(const int bufferSize, const double sampleRate, cons midiBuffer(), inputs(carla_fixValue(0U, MAX_PATCHBAY_PLUGINS-2, ins)), outputs(carla_fixValue(0U, MAX_PATCHBAY_PLUGINS-2, outs)), + ignorePathbay(false), retCon() { graph.setPlayConfigDetails(static_cast(inputs), static_cast(outputs), sampleRate, bufferSize); @@ -1197,7 +1198,8 @@ void PatchbayGraph::addPlugin(CarlaPlugin* const plugin) node->properties.set("isPlugin", true); node->properties.set("pluginId", static_cast(plugin->getId())); - addNodeToPatchbay(plugin->getEngine(), node->nodeId, static_cast(plugin->getId()), instance); + if (! ignorePathbay) + addNodeToPatchbay(plugin->getEngine(), node->nodeId, static_cast(plugin->getId()), instance); } void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin) @@ -1220,7 +1222,8 @@ void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* con node->properties.set("isPlugin", true); node->properties.set("pluginId", static_cast(newPlugin->getId())); - addNodeToPatchbay(newPlugin->getEngine(), node->nodeId, static_cast(newPlugin->getId()), instance); + if (! ignorePathbay) + addNodeToPatchbay(newPlugin->getEngine(), node->nodeId, static_cast(newPlugin->getId()), instance); } void PatchbayGraph::removePlugin(CarlaPlugin* const plugin) @@ -1234,7 +1237,8 @@ void PatchbayGraph::removePlugin(CarlaPlugin* const plugin) AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId())); CARLA_SAFE_ASSERT_RETURN(node != nullptr,); - removeNodeFromPatchbay(engine, plugin->getPatchbayNodeId(), node->getProcessor()); + if (! ignorePathbay) + removeNodeFromPatchbay(engine, plugin->getPatchbayNodeId(), node->getProcessor()); // Fix plugin Ids properties for (uint i=plugin->getId(), count=engine->getCurrentPluginCount(); igetPatchbayNodeId())); CARLA_SAFE_ASSERT_CONTINUE(node != nullptr); - removeNodeFromPatchbay(engine, node->nodeId, node->getProcessor()); + if (! ignorePathbay) + removeNodeFromPatchbay(engine, node->nodeId, node->getProcessor()); + graph.removeNode(node->nodeId); } } @@ -1361,7 +1367,8 @@ void PatchbayGraph::refreshConnections(CarlaEngine* const engine) if (node->properties.getWithDefault("isPlugin", false) == juce::var(true)) clientId = node->properties.getWithDefault("pluginId", -1); - addNodeToPatchbay(engine, node->nodeId, clientId, proc); + if (! ignorePathbay) + addNodeToPatchbay(engine, node->nodeId, clientId, proc); } char strBuf[STR_MAX+1]; @@ -1709,6 +1716,12 @@ void EngineInternalGraph::removeAllPlugins(CarlaEngine* const engine) fPatchbay->removeAllPlugins(engine); } +void EngineInternalGraph::setIgnorePatchbay(const bool ignore) noexcept +{ + CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,); + fPatchbay->ignorePathbay = ignore; +} + // ----------------------------------------------------------------------- // CarlaEngine Patchbay stuff diff --git a/source/backend/engine/CarlaEngineGraph.hpp b/source/backend/engine/CarlaEngineGraph.hpp index c73eee0ba..b3410a2ab 100644 --- a/source/backend/engine/CarlaEngineGraph.hpp +++ b/source/backend/engine/CarlaEngineGraph.hpp @@ -119,6 +119,7 @@ struct PatchbayGraph { MidiBuffer midiBuffer; const uint32_t inputs; const uint32_t outputs; + bool ignorePathbay; mutable CharStringListPtr retCon; PatchbayGraph(const int bufferSize, const double sampleRate, const uint32_t inputs, const uint32_t outputs); diff --git a/source/backend/engine/CarlaEngineInternal.hpp b/source/backend/engine/CarlaEngineInternal.hpp index 6b3217b13..571a3129d 100644 --- a/source/backend/engine/CarlaEngineInternal.hpp +++ b/source/backend/engine/CarlaEngineInternal.hpp @@ -83,6 +83,8 @@ public: void removePlugin(CarlaPlugin* const plugin); void removeAllPlugins(CarlaEngine* const engine); + void setIgnorePatchbay(const bool ignore) noexcept; + private: bool fIsRack; bool fIsReady; diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 53070e4b1..2b6cc1383 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -1112,6 +1112,7 @@ public: if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY) { fExternalPatchbay = external; + pData->graph.setIgnorePatchbay(external); if (! external) return CarlaEngine::patchbayRefresh(false);