Hi all,
Is there any way to setBusesLayout while simultaneously adding or removing buses as appropriate?
Currently, littered around my code are instances like the following:
auto algLayout = algProc->getBusesLayout();
auto sinkLayout = algLayout;
// sync number of buses
for (int dir = 0; dir < 2; ++dir)
{
const bool isInput = (dir == 0);
int expectedNumBuses = isInput ? sinkLayout.inputBuses.size() : sinkLayout.outputBuses.size();
int currentNumBuses = sinkProc->getBusCount(isInput);
for (; currentNumBuses < expectedNumBuses; currentNumBuses++)
{
auto result = sinkProc->addBus(isInput);
if (!result)
{
Logger::writeToLog("Failed to add bus to sink processor");
return false;
}
}
for (; expectedNumBuses < currentNumBuses; expectedNumBuses++)
{
auto result = sinkProc->removeBus(isInput);
if (!result)
{
Logger::writeToLog("Failed to remove bus to sink processor");
return false;
}
}
assert(expectedNumBuses == currentNumBuses);
}
if (!sinkProc->setBusesLayout(sinkLayout))
{
Logger::writeToLog("Failed to set buses layout for sinkProc");
return false;
}
Basically:
- Build a layout
- Go through the processor and add or remove busses as necessary so bus counts match
- apply the bus alyout with setBusesLayout
Is there a way that 2 and 3 can be the same step? Essentially if you apply a bus layout, it adds/removes buses as necessary?
Am I over complicating things?
Thank you!