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.

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