3 * By Daniel Borkmann <daniel@netyack.org>
4 * Copyright 2011 Daniel Borkmann.
13 #include <jack/jack.h>
14 #include <celt/celt.h>
15 #include <speex/speex_jitter.h>
18 #include "error_and_die.h"
20 static jack_port_t
*input
;
21 static jack_port_t
*output
;
23 static jack_client_t
*client
;
25 int jack_process_new_frames(jack_nframes_t nframes
, void *arg
)
27 jack_default_audio_sample_t
*in
, *out
;
29 in
= jack_port_get_buffer(input
, nframes
);
30 out
= jack_port_get_buffer(output
, nframes
);
32 memcpy(out
, in
, sizeof(*in
) * nframes
);
37 void jack_shutdown(void *arg
)
42 void jack_setup(char *name
)
47 jack_options_t options
= JackNoStartServer
;
50 client
= jack_client_open(name
, options
, &status
, NULL
);
52 whine("Opening JACK client failed (0x%2.0x)\n", status
);
53 if (status
& JackServerFailed
)
54 whine("JACK server not running?\n");
58 jack_set_process_callback(client
, jack_process_new_frames
, 0);
59 jack_on_shutdown(client
, jack_shutdown
, 0);
61 input
= jack_port_register(client
, "input", JACK_DEFAULT_AUDIO_TYPE
,
63 output
= jack_port_register(client
, "output", JACK_DEFAULT_AUDIO_TYPE
,
65 if (!input
|| !output
)
66 panic("No more JACK ports available!\n");
68 ret
= jack_activate(client
);
70 panic("Cannot activate JACK client!\n");
72 ports
= jack_get_ports(client
, NULL
, NULL
,
73 JackPortIsPhysical
| JackPortIsOutput
);
75 panic("No physical capture ports available!\n");
77 ret
= jack_connect(client
, ports
[0], jack_port_name(input
));
80 panic("Cannot connect input ports!\n");
82 ports
= jack_get_ports(client
, NULL
, NULL
,
83 JackPortIsPhysical
| JackPortIsInput
);
85 panic("No physical playback ports available!\n");
87 ret
= jack_connect(client
, jack_port_name(output
), ports
[0]);
90 panic("Cannot connect output ports!\n");
92 info("plugged to jack\n");
95 int main(int argc
, char **argv
)
98 info("netyack up and running\n");
100 /* Keep running until stopped by the user. */
104 * This is never reached but if the program had some other way to exit
105 * besides being killed, they would be important to call.
108 jack_client_close(client
);