7 typedef jack_default_audio_sample_t sample_t;
9 static jack_client_t *jc;
10 static jack_port_t *inport[2], *outport[4];
12 static int process_callback(jack_nframes_t nframes, void *arg __attribute__((unused)))
14 for (int ch=0; ch<2; ch++) {
15 sample_t *in = jack_port_get_buffer(inport[ch], nframes);
16 sample_t *out = jack_port_get_buffer(outport[ch], nframes);
17 sample_t *out2 = jack_port_get_buffer(outport[2+ch], nframes);
18 for (jack_nframes_t i=0; i<nframes; i++) {
26 static void port_callback(jack_port_id_t id, int reg, void *arg __attribute__((unused)))
28 jack_port_t *p = jack_port_by_id(jc, id);
30 puts("port_callback: lookup failed");
33 const char *name = jack_port_name(p);
34 printf("%s port %s\n", (reg ? "Registered" : "Unregistered"), name);
36 const char *ss = strstr(name, ":from_slave_");
38 char *to = (ss[12] == '1' ? "brum:in1" : "brum:in2");
39 printf("\t... connecting to %s\n", to);
40 if (jack_connect(jc, name, to))
41 puts("jack_connect failed");
47 jc = jack_client_open("brum", JackNoStartServer, NULL);
49 puts("jack_client_open failed");
53 for (int i=0; i<2; i++) {
55 sprintf(name, "in%d", i+1);
56 inport[i] = jack_port_register(jc, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
58 puts("jack_port_register failed");
63 for (int i=0; i<4; i++) {
65 sprintf(name, "out%d", i+1);
66 outport[i] = jack_port_register(jc, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
68 puts("jack_port_register failed");
73 jack_set_process_callback(jc, process_callback, NULL);
74 jack_set_port_registration_callback(jc, port_callback, NULL);
76 if (jack_activate(jc)) {
77 puts("jack_activate failed");
81 puts("Connecting ports...");
82 for (int i=1; i<=4; i++) {
84 sprintf(a, "brum:out%d", i);
85 sprintf(b, "system:playback_%d", i);
86 if (jack_connect(jc, a, b))
87 printf("Failed to connect %s -> %s\n", a, b);
92 read(0, xxx, sizeof(xxx));
95 jack_client_close(jc);