]> mj.ucw.cz Git - ursary.git/commitdiff
Bury old experiments with Jack
authorMartin Mares <mj@ucw.cz>
Sun, 9 Nov 2014 23:39:22 +0000 (00:39 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 9 Nov 2014 23:39:22 +0000 (00:39 +0100)
Maybe one day I will kick out PulseAudio and beg Jack to forgive.

jt.c [deleted file]

diff --git a/jt.c b/jt.c
deleted file mode 100644 (file)
index 3fa5558..0000000
--- a/jt.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <jack/jack.h>
-
-typedef jack_default_audio_sample_t sample_t;
-
-static jack_client_t *jc;
-static jack_port_t *inport[2], *outport[4];
-
-static int process_callback(jack_nframes_t nframes, void *arg __attribute__((unused)))
-{
-       for (int ch=0; ch<2; ch++) {
-               sample_t *in = jack_port_get_buffer(inport[ch], nframes);
-               sample_t *out = jack_port_get_buffer(outport[ch], nframes);
-               sample_t *out2 = jack_port_get_buffer(outport[2+ch], nframes);
-               for (jack_nframes_t i=0; i<nframes; i++) {
-                       out[i] = in[i];
-                       out2[i] = in[i];
-               }
-       }
-       return 0;
-}
-
-static void port_callback(jack_port_id_t id, int reg, void *arg __attribute__((unused)))
-{
-       jack_port_t *p = jack_port_by_id(jc, id);
-       if (!p) {
-               puts("port_callback: lookup failed");
-               return;
-       }
-       const char *name = jack_port_name(p);
-       printf("%s port %s\n", (reg ? "Registered" : "Unregistered"), name);
-
-       const char *ss = strstr(name, ":from_slave_");
-       if (reg && ss) {
-               char *to = (ss[12] == '1' ? "brum:in1" : "brum:in2");
-               printf("\t... connecting to %s\n", to);
-               if (jack_connect(jc, name, to))
-                       puts("jack_connect failed");
-       }
-}
-
-int main(void)
-{
-       jc = jack_client_open("brum", JackNoStartServer, NULL);
-       if (!jc) {
-               puts("jack_client_open failed");
-               return 1;
-       }
-
-       for (int i=0; i<2; i++) {
-               char name[16];
-               sprintf(name, "in%d", i+1);
-               inport[i] = jack_port_register(jc, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
-               if (!inport[i]) {
-                       puts("jack_port_register failed");
-                       return 1;
-               }
-       }
-
-       for (int i=0; i<4; i++) {
-               char name[16];
-               sprintf(name, "out%d", i+1);
-               outport[i] = jack_port_register(jc, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
-               if (!outport[i]) {
-                       puts("jack_port_register failed");
-                       return 1;
-               }
-       }
-
-       jack_set_process_callback(jc, process_callback, NULL);
-       jack_set_port_registration_callback(jc, port_callback, NULL);
-
-       if (jack_activate(jc)) {
-               puts("jack_activate failed");
-               return 1;
-       }
-
-       puts("Connecting ports...");
-       for (int i=1; i<=4; i++) {
-               char a[32], b[32];
-               sprintf(a, "brum:out%d", i);
-               sprintf(b, "system:playback_%d", i);
-               if (jack_connect(jc, a, b))
-                       printf("Failed to connect %s -> %s\n", a, b);
-       }
-
-       puts("Running...");
-       char xxx[16];
-       read(0, xxx, sizeof(xxx));
-
-       puts("exiting");
-       jack_client_close(jc);
-       return 0;
-}