JACK tools
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.

93 lines
2.5KB

  1. /*
  2. Copyright (C) 2007 Paul Davis
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (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.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include <stdio.h>
  16. #include <errno.h>
  17. #include <unistd.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <jack/jack.h>
  21. void
  22. port_callback (jack_port_id_t port, int yn, void* arg)
  23. {
  24. printf ("Port %d %s\n", port, (yn ? "registered" : "unregistered"));
  25. }
  26. void
  27. connect_callback (jack_port_id_t a, jack_port_id_t b, int yn, void* arg)
  28. {
  29. printf ("Ports %d and %d %s\n", a, b, (yn ? "connected" : "disconnected"));
  30. }
  31. void
  32. client_callback (const char* client, int yn, void* arg)
  33. {
  34. printf ("Client %s %s\n", client, (yn ? "registered" : "unregistered"));
  35. }
  36. int
  37. graph_callback (void* arg)
  38. {
  39. printf ("Graph reordered\n");
  40. return 0;
  41. }
  42. int
  43. main (int argc, char *argv[])
  44. {
  45. jack_client_t *client;
  46. jack_options_t options = JackNullOption;
  47. jack_status_t status;
  48. if ((client = jack_client_open ("event-monitor", options, &status, NULL)) == 0) {
  49. fprintf (stderr, "jack_client_open() failed, "
  50. "status = 0x%2.0x\n", status);
  51. if (status & JackServerFailed) {
  52. fprintf (stderr, "Unable to connect to JACK server\n");
  53. }
  54. return 1;
  55. }
  56. if (jack_set_port_registration_callback (client, port_callback, NULL)) {
  57. fprintf (stderr, "cannot set port registration callback\n");
  58. return 1;
  59. }
  60. if (jack_set_port_connect_callback (client, connect_callback, NULL)) {
  61. fprintf (stderr, "cannot set port connect callback\n");
  62. return 1;
  63. }
  64. if (jack_set_client_registration_callback (client, client_callback, NULL)) {
  65. fprintf (stderr, "cannot set client registration callback\n");
  66. return 1;
  67. }
  68. if (jack_set_graph_order_callback (client, graph_callback, NULL)) {
  69. fprintf (stderr, "cannot set graph order registration callback\n");
  70. return 1;
  71. }
  72. if (jack_activate (client)) {
  73. fprintf (stderr, "cannot activate client");
  74. return 1;
  75. }
  76. sleep (-1);
  77. exit (0);
  78. }