--- a/bash-completion.sh Wed Oct 07 01:46:03 2020 +0200
+++ b/bash-completion.sh Wed Oct 07 22:30:09 2020 +0200
@@ -17,7 +17,7 @@
_relpipe_out_jack_completion_ports() {
if type relpipe-in-jack &> /dev/null && type relpipe-out-nullbyte &> /dev/null; then
- relpipe-in-jack --list-jack-ports true --list-midi-messages false 2>/dev/null \
+ relpipe-in-jack --list-ports true --list-midi-messages false 2>/dev/null \
| relpipe-out-nullbyte \
| while _relpipe_out_jack_completion_read_nullbyte "name" "input" "output" "physical" "terminal" "mine" "midi" "type"; do
if [[ "$midi" = "true" && "$input" = "true" && "$mine" = "false" ]]; then echo "$name"; fi; done
@@ -33,14 +33,16 @@
w2=${COMP_WORDS[COMP_CWORD-2]}
w3=${COMP_WORDS[COMP_CWORD-3]}
- if [[ "$w1" == "--jack-client-name" && "x$w0" == "x" ]]; then COMPREPLY=("'relpipe-out-jack'")
- elif [[ "$w1" == "--jack-connect-to-port" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_out_jack_completion_ports)" -- "$w0"))
- elif [[ "$w1" == "--required-jack-connections" && "x$w0" == "x" ]]; then COMPREPLY=("1")
+ if [[ "$w1" == "--client" && "x$w0" == "x" ]]; then COMPREPLY=("'relpipe-out-jack'")
+ elif [[ "$w1" == "--port" && "x$w0" == "x" ]]; then COMPREPLY=("'midi-out'")
+ elif [[ "$w1" == "--connect-to" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_out_jack_completion_ports)" -- "$w0"))
+ elif [[ "$w1" == "--required-connections" && "x$w0" == "x" ]]; then COMPREPLY=("1")
else
OPTIONS=(
- "--jack-client-name"
- "--jack-connect-to-port"
- "--required-jack-connections"
+ "--client"
+ "--port"
+ "--connect-to"
+ "--required-connections"
)
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
fi
--- a/src/CLIParser.h Wed Oct 07 01:46:03 2020 +0200
+++ b/src/CLIParser.h Wed Oct 07 22:30:09 2020 +0200
@@ -48,9 +48,10 @@
public:
- static const relpipe::common::type::StringX OPTION_JACK_CLIENT_NAME;
- static const relpipe::common::type::StringX OPTION_JACK_CONNECT_TO_PORT;
- static const relpipe::common::type::StringX OPTION_REQUIRED_JACK_CONNECTIONS;
+ static const relpipe::common::type::StringX OPTION_CLIENT;
+ static const relpipe::common::type::StringX OPTION_PORT;
+ static const relpipe::common::type::StringX OPTION_CONNECT_TO;
+ static const relpipe::common::type::StringX OPTION_REQUIRED_CONNECTIONS;
Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
Configuration c;
@@ -58,12 +59,14 @@
for (int i = 0; i < arguments.size();) {
relpipe::common::type::StringX option = readNext(arguments, i);
- if (option == OPTION_JACK_CLIENT_NAME) {
- c.jackClientName = readNext(arguments, i);
- } else if (option == OPTION_JACK_CONNECT_TO_PORT) {
- c.portsToConnect.push_back(readNext(arguments, i));
- } else if (option == OPTION_REQUIRED_JACK_CONNECTIONS) {
- c.requiredJackConnections = std::stoi(readNext(arguments, i));
+ if (option == OPTION_CLIENT) {
+ c.client = readNext(arguments, i);
+ } else if (option == OPTION_PORT) {
+ c.port = readNext(arguments, i);
+ } else if (option == OPTION_CONNECT_TO) {
+ c.connectTo.push_back(readNext(arguments, i));
+ } else if (option == OPTION_REQUIRED_CONNECTIONS) {
+ c.requiredConnections = std::stoi(readNext(arguments, i));
} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
}
@@ -74,9 +77,10 @@
}
};
-const relpipe::common::type::StringX CLIParser::OPTION_JACK_CLIENT_NAME = L"--jack-client-name";
-const relpipe::common::type::StringX CLIParser::OPTION_JACK_CONNECT_TO_PORT = L"--jack-connect-to-port";
-const relpipe::common::type::StringX CLIParser::OPTION_REQUIRED_JACK_CONNECTIONS = L"--required-jack-connections";
+const relpipe::common::type::StringX CLIParser::OPTION_CLIENT = L"--client";
+const relpipe::common::type::StringX CLIParser::OPTION_PORT = L"--port";
+const relpipe::common::type::StringX CLIParser::OPTION_CONNECT_TO = L"--connect-to";
+const relpipe::common::type::StringX CLIParser::OPTION_REQUIRED_CONNECTIONS = L"--required-connections";
}
}
--- a/src/Configuration.h Wed Oct 07 01:46:03 2020 +0200
+++ b/src/Configuration.h Wed Oct 07 22:30:09 2020 +0200
@@ -28,9 +28,10 @@
class Configuration {
public:
- relpipe::common::type::StringX jackClientName = L"relpipe-out-jack";
- std::vector<relpipe::common::type::StringX> portsToConnect;
- int requiredJackConnections = 1;
+ relpipe::common::type::StringX client = L"relpipe-out-jack";
+ relpipe::common::type::StringX port = L"midi-out";
+ std::vector<relpipe::common::type::StringX> connectTo;
+ int requiredConnections = 1;
virtual ~Configuration() {
}
--- a/src/JackHandler.h Wed Oct 07 01:46:03 2020 +0200
+++ b/src/JackHandler.h Wed Oct 07 22:30:09 2020 +0200
@@ -186,7 +186,7 @@
pthread_mutex_lock(&realTimeContext.processingLock);
// Initialize JACK connection:
- std::string clientName = convertor.to_bytes(configuration.jackClientName);
+ std::string clientName = convertor.to_bytes(configuration.client);
realTimeContext.jackClient = jack_client_open(clientName.c_str(), JackNullOption, nullptr);
if (realTimeContext.jackClient == nullptr) failInConstructor(L"Could not create JACK client.");
@@ -198,7 +198,7 @@
jack_set_error_function(jackErrorCallback);
jack_set_info_function(jackErrorCallback);
- realTimeContext.jackPort = jack_port_register(realTimeContext.jackClient, "output", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
+ realTimeContext.jackPort = jack_port_register(realTimeContext.jackClient, convertor.to_bytes(configuration.port).c_str(), JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
if (realTimeContext.jackPort == nullptr) failInConstructor(L"Could not register the JACK port.");
if (mlockall(MCL_CURRENT | MCL_FUTURE)) fwprintf(stderr, L"Warning: Can not lock memory.\n");
@@ -209,13 +209,13 @@
// Connect to configured destination ports:
const char* jackPortName = jack_port_name(realTimeContext.jackPort);
- for (auto destinationPort : configuration.portsToConnect) {
+ for (auto destinationPort : configuration.connectTo) {
int error = jack_connect(realTimeContext.jackClient, jackPortName, convertor.to_bytes(destinationPort).c_str());
if (error) failInConstructor(L"Connection to the JACK port failed: " + destinationPort);
}
// Wait for a port connection, because it does not make much sense to send MIDI events nowhere:
- while (jack_port_connected(realTimeContext.jackPort) < configuration.requiredJackConnections) usleep(10000);
+ while (jack_port_connected(realTimeContext.jackPort) < configuration.requiredConnections) usleep(10000);
}