summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..a821ef3
--- /dev/null
+++ b/main.c
@@ -0,0 +1,43 @@
1#include <jack/jack.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5static void
6registration_cb(jack_port_id_t port_id, int is_registered, void *arg)
7{
8 jack_client_t *client = (jack_client_t *)arg;
9 jack_port_t *port = jack_port_by_id(client, port_id);
10 const char *port_name = jack_port_name(port);
11
12 if (is_registered) {
13 printf("%s registered\n", port_name);
14 } else {
15 printf("%s unregistered\n", port_name);
16 }
17}
18
19int
20main(void)
21{
22 jack_client_t *client;
23
24 client = jack_client_open("jack_connectd", JackNullOption, NULL);
25 if (client == NULL) {
26 fprintf(stderr, "Failed to connect to JACK server.\n");
27 return 1;
28 }
29
30 /* client is passed as arg so it can be used within cb */
31 jack_set_port_registration_callback(client, registration_cb, client);
32
33 /* start processing callbacks */
34 if (jack_activate(client) != 0) {
35 fprintf(stderr, "Failed to activate JACK client.\n");
36 return 1;
37 }
38
39 /* do nothing else while waiting */
40 for (;;);
41
42 return 0;
43}