2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <jack/jack.h>
31 //fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name);
38 fprintf (stderr
, "\nUsage: %s [options] [filter string]\n", my_name
);
39 fprintf (stderr
, "List active Jack ports, and optionally display extra information.\n");
40 fprintf (stderr
, "Optionally filter ports which match ALL strings provided after any options.\n\n");
41 fprintf (stderr
, "Display options:\n");
42 fprintf (stderr
, " -A, --aliases List aliases for each port\n");
43 fprintf (stderr
, " -c, --connections List connections to/from each port\n");
44 fprintf (stderr
, " -l, --latency Display per-port latency in frames at each port\n");
45 fprintf (stderr
, " -L, --latency Display total latency in frames at each port\n");
46 fprintf (stderr
, " -p, --properties Display port properties. Output may include:\n"
47 " input|output, can-monitor, physical, terminal\n\n");
48 fprintf (stderr
, " -t, --type Display port type\n");
49 fprintf (stderr
, " -h, --help Display this help message\n");
50 fprintf (stderr
, " --version Output version information and exit\n\n");
51 fprintf (stderr
, "For more information see http://jackaudio.org/\n");
55 main (int argc
, char *argv
[])
57 jack_client_t
*client
;
59 const char **ports
, **connections
;
64 int show_port_latency
= 0;
65 int show_total_latency
= 0;
66 int show_properties
= 0;
73 struct option long_options
[] = {
74 { "aliases", 0, 0, 'A' },
75 { "connections", 0, 0, 'c' },
76 { "port-latency", 0, 0, 'l' },
77 { "total-latency", 0, 0, 'L' },
78 { "properties", 0, 0, 'p' },
79 { "type", 0, 0, 't' },
80 { "help", 0, 0, 'h' },
81 { "version", 0, 0, 'v' },
85 my_name
= strrchr(argv
[0], '/');
92 while ((c
= getopt_long (argc
, argv
, "AclLphvt", long_options
, &option_index
)) >= 0) {
95 aliases
[0] = (char *) malloc (jack_port_name_size());
96 aliases
[1] = (char *) malloc (jack_port_name_size());
103 show_port_latency
= 1;
106 show_total_latency
= 1;
129 /* Open a client connection to the JACK server. Starting a
130 * new server only to list its ports seems pointless, so we
131 * specify JackNoStartServer. */
132 //JOQ: need a new server name option
134 client
= jack_client_open ("lsp", JackNoStartServer
, &status
);
135 if (client
== NULL
) {
136 if (status
& JackServerFailed
) {
137 fprintf (stderr
, "JACK server not running\n");
139 fprintf (stderr
, "jack_client_open() failed, "
140 "status = 0x%2.0x\n", status
);
145 ports
= jack_get_ports (client
, NULL
, NULL
, 0);
149 for (i
= 0; ports
[i
]; ++i
) {
150 // skip over any that don't match ALL of the strings presented at command line
152 for(k
= optind
; k
< argc
; k
++){
153 if(strstr(ports
[i
], argv
[k
]) == NULL
){
157 if (skip_port
) continue;
159 printf ("%s\n", ports
[i
]);
160 port
= jack_port_by_name (client
, ports
[i
]);
166 cnt
= jack_port_get_aliases (port
, aliases
);
167 for (i
= 0; i
< cnt
; ++i
) {
168 printf (" %s\n", aliases
[i
]);
173 if ((connections
= jack_port_get_all_connections (client
, jack_port_by_name(client
, ports
[i
]))) != 0) {
174 for (j
= 0; connections
[j
]; j
++) {
175 printf (" %s\n", connections
[j
]);
180 if (show_port_latency
) {
182 printf (" port latency = %d frames\n",
183 jack_port_get_latency (port
));
186 if (show_total_latency
) {
188 printf (" total latency = %d frames\n",
189 jack_port_get_total_latency (client
, port
));
192 if (show_properties
) {
194 int flags
= jack_port_flags (port
);
195 printf (" properties: ");
196 if (flags
& JackPortIsInput
) {
197 fputs ("input,", stdout
);
199 if (flags
& JackPortIsOutput
) {
200 fputs ("output,", stdout
);
202 if (flags
& JackPortCanMonitor
) {
203 fputs ("can-monitor,", stdout
);
205 if (flags
& JackPortIsPhysical
) {
206 fputs ("physical,", stdout
);
208 if (flags
& JackPortIsTerminal
) {
209 fputs ("terminal,", stdout
);
217 fputs (jack_port_type (port
), stdout
);
224 jack_client_close (client
);