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.

72 lines
1.6KB

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