Browse Source

Synchronize with jack code

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1279 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.59
sletz 19 years ago
parent
commit
d2c21071fa
1 changed files with 48 additions and 13 deletions
  1. +48
    -13
      example-clients/lsp.c

+ 48
- 13
example-clients/lsp.c View File

@@ -25,9 +25,11 @@ show_usage (void)
fprintf (stderr, "List active Jack ports, and optionally display extra information.\n\n");
fprintf (stderr, "Display options:\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, " -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, " -h, --help Display this help message\n");
fprintf (stderr, " --version Output version information and exit\n\n");
fprintf (stderr, "For more information see http://jackit.sourceforge.net/\n");
@@ -37,18 +39,23 @@ int
main (int argc, char *argv[])
{
jack_client_t *client;
jack_status_t status;
const char **ports, **connections;
unsigned int i, j;
int show_con = 0;
int show_latency = 0;
int show_port_latency = 0;
int show_total_latency = 0;
int show_properties = 0;
int show_type = 0;
int c;
int option_index;

struct option long_options[] = {
{ "connections", 0, 0, 'c' },
{ "latency", 0, 0, 'l' },
{ "port-latency", 0, 0, 'l' },
{ "total-latency", 0, 0, 'L' },
{ "properties", 0, 0, 'p' },
{ "type", 0, 0, 't' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ 0, 0, 0, 0 }
@@ -61,17 +68,23 @@ main (int argc, char *argv[])
my_name ++;
}

while ((c = getopt_long (argc, argv, "clphv", long_options, &option_index)) >= 0) {
while ((c = getopt_long (argc, argv, "clLphvt", long_options, &option_index)) >= 0) {
switch (c) {
case 'c':
show_con = 1;
break;
case 'l':
show_latency = 1;
show_port_latency = 1;
break;
case 'L':
show_total_latency = 1;
break;
case 'p':
show_properties = 1;
break;
case 't':
show_type = 1;
break;
case 'h':
show_usage ();
return 1;
@@ -87,10 +100,19 @@ main (int argc, char *argv[])
}
}

/* try to become a client of the JACK server */
/* 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_new ("lsp")) == 0) {
fprintf (stderr, "jack server not running?\n");
client = jack_client_open ("lsp", JackNoStartServer, &status);
if (client == NULL) {
if (status & JackServerFailed) {
fprintf (stderr, "JACK server not running\n");
} else {
fprintf (stderr, "jack_client_open() failed, "
"status = 0x%2.0x\n", status);
}
return 1;
}

@@ -98,6 +120,9 @@ main (int argc, char *argv[])

for (i = 0; ports[i]; ++i) {
printf ("%s\n", ports[i]);

jack_port_t *port = jack_port_by_name (client, ports[i]);

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++) {
@@ -106,16 +131,19 @@ main (int argc, char *argv[])
free (connections);
}
}
if (show_latency) {
jack_port_t *port = jack_port_by_name (client, ports[i]);
if (show_port_latency) {
if (port) {
printf (" port latency = %" PRIu32 " frames\n",
jack_port_get_latency (port));
}
}
if (show_total_latency) {
if (port) {
// printf (" latency = %" PRIu32 " frames\n",
// jack_port_get_total_latency (client, port));
free (port);
printf (" total latency = %" PRIu32 " frames\n",
jack_port_get_total_latency (client, port));
}
}
if (show_properties) {
jack_port_t *port = jack_port_by_name (client, ports[i]);
if (port) {
int flags = jack_port_flags (port);
printf (" properties: ");
@@ -137,6 +165,13 @@ main (int argc, char *argv[])
putc ('\n', stdout);
}
}
if (show_type) {
if (port) {
putc ('\t', stdout);
//fputs (port->type_info->type_name, stdout);
putc ('\n', stdout);
}
}
}
jack_client_close (client);
exit (0);


Loading…
Cancel
Save