blob: a821ef3b594524780ef81b9ba39cbc89da698714 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <jack/jack.h>
#include <stdio.h>
#include <stdlib.h>
static void
registration_cb(jack_port_id_t port_id, int is_registered, void *arg)
{
jack_client_t *client = (jack_client_t *)arg;
jack_port_t *port = jack_port_by_id(client, port_id);
const char *port_name = jack_port_name(port);
if (is_registered) {
printf("%s registered\n", port_name);
} else {
printf("%s unregistered\n", port_name);
}
}
int
main(void)
{
jack_client_t *client;
client = jack_client_open("jack_connectd", JackNullOption, NULL);
if (client == NULL) {
fprintf(stderr, "Failed to connect to JACK server.\n");
return 1;
}
/* client is passed as arg so it can be used within cb */
jack_set_port_registration_callback(client, registration_cb, client);
/* start processing callbacks */
if (jack_activate(client) != 0) {
fprintf(stderr, "Failed to activate JACK client.\n");
return 1;
}
/* do nothing else while waiting */
for (;;);
return 0;
}
|