aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/jalv.c35
-rw-r--r--src/jalv_console.c11
-rw-r--r--src/jalv_gtk.c4
-rw-r--r--src/jalv_internal.h2
5 files changed, 41 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index 76481e1..926f9d9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ jalv (1.4.7) unstable;
* Improve preset support
* Add generic Qt control UI from Amadeus Folego
* Set Jack port order metadata
+ * Allow Jack client name to be set from command line (thanks Adam Avramov)
* Add command prompt to console version for changing controls
* Exit on Jack shutdown (Patch from Robin Gareus)
* Report Jack latency (Patch from Robin Gareus)
@@ -11,7 +12,7 @@ jalv (1.4.7) unstable;
* Use moc-qt4 if present for systems with multiple Qt versions
* Add Qt5 version
- -- David Robillard <d@drobilla.net> Sat, 12 Sep 2015 12:02:48 -0400
+ -- David Robillard <d@drobilla.net> Fri, 09 Oct 2015 18:00:22 -0400
jalv (1.4.6) stable;
diff --git a/src/jalv.c b/src/jalv.c
index 0853b81..c125a52 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -1152,34 +1152,43 @@ main(int argc, char** argv)
/* Create port structures (jalv.ports) */
jalv_create_ports(&jalv);
- /* Get the plugin's name */
- LilvNode* name = lilv_plugin_get_name(jalv.plugin);
- const char* name_str = lilv_node_as_string(name);
-
- /* Truncate plugin name to suit JACK (if necessary) */
+ /* Determine the name of the JACK client */
char* jack_name = NULL;
- if (strlen(name_str) >= (unsigned)jack_client_name_size() - 1) {
- jack_name = (char*)calloc(jack_client_name_size(), 1);
- strncpy(jack_name, name_str, jack_client_name_size() - 1);
+ if (jalv.opts.name) {
+ /* Name given on command line */
+ jack_name = jalv_strdup(jalv.opts.name);
} else {
- jack_name = jalv_strdup(name_str);
+ /* Use plugin name */
+ LilvNode* name = lilv_plugin_get_name(jalv.plugin);
+ jack_name = jalv_strdup(lilv_node_as_string(name));
+ lilv_node_free(name);
+ }
+
+ /* Truncate client name to suit JACK if necessary */
+ if (strlen(jack_name) >= (unsigned)jack_client_name_size() - 1) {
+ jack_name[jack_client_name_size() - 1] = '\0';
}
/* Connect to JACK */
printf("JACK Name: %s\n", jack_name);
#ifdef JALV_JACK_SESSION
if (jalv.opts.uuid) {
- jalv.jack_client = jack_client_open(jack_name, JackSessionID, NULL,
- jalv.opts.uuid);
+ jalv.jack_client = jack_client_open(
+ jack_name,
+ JackSessionID | (jalv.opts.name_exact ? JackUseExactName : 0),
+ NULL,
+ jalv.opts.uuid);
}
#endif
if (!jalv.jack_client) {
- jalv.jack_client = jack_client_open(jack_name, JackNullOption, NULL);
+ jalv.jack_client = jack_client_open(
+ jack_name,
+ (jalv.opts.name_exact ? JackUseExactName : JackNullOption),
+ NULL);
}
free(jack_name);
- lilv_node_free(name);
if (!jalv.jack_client)
die("Failed to connect to JACK.\n");
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 79cde0f..b17779b 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -39,6 +39,8 @@ print_usage(const char* name, bool error)
fprintf(os, " -l DIR Load state from save directory\n");
fprintf(os, " -d DIR Dump plugin <=> UI communication\n");
fprintf(os, " -b SIZE Buffer size for plugin <=> UI communication\n");
+ fprintf(os, " -n NAME JACK client name\n");
+ fprintf(os, " -x Exact JACK client name (exit if taken)\n");
return error ? 1 : 0;
}
@@ -101,6 +103,15 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
opts->controls[n_controls] = NULL;
} else if ((*argv)[a][1] == 'd') {
opts->dump = true;
+ } else if ((*argv)[a][1] == 'n') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -n\n");
+ return 1;
+ }
+ free(opts->name);
+ opts->name = jalv_strdup((*argv)[a]);
+ } else if ((*argv)[a][1] == 'x') {
+ opts->name_exact = 1;
} else {
fprintf(stderr, "Unknown option %s\n", (*argv)[a]);
return print_usage((*argv)[0], true);
diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c
index e720100..4f45c92 100644
--- a/src/jalv_gtk.c
+++ b/src/jalv_gtk.c
@@ -105,6 +105,10 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
"Set control value (e.g. \"vol=1.4\")", NULL},
{ "print-controls", 'p', 0, G_OPTION_ARG_NONE, &opts->print_controls,
"Print control output changes to stdout", NULL},
+ { "jack-name", 'n', 0, G_OPTION_ARG_STRING, &opts->name,
+ "JACK client name", NULL},
+ { "exact-jack-name", 'x', 0, G_OPTION_ARG_NONE, &opts->name_exact,
+ "Exact JACK client name (exit if taken)", NULL },
{ 0, 0, 0, 0, 0, 0, 0 } };
GError* error = NULL;
const int err = gtk_init_with_args(
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index abaf994..6651cd7 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -85,6 +85,8 @@ typedef struct {
} ControlChange;
typedef struct {
+ char* name; ///< Client name
+ int name_exact; ///< Exit if name is taken
char* uuid; ///< Session UUID
char* load; ///< Path for state to load
char* preset; ///< URI of preset to load