jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.0KB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5. #include <getopt.h>
  6. #include <jack/jack.h>
  7. int
  8. main (int argc, char *argv[])
  9. {
  10. jack_client_t *client;
  11. const char **ports, **connections;
  12. unsigned int i, j;
  13. int show_con = 0;
  14. int show_latency = 0;
  15. int show_properties = 0;
  16. int c;
  17. int option_index;
  18. struct option long_options[] = {
  19. { "connections", 0, 0, 'c' },
  20. { "latency", 0, 0, 'l' },
  21. { "properties", 0, 0, 'p' },
  22. { 0, 0, 0, 0 }
  23. };
  24. while ((c = getopt_long (argc, argv, "clp", long_options, &option_index)) >= 0) {
  25. switch (c) {
  26. case 'c':
  27. show_con = 1;
  28. break;
  29. case 'l':
  30. show_latency = 1;
  31. break;
  32. case 'p':
  33. show_properties = 1;
  34. break;
  35. }
  36. }
  37. /* try to become a client of the JACK server */
  38. if ((client = jack_client_new ("lsp")) == 0) {
  39. fprintf (stderr, "jack server not running?\n");
  40. return 1;
  41. }
  42. ports = jack_get_ports (client, NULL, NULL, 0);
  43. for (i = 0; ports[i]; ++i) {
  44. printf ("%s\n", ports[i]);
  45. if (show_con) {
  46. if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) {
  47. for (j = 0; connections[j]; j++) {
  48. printf (" %s\n", connections[j]);
  49. }
  50. free (connections);
  51. }
  52. }
  53. if (show_latency) {
  54. jack_port_t *port = jack_port_by_name (client, ports[i]);
  55. if (port) {
  56. printf (" latency = %lu frames\n", jack_port_get_total_latency (client, port));
  57. free (port);
  58. }
  59. }
  60. if (show_properties) {
  61. jack_port_t *port = jack_port_by_name (client, ports[i]);
  62. if (port) {
  63. int flags = jack_port_flags (port);
  64. printf (" properties: ");
  65. if (flags & JackPortIsInput) {
  66. fputs ("input,", stdout);
  67. }
  68. if (flags & JackPortIsOutput) {
  69. fputs ("output,", stdout);
  70. }
  71. if (flags & JackPortCanMonitor) {
  72. fputs ("can-monitor,", stdout);
  73. }
  74. if (flags & JackPortIsPhysical) {
  75. fputs ("physical,", stdout);
  76. }
  77. if (flags & JackPortIsTerminal) {
  78. fputs ("terminal,", stdout);
  79. }
  80. putc ('\n', stdout);
  81. }
  82. }
  83. }
  84. jack_client_close (client);
  85. exit (0);
  86. }