tramp wrote an xrun counter.
Code: Select all
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <jack/jack.h>
/* gcc -Wall xruncounter.c -lm `pkg-config --cflags --libs jack` -o xruncounter */
jack_client_t *client;
void
jack_shutdown (void *arg)
{
exit (1);
}
int jack_xrun_callback(void *arg)
{
/* count xruns */
static int xruns = 0;
xruns += 1;
fprintf (stderr, "xrun %i \n", xruns);
return 0;
}
void
signal_handler (int sig)
{
jack_client_close (client);
fprintf (stderr, " signal received, exiting ...\n");
exit (0);
}
int
main (int argc, char *argv[])
{
if ((client = jack_client_open ("xruncounter", JackNullOption, NULL)) == 0) {
fprintf (stderr, "jack server not running?\n");
return 1;
}
signal (SIGQUIT, signal_handler);
signal (SIGTERM, signal_handler);
signal (SIGHUP, signal_handler);
signal (SIGINT, signal_handler);
jack_set_xrun_callback(client, jack_xrun_callback, 0);
jack_on_shutdown (client, jack_shutdown, 0);
if (jack_activate (client)) {
fprintf (stderr, "cannot activate client");
return 1;
}
while (1) {
usleep (100000);
}
jack_client_close (client);
exit (0);
}
If you copy that and save it as xruncounter.c
you can compile it with the command at the top of the file. This program is the basis of tramp's xruncounter testing tool.