From e8c0d6b418317ef06244f3d89aceee6ee9e342e7 Mon Sep 17 00:00:00 2001 From: sletz Date: Sun, 16 Mar 2008 11:56:19 +0000 Subject: [PATCH] Add control example client git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2014 0c269be4-1314-0410-8aa9-9f06e86f4224 --- example-clients/control.c | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 example-clients/control.c diff --git a/example-clients/control.c b/example-clients/control.c new file mode 100644 index 00000000..ca1cf55f --- /dev/null +++ b/example-clients/control.c @@ -0,0 +1,71 @@ +/** @file simple_client.c + * + * @brief This simple client demonstrates the basic features of JACK + * as they would be used by many applications. + */ + +#include +#include +#include +#include +#include +#include + +jack_client_t *client; +static int reorder = 0; + +static int Jack_Graph_Order_Callback(void *arg) +{ + const char **ports; + int i; + + printf("Jack_Graph_Order_Callback count = %ld\n", reorder++); + + ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput); + for (i = 0; ports[i]; ++i) { + printf("name: %s\n", ports[i]); + } + free(ports); + + ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical|JackPortIsInput); + for (i = 0; ports[i]; ++i) { + printf("name: %s\n", ports[i]); + } + free(ports); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + jack_options_t options = JackNullOption; + jack_status_t status; + char c; + + /* open a client connection to the JACK server */ + + client = jack_client_open("control_client", options, &status); + if (client == NULL) { + printf("jack_client_open() failed \n"); + exit(1); + } + + if (jack_set_graph_order_callback(client, Jack_Graph_Order_Callback, 0) != 0) { + printf("Error when calling jack_set_graph_order_callback() !\n"); + } + + /* Tell the JACK server that we are ready to roll. Our + * process() callback will start running now. */ + + if (jack_activate(client)) { + printf("cannot activate client"); + exit(1); + } + + printf("Type 'q' to quit\n"); + while ((getchar() != 'q')) {} + + jack_client_close(client); + exit (0); +}