Skip to content

Commit b819945

Browse files
committed
Simplify ProcessorGraph::updateConnections
1 parent b3bb1a9 commit b819945

1 file changed

Lines changed: 21 additions & 46 deletions

File tree

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "../../UI/TimestampSourceSelection.h"
3737

3838
#include "../ProcessorManager/ProcessorManager.h"
39-
39+
4040
ProcessorGraph::ProcessorGraph() : currentNodeId(100)
4141
{
4242

@@ -293,58 +293,33 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
293293
std::cout << " NOT connecting to audio and record nodes." << std::endl;
294294
}
295295

296-
if (dest != nullptr)
296+
// find the next dest that's not a merger or splitter
297+
while (dest != nullptr && (dest->isMerger() || dest->isSplitter()))
297298
{
298-
299-
while (dest->isMerger()) // find the next dest that's not a merger
299+
if (dest->isSplitter() && !dest->wasConnected)
300300
{
301-
dest = dest->getDestNode();
302-
303-
if (dest == nullptr)
304-
break;
305-
}
306-
307-
if (dest != nullptr)
308-
{
309-
while (dest->isSplitter())
301+
if (!splitters.contains(dest))
310302
{
311-
if (!dest->wasConnected)
312-
{
313-
if (!splitters.contains(dest))
314-
{
315-
splitters.add(dest);
316-
dest->switchIO(0); // go down first path
317-
}
318-
else
319-
{
320-
int splitterIndex = splitters.indexOf(dest);
321-
splitters.remove(splitterIndex);
322-
dest->switchIO(1); // go down second path
323-
dest->wasConnected = true; // make sure we don't re-use this splitter
324-
}
325-
}
326-
327-
dest = dest->getDestNode();
328-
329-
if (dest == nullptr)
330-
break;
303+
splitters.add(dest);
304+
dest->switchIO(0); // go down first path
331305
}
332-
333-
if (dest != nullptr)
306+
else
334307
{
335-
336-
if (dest->isEnabledState())
337-
{
338-
connectProcessors(source, dest);
339-
}
308+
int splitterIndex = splitters.indexOf(dest);
309+
splitters.remove(splitterIndex);
310+
dest->switchIO(1); // go down second path
311+
dest->wasConnected = true; // make sure we don't re-use this splitter
340312
}
341-
342313
}
343-
else
314+
dest = dest->getDestNode();
315+
}
316+
317+
if (dest != nullptr)
318+
{
319+
if (dest->isEnabledState())
344320
{
345-
std::cout << " No dest node." << std::endl;
321+
connectProcessors(source, dest);
346322
}
347-
348323
}
349324
else
350325
{
@@ -509,7 +484,7 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(Array<var>& des
509484

510485
processor = ProcessorManager::createProcessorFromPluginInfo((Plugin::PluginType)processorType, processorIndex, processorName, libName, libVersion, isSource, isSink);
511486
}
512-
487+
513488
String msg = "New " + processorName + " created";
514489
CoreServices::sendStatusMessage(msg);
515490

@@ -781,4 +756,4 @@ float ProcessorGraph::getGlobalSampleRate(bool softwareOnly) const
781756
void ProcessorGraph::setTimestampWindow(TimestampSourceSelectionWindow* window)
782757
{
783758
m_timestampWindow = window;
784-
}
759+
}

0 commit comments

Comments
 (0)