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.
25 #include <jack/jack.h>
32 //fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name);
39 fprintf (stderr
, "\nUsage: %s [options] [filter string]\n", my_name
);
40 fprintf (stderr
, "List active Jack ports, and optionally display extra information.\n");
41 fprintf (stderr
, "Optionally filter ports which match ALL strings provided after any options.\n\n");
42 fprintf (stderr
, "Display options:\n");
43 fprintf (stderr
, " -s, --server <name> Connect to the jack server named <name>\n");
44 fprintf (stderr
, " -A, --aliases List aliases for each port\n");
45 fprintf (stderr
, " -c, --connections List connections to/from each port\n");
46 fprintf (stderr
, " -l, --latency Display per-port latency in frames at each port\n");
47 fprintf (stderr
, " -L, --latency Display total latency in frames at each port\n");
48 fprintf (stderr
, " -p, --properties Display port properties. Output may include:\n"
49 " input|output, can-monitor, physical, terminal\n\n");
50 fprintf (stderr
, " -t, --type Display port type\n");
51 fprintf (stderr
, " -h, --help Display this help message\n");
52 fprintf (stderr
, " --version Output version information and exit\n\n");
53 fprintf (stderr
, "For more information see http://jackaudio.org/\n");
57 main (int argc
, char *argv
[])
59 jack_client_t
*client
;
61 jack_options_t options
= JackNoStartServer
;
62 const char **ports
, **connections
;
67 int show_port_latency
= 0;
68 int show_total_latency
= 0;
69 int show_properties
= 0;
74 char *server_name
= NULL
;
77 struct option long_options
[] = {
78 { "server", 1, 0, 's' },
79 { "aliases", 0, 0, 'A' },
80 { "connections", 0, 0, 'c' },
81 { "port-latency", 0, 0, 'l' },
82 { "total-latency", 0, 0, 'L' },
83 { "properties", 0, 0, 'p' },
84 { "type", 0, 0, 't' },
85 { "help", 0, 0, 'h' },
86 { "version", 0, 0, 'v' },
90 my_name
= strrchr(argv
[0], '/');
97 while ((c
= getopt_long (argc
, argv
, "s:AclLphvt", long_options
, &option_index
)) >= 0) {
100 server_name
= (char *) malloc (sizeof (char) * strlen(optarg
));
101 strcpy (server_name
, optarg
);
102 options
|= JackServerName
;
105 aliases
[0] = (char *) malloc (jack_port_name_size());
106 aliases
[1] = (char *) malloc (jack_port_name_size());
113 show_port_latency
= 1;
116 show_total_latency
= 1;
139 /* Open a client connection to the JACK server. Starting a
140 * new server only to list its ports seems pointless, so we
141 * specify JackNoStartServer. */
142 //JOQ: need a new server name option
144 client
= jack_client_open ("lsp", options
, &status
, server_name
);
145 if (client
== NULL
) {
146 if (status
& JackServerFailed
) {
147 fprintf (stderr
, "JACK server not running\n");
149 fprintf (stderr
, "jack_client_open() failed, "
150 "status = 0x%2.0x\n", status
);
155 ports
= jack_get_ports (client
, NULL
, NULL
, 0);
159 for (i
= 0; ports
&& ports
[i
]; ++i
) {
160 // skip over any that don't match ALL of the strings presented at command line
162 for(k
= optind
; k
< argc
; k
++){
163 if(strstr(ports
[i
], argv
[k
]) == NULL
){
167 if (skip_port
) continue;
169 printf ("%s\n", ports
[i
]);
170 port
= jack_port_by_name (client
, ports
[i
]);
176 cnt
= jack_port_get_aliases (port
, aliases
);
177 for (i
= 0; i
< cnt
; ++i
) {
178 printf (" %s\n", aliases
[i
]);
183 if ((connections
= jack_port_get_all_connections (client
, jack_port_by_name(client
, ports
[i
]))) != 0) {
184 for (j
= 0; connections
[j
]; j
++) {
185 printf (" %s\n", connections
[j
]);
190 if (show_port_latency
) {
192 jack_latency_range_t range
;
193 printf (" port latency = %" PRIu32
" frames\n",
194 jack_port_get_latency (port
));
196 jack_port_get_latency_range (port
, JackPlaybackLatency
, &range
);
197 printf (" port playback latency = [ %" PRIu32
" %" PRIu32
" ] frames\n",
198 range
.min
, range
.max
);
200 jack_port_get_latency_range (port
, JackCaptureLatency
, &range
);
201 printf (" port capture latency = [ %" PRIu32
" %" PRIu32
" ] frames\n",
202 range
.min
, range
.max
);
205 if (show_total_latency
) {
207 printf (" total latency = %d frames\n",
208 jack_port_get_total_latency (client
, port
));
211 if (show_properties
) {
213 int flags
= jack_port_flags (port
);
214 printf (" properties: ");
215 if (flags
& JackPortIsInput
) {
216 fputs ("input,", stdout
);
218 if (flags
& JackPortIsOutput
) {
219 fputs ("output,", stdout
);
221 if (flags
& JackPortCanMonitor
) {
222 fputs ("can-monitor,", stdout
);
224 if (flags
& JackPortIsPhysical
) {
225 fputs ("physical,", stdout
);
227 if (flags
& JackPortIsTerminal
) {
228 fputs ("terminal,", stdout
);
237 fputs (jack_port_type (port
), stdout
);
250 jack_client_close (client
);