From 19e468cc78813ac279afd8dfcc516d4052dd1d78 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 21 Feb 2019 12:14:18 +0100 Subject: [PATCH 1/3] Sync example-clients/connect.c with jack1 Signed-off-by: falkTX --- example-clients/connect.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/example-clients/connect.c b/example-clients/connect.c index 5494ab94..b302ce67 100644 --- a/example-clients/connect.c +++ b/example-clients/connect.c @@ -23,28 +23,21 @@ #endif #include #include -#include #include + #include #include -jack_port_t *input_port; -jack_port_t *output_port; -int connecting, disconnecting; -volatile int done = 0; #define TRUE 1 #define FALSE 0 +volatile int done = 0; + void port_connect_callback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg) { done = 1; } -void error_callback (const char *err) -{ - //fprintf (stderr, "%s\n", err); -} - void show_version (char *my_name) { @@ -138,17 +131,10 @@ main (int argc, char *argv[]) return 1; } - jack_set_error_function(error_callback); - /* try to become a client of the JACK server */ if ((client = jack_client_open (my_name, options, &status, server_name)) == 0) { - fprintf (stderr, "Error: cannot connect to JACK, "); - if (status & JackServerFailed) { - fprintf (stderr, "server is not running.\n"); - } else { - fprintf (stderr, "jack_client_open() failed, status = 0x%2.0x\n", status); - } + fprintf (stderr, "jack server not running?\n"); return 1; } From 8e2c84ea48fc9f31baaf21878fbe93412d9ea168 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 21 Feb 2019 12:37:15 +0100 Subject: [PATCH 2/3] Sync example-clients/lsp.c with jack1 Signed-off-by: falkTX --- example-clients/lsp.c | 82 ++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/example-clients/lsp.c b/example-clients/lsp.c index 4485fe56..a1e3f1aa 100644 --- a/example-clients/lsp.c +++ b/example-clients/lsp.c @@ -22,19 +22,34 @@ #include #include #include + #include +#include +#include char * my_name; -void error_callback (const char *err) +static void +show_version (void) { - //fprintf (stderr, "%s\n", err); + //fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name); } static void -show_version (void) +printf_name2uuid (jack_client_t* client, const char* pname) { - //fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name); + char *port_component = strchr( pname, ':' ); + size_t csize = port_component - pname + 1; + char client_component[csize]; + snprintf(client_component, csize, "%s", pname); + + char *uuid = jack_get_uuid_for_client_name(client, client_component); + if (uuid) { + printf("%s%s\n", uuid, port_component ); + } else { + printf("%s\n",pname); + } + jack_free(uuid); } static void @@ -48,11 +63,13 @@ show_usage (void) fprintf (stderr, " -s, --server Connect to the jack server named \n"); fprintf (stderr, " -A, --aliases List aliases for each port\n"); fprintf (stderr, " -c, --connections List connections to/from each port\n"); - fprintf (stderr, " -l, --latency Display per-port latency in frames at each port\n"); - fprintf (stderr, " -L, --latency Display total latency in frames at each port\n"); + fprintf (stderr, " -l, --port-latency Display per-port latency in frames at each port\n"); + fprintf (stderr, " -L, --total-latency Display total latency in frames at each port\n"); fprintf (stderr, " -p, --properties Display port properties. Output may include:\n" " input|output, can-monitor, physical, terminal\n\n"); fprintf (stderr, " -t, --type Display port type\n"); + fprintf (stderr, " -u, --uuid Display uuid instead of client name (if available)\n"); + fprintf (stderr, " -U, --port-uuid Display port uuid\n"); fprintf (stderr, " -h, --help Display this help message\n"); fprintf (stderr, " --version Output version information and exit\n\n"); fprintf (stderr, "For more information see http://jackaudio.org/\n"); @@ -73,11 +90,12 @@ main (int argc, char *argv[]) int show_total_latency = 0; int show_properties = 0; int show_type = 0; + int show_uuid = 0; + int show_port_uuid = 0; int c; int option_index; char* aliases[2]; char *server_name = NULL; - jack_port_t *port; struct option long_options[] = { { "server", 1, 0, 's' }, @@ -87,6 +105,8 @@ main (int argc, char *argv[]) { "total-latency", 0, 0, 'L' }, { "properties", 0, 0, 'p' }, { "type", 0, 0, 't' }, + { "uuid", 0, 0, 'u' }, + { "port-uuid", 0, 0, 'U' }, { "help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } @@ -99,7 +119,7 @@ main (int argc, char *argv[]) my_name ++; } - while ((c = getopt_long (argc, argv, "s:AclLphvt", long_options, &option_index)) >= 0) { + while ((c = getopt_long (argc, argv, "s:AclLphvtuU", long_options, &option_index)) >= 0) { switch (c) { case 's': server_name = (char *) malloc (sizeof (char) * strlen(optarg)); @@ -126,6 +146,12 @@ main (int argc, char *argv[]) case 't': show_type = 1; break; + case 'u': + show_uuid = 1; + break; + case 'U': + show_port_uuid = 1; + break; case 'h': show_usage (); return 1; @@ -141,13 +167,9 @@ main (int argc, char *argv[]) } } - jack_set_error_function(error_callback); - /* Open a client connection to the JACK server. Starting a * new server only to list its ports seems pointless, so we * specify JackNoStartServer. */ - //JOQ: need a new server name option - if ((client = jack_client_open ("lsp", options, &status, server_name)) == 0) { fprintf (stderr, "Error: cannot connect to JACK, "); if (status & JackServerFailed) { @@ -159,21 +181,31 @@ main (int argc, char *argv[]) } ports = jack_get_ports (client, NULL, NULL, 0); - if (!ports) - goto error; for (i = 0; ports && ports[i]; ++i) { // skip over any that don't match ALL of the strings presented at command line skip_port = 0; - for(k = optind; k < argc; k++){ - if(strstr(ports[i], argv[k]) == NULL ){ + for (k = optind; k < argc; k++){ + if (strstr(ports[i], argv[k]) == NULL ){ skip_port = 1; } } if (skip_port) continue; - printf ("%s\n", ports[i]); - port = jack_port_by_name (client, ports[i]); + if (show_uuid) { + printf_name2uuid(client, ports[i]); + } else { + printf ("%s\n", ports[i]); + } + + jack_port_t *port = jack_port_by_name (client, ports[i]); + + if (show_port_uuid) { + char buf[JACK_UUID_STRING_SIZE]; + jack_uuid_t uuid = jack_port_uuid (port); + jack_uuid_unparse (uuid, buf); + printf (" uuid: %s\n", buf); + } if (show_aliases) { int cnt; @@ -188,16 +220,19 @@ main (int argc, char *argv[]) if (show_con) { if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) { for (j = 0; connections[j]; j++) { - printf (" %s\n", connections[j]); + printf(" "); + if (show_uuid) { + printf_name2uuid(client, connections[j]); + } else { + printf("%s\n", connections[j]); + } } - free (connections); + jack_free (connections); } } if (show_port_latency) { if (port) { jack_latency_range_t range; - printf (" port latency = %" PRIu32 " frames\n", - jack_port_get_latency (port)); jack_port_get_latency_range (port, JackPlaybackLatency, &range); printf (" port playback latency = [ %" PRIu32 " %" PRIu32 " ] frames\n", @@ -233,7 +268,6 @@ main (int argc, char *argv[]) if (flags & JackPortIsTerminal) { fputs ("terminal,", stdout); } - putc ('\n', stdout); } } @@ -246,7 +280,6 @@ main (int argc, char *argv[]) } } -error: if (show_aliases) { free(aliases[0]); free(aliases[1]); @@ -256,4 +289,3 @@ error: jack_client_close (client); exit (0); } - From 5f2baebd6b9d26d2ec5bdb94957d1e3351b1b7e8 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 21 Feb 2019 12:43:14 +0100 Subject: [PATCH 3/3] Sync example-clients/bufsize.c with jack1 Signed-off-by: falkTX --- example-clients/bufsize.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/example-clients/bufsize.c b/example-clients/bufsize.c index 903beadd..87683595 100644 --- a/example-clients/bufsize.c +++ b/example-clients/bufsize.c @@ -47,7 +47,6 @@ void signal_handler(int sig) void parse_arguments(int argc, char *argv[]) { - /* basename $0 */ package = strrchr(argv[0], '/'); if (package == 0) @@ -71,27 +70,31 @@ void parse_arguments(int argc, char *argv[]) nframes = strtoul(argv[1], NULL, 0); if (errno == ERANGE) { - fprintf(stderr, "%s: invalid buffer size: %s (range is 1-8192)\n", + fprintf(stderr, "%s: invalid buffer size: %s (range is 1-16384)\n", package, argv[1]); exit(2); } - - if (nframes < 1 || nframes > 8192) { - fprintf(stderr, "%s: invalid buffer size: %s (range is 1-8192)\n", + if (nframes < 1 || nframes > 16384) { + fprintf(stderr, "%s: invalid buffer size: %s (range is 1-16384)\n", package, argv[1]); exit(3); } } +void silent_function( const char *ignore ) +{ +} + int main(int argc, char *argv[]) { int rc; - jack_options_t options = JackNoStartServer; - parse_arguments(argc, argv); + if (just_print_bufsize) + jack_set_info_function( silent_function ); + /* become a JACK client */ - if ((client = jack_client_open(package, options, NULL)) == 0) { + if ((client = jack_client_open(package, JackNoStartServer, NULL)) == 0) { fprintf(stderr, "JACK server not running?\n"); exit(1); } @@ -106,8 +109,8 @@ int main(int argc, char *argv[]) jack_on_shutdown(client, jack_shutdown, 0); if (just_print_bufsize) { - fprintf(stdout, "buffer size = %d sample rate = %d\n", jack_get_buffer_size(client), jack_get_sample_rate(client)); - rc=0; + fprintf(stdout, "%d\n", jack_get_buffer_size( client ) ); + rc = 0; } else {