diff options
author | David Robillard <d@drobilla.net> | 2015-10-09 22:00:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-09 22:00:54 +0000 |
commit | 179200bf87a153e1103a3bbe6133c9f5339d62d2 (patch) | |
tree | da5ef637c94c8bc19d168db40997e91a06d4456a /src | |
parent | 5791a2a5bb3db7784f87efbb181cf8151a40c2de (diff) | |
download | jalv-179200bf87a153e1103a3bbe6133c9f5339d62d2.tar.gz jalv-179200bf87a153e1103a3bbe6133c9f5339d62d2.tar.bz2 jalv-179200bf87a153e1103a3bbe6133c9f5339d62d2.zip |
Allow Jack client name to be set from command line
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5760 a436a847-0d15-0410-975c-d299462d15a1
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 |