diff options
Diffstat (limited to 'examples/jackd-talker/jack.c')
-rw-r--r-- | examples/jackd-talker/jack.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/examples/jackd-talker/jack.c b/examples/jackd-talker/jack.c index 214d3d11..dc0d621b 100644 --- a/examples/jackd-talker/jack.c +++ b/examples/jackd-talker/jack.c @@ -8,9 +8,8 @@ #include <jack/ringbuffer.h> #include "jack.h" #include "defines.h" +#include "talker_mrp_client.h" -extern volatile int halt_tx; -extern volatile int listeners; extern volatile int glob_unleash_jack; static jack_port_t** inputports; @@ -30,18 +29,18 @@ static int process(jack_nframes_t nframes, void* arg) { int cnt; static int total; - (void) arg; /* unused */ + struct mrp_talker_ctx *ctx = (struct mrp_talker_ctx *) arg; /* Do nothing until we're ready to begin. */ if (!glob_unleash_jack) { printf ("nothing to do\n"); return 0; } - + for(int i = 0; i < CHANNELS; i++) { in[i] = jack_port_get_buffer(inputports[i], nframes); } - + for (size_t i = 0; i < nframes; i++) { for(int j = 0; j < CHANNELS; j++) { total++; @@ -54,7 +53,7 @@ static int process(jack_nframes_t nframes, void* arg) } else { printf ("Only %i bytes available after %i samples\n", cnt, total); - halt_tx = 1; + ctx->halt_tx = 1; } } } @@ -70,13 +69,13 @@ static int process(jack_nframes_t nframes, void* arg) void jack_shutdown(void* arg) { - (void) arg; /* unused */ + struct mrp_talker_ctx *ctx = (struct mrp_talker_ctx *) arg; printf("JACK shutdown\n"); - halt_tx = 1; + ctx->halt_tx = 1; } -jack_client_t* init_jack(void) +jack_client_t* init_jack(struct mrp_talker_ctx *ctx) { jack_client_t *client; const char *client_name = "simple_talker"; @@ -98,8 +97,8 @@ jack_client_t* init_jack(void) fprintf (stderr, "unique name `%s' assigned\n", client_name); } - jack_set_process_callback(client, process, 0); - jack_on_shutdown(client, jack_shutdown, 0); + jack_set_process_callback(client, process, (void *)ctx); + jack_on_shutdown(client, jack_shutdown, (void *)ctx); if (jack_activate (client)) fprintf (stderr, "cannot activate client"); @@ -115,15 +114,15 @@ jack_client_t* init_jack(void) for(int i = 0; i < CHANNELS; i++) { char* portName; - if (asprintf(&portName, "input%d", i) < 0) + if (asprintf(&portName, "input%d", i) < 0) { fprintf(stderr, "Could not create portname for port %d", i); exit(EXIT_FAILURE); - } - + } + inputports[i] = jack_port_register (client, portName, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); - if (NULL == inputports[i]) + if (NULL == inputports[i]) { fprintf (stderr, "cannot register input port \"%d\"!\n", i); jack_client_close (client); |