16
fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n",
24
fprintf (stderr, "\nUsage: %s [options] [filter string]\n", my_name);
25
fprintf (stderr, "List active Jack ports, and optionally display extra information.\n");
26
fprintf (stderr, "Optionally filter ports which match ALL strings provided after any options.\n\n");
27
fprintf (stderr, "Display options:\n");
28
fprintf (stderr, " -s, --server <name> Connect to the jack server named <name>\n");
29
fprintf (stderr, " -A, --aliases List aliases for each port\n");
30
fprintf (stderr, " -c, --connections List connections to/from each port\n");
31
fprintf (stderr, " -l, --latency Display per-port latency in frames at each port\n");
32
fprintf (stderr, " -L, --latency Display total latency in frames at each port\n");
33
fprintf (stderr, " -p, --properties Display port properties. Output may include:\n"
34
" input|output, can-monitor, physical, terminal\n\n");
35
fprintf (stderr, " -t, --type Display port type\n");
36
fprintf (stderr, " -h, --help Display this help message\n");
37
fprintf (stderr, " --version Output version information and exit\n\n");
38
fprintf (stderr, "For more information see http://jackaudio.org/\n");
42
main (int argc, char *argv[])
44
jack_client_t *client;
46
jack_options_t options = JackNoStartServer;
47
const char **ports, **connections;
52
int show_port_latency = 0;
53
int show_total_latency = 0;
54
int show_properties = 0;
59
char *server_name = NULL;
62
struct option long_options[] = {
63
{ "server", 1, 0, 's' },
64
{ "aliases", 0, 0, 'A' },
65
{ "connections", 0, 0, 'c' },
66
{ "port-latency", 0, 0, 'l' },
67
{ "total-latency", 0, 0, 'L' },
68
{ "properties", 0, 0, 'p' },
69
{ "type", 0, 0, 't' },
70
{ "help", 0, 0, 'h' },
71
{ "version", 0, 0, 'v' },
75
my_name = strrchr(argv[0], '/');
82
while ((c = getopt_long (argc, argv, "s:AclLphvt", long_options, &option_index)) >= 0) {
85
server_name = (char *) malloc (sizeof (char) * strlen(optarg));
86
strcpy (server_name, optarg);
87
options |= JackServerName;
90
aliases[0] = (char *) malloc (jack_port_name_size());
91
aliases[1] = (char *) malloc (jack_port_name_size());
98
show_port_latency = 1;
101
show_total_latency = 1;
124
/* Open a client connection to the JACK server. Starting a
125
* new server only to list its ports seems pointless, so we
126
* specify JackNoStartServer. */
127
client = jack_client_open ("lsp", options, &status, server_name);
128
if (client == NULL) {
129
if (status & JackServerFailed) {
130
fprintf (stderr, "JACK server not running\n");
132
fprintf (stderr, "jack_client_open() failed, "
133
"status = 0x%2.0x\n", status);
138
ports = jack_get_ports (client, NULL, NULL, 0);
140
for (i = 0; ports[i]; ++i) {
141
// skip over any that don't match ALL of the strings presented at command line
143
for(k=optind; k < argc; k++){
144
if(strstr(ports[i], argv[k]) == NULL ){
148
if(skip_port) continue;
150
printf ("%s\n", ports[i]);
152
jack_port_t *port = jack_port_by_name (client, ports[i]);
158
cnt = jack_port_get_aliases (port, aliases);
159
for (i = 0; i < cnt; ++i) {
160
printf (" %s\n", aliases[i]);
165
if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) {
166
for (j = 0; connections[j]; j++) {
167
printf (" %s\n", connections[j]);
172
if (show_port_latency) {
174
printf (" port latency = %" PRIu32 " frames\n",
175
jack_port_get_latency (port));
178
if (show_total_latency) {
180
printf (" total latency = %" PRIu32 " frames\n",
181
jack_port_get_total_latency (client, port));
184
if (show_properties) {
186
int flags = jack_port_flags (port);
187
printf (" properties: ");
188
if (flags & JackPortIsInput) {
189
fputs ("input,", stdout);
191
if (flags & JackPortIsOutput) {
192
fputs ("output,", stdout);
194
if (flags & JackPortCanMonitor) {
195
fputs ("can-monitor,", stdout);
197
if (flags & JackPortIsPhysical) {
198
fputs ("physical,", stdout);
200
if (flags & JackPortIsTerminal) {
201
fputs ("terminal,", stdout);
209
fputs (jack_port_type (port), stdout);
214
jack_client_close (client);