diff -r 0d362165241e -r ded44e94147c src/JackCommand.h --- a/src/JackCommand.h Tue Oct 06 16:24:18 2020 +0200 +++ b/src/JackCommand.h Tue Oct 06 16:55:22 2020 +0200 @@ -55,6 +55,8 @@ std::atomic continueProcessing{true}; + int maxJackPortConnections = 0; + /** * Is passed through the ring buffer * from the the jack-writing thread (callback) to the relpipe-writing thread. @@ -218,6 +220,15 @@ int jackError = jack_activate(realTimeContext.jackClient); if (jackError) failInConstructor(L"Could not activate the JACK client."); + + + // Connect to configured destination ports: + const char* jackPortName = jack_port_name(realTimeContext.jackPort); + for (auto sourcePort : configuration.portsToConnect) { + int error = jack_connect(realTimeContext.jackClient, convertor.to_bytes(sourcePort).c_str(), jackPortName); + if (error) failInConstructor(L"Connection to the JACK port failed: " + sourcePort); + } + } void processJackStream(std::shared_ptr writer, std::function relationalWriterFlush) { @@ -244,6 +255,13 @@ relationalWriterFlush(); } waitForRTCycle(); + + // Once the Configuration::requiredJackConnections count was reached, we will disconnect if the count drops under this level. + if (configuration.requiredJackConnections) { + int currentConnectionCount = jack_port_connected(realTimeContext.jackPort); + if (currentConnectionCount > maxJackPortConnections) maxJackPortConnections = currentConnectionCount; + else if (maxJackPortConnections >= configuration.requiredJackConnections && currentConnectionCount < configuration.requiredJackConnections) break; + } } }