# HG changeset patch # User František Kučera # Date 1601591654 -7200 # Node ID 14cf28d7681c187e7d52c0135f5d6adc9912516b # Parent 27579c5cdc519fd5e58b59358ffc1ef3cc3e6851 option: --required-jack-connections (start after given number of port connections) diff -r 27579c5cdc51 -r 14cf28d7681c bash-completion.sh --- a/bash-completion.sh Fri Oct 02 00:18:34 2020 +0200 +++ b/bash-completion.sh Fri Oct 02 00:34:14 2020 +0200 @@ -29,9 +29,11 @@ if [[ "$w1" == "--TODO" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN[*]}" -- "$w0")) elif [[ "$w1" == "--jack-client-name" && "x$w0" == "x" ]]; then COMPREPLY=("'relpipe-out-jack'") + elif [[ "$w1" == "--required-jack-connections" && "x$w0" == "x" ]]; then COMPREPLY=("1") else OPTIONS=( "--jack-client-name" + "--required-jack-connections" ) COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) fi diff -r 27579c5cdc51 -r 14cf28d7681c src/CLIParser.h --- a/src/CLIParser.h Fri Oct 02 00:18:34 2020 +0200 +++ b/src/CLIParser.h Fri Oct 02 00:34:14 2020 +0200 @@ -49,6 +49,7 @@ public: static const relpipe::common::type::StringX OPTION_JACK_CLIENT_NAME; + static const relpipe::common::type::StringX OPTION_REQUIRED_JACK_CONNECTIONS; Configuration parse(const std::vector& arguments) { Configuration c; @@ -58,6 +59,8 @@ if (option == OPTION_JACK_CLIENT_NAME) { c.jackClientName = readNext(arguments, i); + } else if (option == OPTION_REQUIRED_JACK_CONNECTIONS) { + c.requiredJackConnections = std::stoi(readNext(arguments, i)); } else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); } @@ -69,6 +72,7 @@ }; const relpipe::common::type::StringX CLIParser::OPTION_JACK_CLIENT_NAME = L"--jack-client-name"; +const relpipe::common::type::StringX CLIParser::OPTION_REQUIRED_JACK_CONNECTIONS = L"--required-jack-connections"; } } diff -r 27579c5cdc51 -r 14cf28d7681c src/Configuration.h --- a/src/Configuration.h Fri Oct 02 00:18:34 2020 +0200 +++ b/src/Configuration.h Fri Oct 02 00:34:14 2020 +0200 @@ -29,6 +29,7 @@ class Configuration { public: relpipe::common::type::StringX jackClientName = L"relpipe-out-jack"; + int requiredJackConnections = 1; virtual ~Configuration() { } diff -r 27579c5cdc51 -r 14cf28d7681c src/JackHandler.h --- a/src/JackHandler.h Fri Oct 02 00:18:34 2020 +0200 +++ b/src/JackHandler.h Fri Oct 02 00:34:14 2020 +0200 @@ -97,8 +97,7 @@ if (jackError) throw JackException(L"Could not activate client."); // Wait for a port connection, because it does not make much sense to send MIDI events nowhere: - // TODO: configurable waiting (number of connections) - while (jack_port_connected(jackPort) == 0) usleep(10000); + while (jack_port_connected(jackPort) < configuration.requiredJackConnections) usleep(10000); // TODO: configurable auto-connection to another client/port }