From 1bd8b84497d290988043a894ac55e3dc0cea0e0a Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Wed, 3 Aug 2011 16:12:16 +0300 Subject: [PATCH] -u commandline option ALSA does not guarantee client names to by unique. I.e. it is possible to have two apps that create two clients with same ALSA client name. JACK however requires port names to be unqiue. To ensure this uniqueness, a2jmidid will add the unique numeric ALSA client ID to the JACK port name. However this behaviour is known to be problematic when restoring connections using simplistic tools like aj-snapshot and jack_connect. In order to make them work, the -u option can be used. This option will cause a2jmidid to omit the numeric ALSA Client ID from JACK port names. In this mode, ALSA client name uniqueness must be guartanteed externally. --- a2jmidid.c | 10 +++++++--- man/a2jmidid.1 | 13 +++++++++++++ port.c | 6 ++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/a2jmidid.c b/a2jmidid.c index 9767069..f47edde 100644 --- a/a2jmidid.c +++ b/a2jmidid.c @@ -2,7 +2,7 @@ * ALSA SEQ < - > JACK MIDI bridge * * Copyright (c) 2006,2007 Dmitry S. Baikov - * Copyright (c) 2007,2008,2009 Nedko Arnaudov + * Copyright (c) 2007,2008,2009,2011 Nedko Arnaudov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,6 +63,7 @@ bool g_stop_request = false; static bool g_started = false; struct a2j * g_a2j = NULL; size_t g_max_jack_port_name_size; +bool g_disable_port_uniqueness = false; bool g_a2j_export_hw_ports = false; char * g_a2j_jack_server_name = "default"; @@ -424,7 +425,7 @@ void a2j_help( const char * self) { - a2j_info("Usage: %s [-j jack-server] [-e | --export-hw]", self); + a2j_info("Usage: %s [-j jack-server] [-e | --export-hw] [-u]", self); a2j_info("Defaults:"); a2j_info("-j default"); } @@ -469,7 +470,7 @@ main( int option_index = 0; int c; - while ((c = getopt_long(argc, argv, "j:eq", long_opts, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "j:eu", long_opts, &option_index)) != -1) { switch (c) { @@ -479,6 +480,9 @@ main( case 'e': g_a2j_export_hw_ports = true; break; + case 'u': + g_disable_port_uniqueness = true; + break; default: a2j_help(argv[0]); return 1; diff --git a/man/a2jmidid.1 b/man/a2jmidid.1 index 749f252..b4fe9d6 100644 --- a/man/a2jmidid.1 +++ b/man/a2jmidid.1 @@ -12,8 +12,21 @@ output. .SH OPTIONS .IP "-e | --export-hw" forces a2jmidid to bridge hardware ports as well as software ports +.IP "-u" +forces a2jmidid to generate non-unique port names (see NOTES) .IP -j specifies which jack-server to use +.SH NOTES +ALSA does not guarantee client names to by unique. I.e. it is possible +to have two apps that create two clients with same ALSA client name. +JACK however requires port names to be unqiue. To ensure this uniqueness, +a2jmidid will add the unique numeric ALSA client ID to the JACK port name. +However this behaviour is known to be problematic when restoring +connections using simplistic tools like aj\-snapshot and jack_connect. +In order to make them work, the -u option can be used. This option will +cause a2jmidid to omit the numeric ALSA Client ID from JACK port names. +In this mode, ALSA client name uniqueness must be guartanteed externally. + .SH AUTHOR Eric Hedekar .SH "SEE ALSO" diff --git a/port.c b/port.c index 4e50343..2698fd7 100644 --- a/port.c +++ b/port.c @@ -3,7 +3,7 @@ * ALSA SEQ < - > JACK MIDI bridge * * Copyright (c) 2006,2007 Dmitry S. Baikov - * Copyright (c) 2007,2008,2009 Nedko Arnaudov + * Copyright (c) 2007,2008,2009,2011 Nedko Arnaudov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,8 @@ #include "log.h" #include "port.h" +extern bool g_disable_port_uniqueness; + /* This should be part of JACK API */ #define JACK_IS_VALID_PORT_NAME_CHAR(c) \ (isalnum(c) || \ @@ -190,7 +192,7 @@ a2j_port_create( port->jack_port = JACK_INVALID_PORT; port->remote = addr; - a2j_port_fill_name(port, type, client_info_ptr, info, true); + a2j_port_fill_name(port, type, client_info_ptr, info, !g_disable_port_uniqueness); /* Add port to list early, before registering to JACK, so map functionality is guaranteed to work during port registration */ list_add_tail(&port->siblings, &stream_ptr->list); -- 2.11.4.GIT