Page 1 of 1

Log xruns from command line?

Posted: Wed Apr 26, 2017 3:52 am
by to7m
Hi all,

I'm looking to do some xrun testing without a desktop environment for the purpose of taking DE problems out of the equation, so any hints on how to go about that would be great. The only methods I've seen so far involve GUIs.

Thanks,
Tom

Re: Log xruns from command line?

Posted: Wed May 03, 2017 1:43 pm
by gimmeapill
No idea how to actually count xruns from the CLI, but wondering about your test: what audio console application are you going to put some load on the system? Just measuring xruns on a system that is running idle is probably to going to tell you much...

The closest thing I can think of is cyclictest (part of the rt-tests suite):
https://rt.wiki.kernel.org/index.php/Cyclictest

It will catch latency peaks while simulating a workload, which is essentially the same thing...

Re: Log xruns from command line?

Posted: Wed May 03, 2017 2:00 pm
by gimmeapill
Actually, just starting jackd from the command line in verbose mode with "-v" should do the trick and spit out some xrun messages.
(Sorry I'm not in front of my linux box to confirm)

Re: Log xruns from command line?

Posted: Wed May 03, 2017 5:15 pm
by tramp
. . or write a little app witch counts the xruns.

xruncounter.c

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);
}

Re: Log xruns from command line?

Posted: Wed May 03, 2017 7:58 pm
by gimmeapill
tramp you're overdoing it ;-)

Confirmed: Just running jackd from a terminal with whatever setting you have in .jackdrc will show xruns as they happen (-v is not even needed).

Re: Log xruns from command line?

Posted: Wed May 03, 2017 8:28 pm
by CrocoDuck
tramp wrote:. . or write a little app witch counts the xruns.
I was thinking of doing the same... but actually haven't got enough time (being a noob, it would require me 100 X the time). I recently coded a little algorithm at work to assess whether detected events of some kind are correlated to each other... just wondering whether that could be of some use with xruns stats...

Re: Log xruns from command line?

Posted: Wed May 03, 2017 9:44 pm
by gimmeapill
@Crocoduck: not sure if this can help with your project since he does it offline, but this chap has dissected xruns with lttng and latency_tracker:
http://lttng.org/blog/2016/01/06/monito ... latencies/

I had one embryonic package prepared to try this out, but never had time to push it further.
If you're interested, I'll happily hand it over as I'm really short on time those days:
https://aur.archlinux.org/packages/latency-tracker-git/

OK, and another thread that went off the rails - sorry OP, I'll stop there ;-)

Re: Log xruns from command line?

Posted: Wed Jan 02, 2019 8:44 am
by raboof
tramp wrote:. . or write a little app witch counts the xruns.
This is pretty neat, perhaps we should share it on github or so for easier collaboration/evolution?