jack2 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.

76 lines
1.7KB

  1. /** @file simple_client.c
  2. *
  3. * @brief This simple client demonstrates the basic features of JACK
  4. * as they would be used by many applications.
  5. */
  6. #include <stdio.h>
  7. #include <errno.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <signal.h>
  11. #include <math.h>
  12. #include <jack/jack.h>
  13. jack_client_t *client;
  14. static int reorder = 0;
  15. static int Jack_Graph_Order_Callback(void *arg)
  16. {
  17. const char **ports;
  18. int i;
  19. printf("Jack_Graph_Order_Callback count = %d\n", reorder++);
  20. ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput);
  21. if (ports) {
  22. for (i = 0; ports[i]; ++i) {
  23. printf("name: %s\n", ports[i]);
  24. }
  25. free(ports);
  26. }
  27. ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical|JackPortIsInput);
  28. if (ports) {
  29. for (i = 0; ports[i]; ++i) {
  30. printf("name: %s\n", ports[i]);
  31. }
  32. free(ports);
  33. }
  34. return 0;
  35. }
  36. int
  37. main (int argc, char *argv[])
  38. {
  39. jack_options_t options = JackNullOption;
  40. jack_status_t status;
  41. /* open a client connection to the JACK server */
  42. client = jack_client_open("control_client", options, &status);
  43. if (client == NULL) {
  44. printf("jack_client_open() failed \n");
  45. exit(1);
  46. }
  47. if (jack_set_graph_order_callback(client, Jack_Graph_Order_Callback, 0) != 0) {
  48. printf("Error when calling jack_set_graph_order_callback() !\n");
  49. }
  50. /* Tell the JACK server that we are ready to roll. Our
  51. * process() callback will start running now. */
  52. if (jack_activate(client)) {
  53. printf("cannot activate client");
  54. exit(1);
  55. }
  56. printf("Type 'q' to quit\n");
  57. while ((getchar() != 'q')) {}
  58. jack_client_close(client);
  59. exit (0);
  60. }