Browse Source

Clear group connections before removing in internal patchbay mode

tags/1.9.6
falkTX 10 years ago
parent
commit
788314e4f9
4 changed files with 59 additions and 6 deletions
  1. +1
    -0
      source/backend/CarlaPlugin.hpp
  2. +56
    -6
      source/backend/engine/CarlaEngineGraph.cpp
  3. +1
    -0
      source/backend/engine/CarlaEngineGraph.hpp
  4. +1
    -0
      source/backend/plugin/CarlaPluginDSSI.cpp

+ 1
- 0
source/backend/CarlaPlugin.hpp View File

@@ -422,6 +422,7 @@ public:
* Set the plugin's id to @a newId.
*
* @see getId()
* @note RT call
*/
virtual void setId(const uint newId) noexcept;



+ 56
- 6
source/backend/engine/CarlaEngineGraph.cpp View File

@@ -1229,9 +1229,19 @@ void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* con
CARLA_SAFE_ASSERT_RETURN(oldPlugin != newPlugin,);
CARLA_SAFE_ASSERT_RETURN(oldPlugin->getId() == newPlugin->getId(),);

// FIXME
CarlaEngine* const engine(oldPlugin->getEngine());
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);

AudioProcessorGraph::Node* const oldNode(graph.getNodeForId(oldPlugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(oldNode != nullptr,);

if (! ignorePathbay)
{
disconnectGroup(engine, oldNode->nodeId);
removeNodeFromPatchbay(engine, oldNode->nodeId, oldNode->getProcessor());
}

graph.removeNode(oldPlugin->getPatchbayNodeId());
graph.removeNode(oldNode->nodeId);

CarlaPluginInstance* const instance(new CarlaPluginInstance(newPlugin));
AudioProcessorGraph::Node* const node(graph.addNode(instance));
@@ -1258,10 +1268,13 @@ void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);

if (! ignorePathbay)
removeNodeFromPatchbay(engine, plugin->getPatchbayNodeId(), node->getProcessor());
{
disconnectGroup(engine, node->nodeId);
removeNodeFromPatchbay(engine, node->nodeId, node->getProcessor());
}

// Fix plugin Ids properties
for (uint i=plugin->getId(), count=engine->getCurrentPluginCount(); i<count; ++i)
for (uint i=plugin->getId()+1, count=engine->getCurrentPluginCount(); i<count; ++i)
{
CarlaPlugin* const plugin2(engine->getPlugin(i));
CARLA_SAFE_ASSERT_BREAK(plugin2 != nullptr);
@@ -1269,11 +1282,11 @@ void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
if (AudioProcessorGraph::Node* const node2 = graph.getNodeForId(plugin2->getPatchbayNodeId()))
{
CARLA_SAFE_ASSERT_CONTINUE(node2->properties.getWithDefault("pluginId", -1) != juce::var(-1));
node2->properties.set("pluginId", static_cast<int>(plugin2->getId()));
node2->properties.set("pluginId", static_cast<int>(i-1));
}
}

CARLA_SAFE_ASSERT_RETURN(graph.removeNode(plugin->getPatchbayNodeId()),);
CARLA_SAFE_ASSERT_RETURN(graph.removeNode(node->nodeId),);
}

void PatchbayGraph::removeAllPlugins(CarlaEngine* const engine)
@@ -1290,7 +1303,10 @@ void PatchbayGraph::removeAllPlugins(CarlaEngine* const engine)
CARLA_SAFE_ASSERT_CONTINUE(node != nullptr);

if (! ignorePathbay)
{
disconnectGroup(engine, node->nodeId);
removeNodeFromPatchbay(engine, node->nodeId, node->getProcessor());
}

graph.removeNode(node->nodeId);
}
@@ -1363,6 +1379,39 @@ bool PatchbayGraph::disconnect(CarlaEngine* const engine, const uint connectionI
return false;
}

void PatchbayGraph::disconnectGroup(CarlaEngine* const engine, const uint groupId) noexcept
{
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);

for (LinkedList<ConnectionToId>::Itenerator it=connections.list.begin(); it.valid(); it.next())
{
static const ConnectionToId fallback = { 0, 0, 0, 0, 0 };

const ConnectionToId& connectionToId(it.getValue(fallback));
CARLA_SAFE_ASSERT_CONTINUE(connectionToId.id != 0);

if (connectionToId.groupA != groupId && connectionToId.groupB != groupId)
continue;

/*
uint adjustedPortA = connectionToId.portA;
uint adjustedPortB = connectionToId.portB;

if (! adjustPatchbayPortIdForJuce(adjustedPortA))
return false;
if (! adjustPatchbayPortIdForJuce(adjustedPortB))
return false;

graph.removeConnection(connectionToId.groupA, static_cast<int>(adjustedPortA),
connectionToId.groupB, static_cast<int>(adjustedPortB));
*/

engine->callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connectionToId.id, 0, 0, 0.0f, nullptr);

connections.list.remove(it);
}
}

void PatchbayGraph::clearConnections()
{
connections.clear();
@@ -1376,6 +1425,7 @@ void PatchbayGraph::refreshConnections(CarlaEngine* const engine)
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);

connections.clear();
graph.removeIllegalConnections();

for (int i=0, count=graph.getNumNodes(); i<count; ++i)
{


+ 1
- 0
source/backend/engine/CarlaEngineGraph.hpp View File

@@ -137,6 +137,7 @@ struct PatchbayGraph {

bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept;
void disconnectGroup(CarlaEngine* const engine, const uint groupId) noexcept;
void clearConnections();
void refreshConnections(CarlaEngine* const engine);



+ 1
- 0
source/backend/plugin/CarlaPluginDSSI.cpp View File

@@ -513,6 +513,7 @@ public:
CarlaPlugin::setId(newId);

// UI osc-url uses Id, so we need to close it when it changes
// FIXME - must be RT safe
showCustomUI(false);
}



Loading…
Cancel
Save