~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
JACK/example-clients/lsp.c


** Warning: Cannot open xref database.

1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <string.h> 5 #include <getopt.h> 6 7 #include <config.h> 8 9 #include <jack/jack.h> 10 11 char * my_name; 12 13 void 14 show_version (void) 15 { 16 fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", 17 my_name); 18 } 19 20 void 21 show_usage (void) 22 { 23 show_version (); 24 fprintf (stderr, "\nUsage: %s [options]\n", my_name); 25 fprintf (stderr, "List active Jack ports, and optionally display extra information.\n\n"); 26 fprintf (stderr, "Display options:\n"); 27 fprintf (stderr, " -c, --connections List connections to/from each port\n"); 28 fprintf (stderr, " -l, --latency Display total latency in frames at each port\n"); 29 fprintf (stderr, " -p, --properties Display port properties. Output may include:\n" 30 " input|output, can-monitor, physical, terminal\n\n"); 31 fprintf (stderr, " -h, --help Display this help message\n"); 32 fprintf (stderr, " --version Output version information and exit\n\n"); 33 fprintf (stderr, "For more information see http://jackit.sourceforge.net/\n"); 34 } 35 36 int 37 main (int argc, char *argv[]) 38 { 39 jack_client_t *client; 40 const char **ports, **connections; 41 unsigned int i, j; 42 int show_con = 0; 43 int show_latency = 0; 44 int show_properties = 0; 45 int c; 46 int option_index; 47 48 struct option long_options[] = { 49 { "connections", 0, 0, 'c' }, 50 { "latency", 0, 0, 'l' }, 51 { "properties", 0, 0, 'p' }, 52 { "help", 0, 0, 'h' }, 53 { "version", 0, 0, 'v' }, 54 { 0, 0, 0, 0 } 55 }; 56 57 my_name = strrchr(argv[0], '/'); 58 if (my_name == 0) { 59 my_name = argv[0]; 60 } else { 61 my_name ++; 62 } 63 64 while ((c = getopt_long (argc, argv, "clphv", long_options, &option_index)) >= 0) { 65 switch (c) { 66 case 'c': 67 show_con = 1; 68 break; 69 case 'l': 70 show_latency = 1; 71 break; 72 case 'p': 73 show_properties = 1; 74 break; 75 case 'h': 76 show_usage (); 77 return 1; 78 break; 79 case 'v': 80 show_version (); 81 return 1; 82 break; 83 default: 84 show_usage (); 85 return 1; 86 break; 87 } 88 } 89 90 /* try to become a client of the JACK server */ 91 92 if ((client = jack_client_new ("lsp")) == 0) { 93 fprintf (stderr, "jack server not running?\n"); 94 return 1; 95 } 96 97 ports = jack_get_ports (client, NULL, NULL, 0); 98 99 for (i = 0; ports[i]; ++i) { 100 printf ("%s\n", ports[i]); 101 if (show_con) { 102 if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) { 103 for (j = 0; connections[j]; j++) { 104 printf (" %s\n", connections[j]); 105 } 106 free (connections); 107 } 108 } 109 if (show_latency) { 110 jack_port_t *port = jack_port_by_name (client, ports[i]); 111 if (port) { 112 printf (" latency = %" PRIu32 " frames\n", 113 jack_port_get_total_latency (client, port)); 114 free (port); 115 } 116 } 117 if (show_properties) { 118 jack_port_t *port = jack_port_by_name (client, ports[i]); 119 if (port) { 120 int flags = jack_port_flags (port); 121 printf (" properties: "); 122 if (flags & JackPortIsInput) { 123 fputs ("input,", stdout); 124 } 125 if (flags & JackPortIsOutput) { 126 fputs ("output,", stdout); 127 } 128 if (flags & JackPortCanMonitor) { 129 fputs ("can-monitor,", stdout); 130 } 131 if (flags & JackPortIsPhysical) { 132 fputs ("physical,", stdout); 133 } 134 if (flags & JackPortIsTerminal) { 135 fputs ("terminal,", stdout); 136 } 137 putc ('\n', stdout); 138 } 139 } 140 } 141 jack_client_close (client); 142 exit (0); 143 } 144

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.