jack_connectd

Simple daemon for connecting and disconnecting ports upon registration for the JACK audio system
Log | Files | Refs | README | LICENSE

commit d59bcc1c67be40e9176e08f05d64ce71dabe4c4a
parent 120c63bcaa15bcee927f22157f799b8795851c8f
Author: vin <git@vineetk.net>
Date:   Fri, 30 May 2025 21:20:25 -0400

able to know when clients are un/registered

Diffstat:
Amain.c | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -0,0 +1,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; +}