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.

84 lines
2.2KB

  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. client_callback (const char* client, int yn, void* arg)
  28. {
  29. printf ("Client %s %s\n", client, (yn ? "registered" : "unregistered"));
  30. }
  31. int
  32. graph_callback (void* arg)
  33. {
  34. printf ("Graph reordered\n");
  35. return 0;
  36. }
  37. int
  38. main (int argc, char *argv[])
  39. {
  40. jack_client_t *client;
  41. jack_options_t options = JackNullOption;
  42. jack_status_t status;
  43. if ((client = jack_client_open ("event-monitor", options, &status, NULL)) == 0) {
  44. fprintf (stderr, "jack_client_open() failed, "
  45. "status = 0x%2.0x\n", status);
  46. if (status & JackServerFailed) {
  47. fprintf (stderr, "Unable to connect to JACK server\n");
  48. }
  49. return 1;
  50. }
  51. if (jack_set_port_registration_callback (client, port_callback, NULL)) {
  52. fprintf (stderr, "cannot set port registration callback\n");
  53. return 1;
  54. }
  55. if (jack_set_client_registration_callback (client, client_callback, NULL)) {
  56. fprintf (stderr, "cannot set client registration callback\n");
  57. return 1;
  58. }
  59. if (jack_set_graph_order_callback (client, graph_callback, NULL)) {
  60. fprintf (stderr, "cannot set graph order registration callback\n");
  61. return 1;
  62. }
  63. if (jack_activate (client)) {
  64. fprintf (stderr, "cannot activate client");
  65. return 1;
  66. }
  67. sleep (-1);
  68. exit (0);
  69. }