diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jalv.c | 35 | ||||
-rw-r--r-- | src/jalv_console.c | 11 | ||||
-rw-r--r-- | src/jalv_gtk.c | 4 | ||||
-rw-r--r-- | src/jalv_internal.h | 2 |
4 files changed, 39 insertions, 13 deletions
@@ -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 |