[alsa-devel] Can't detect "XRUNs"
Raphaël Dingé
raphael.dinge at ohmforce.com
Thu Jul 5 12:59:55 CEST 2018
>> So I've run with the Audio USB card with your patch, and the behaviour
>> is the same as with HDMI, meaning that echo 1 > xrun_injection outputs
>> a xrun in /sys/kernel/tracing/trace, but apart from that, I never have
>> an xrun.
>
> It means that there is no XRUN error, handled neither in PCM core nor
> USB-audio driver.
It seems I have a total misconception of what is an XRUN then.
What I understand from your reply is that the program I launch doesn't
create XRUNs anyway (but my interpretation might be mistaken).
I changed the code of my test to the following in the write loop :
snd_pcm_wait(pcm, 1000 /* milliseconds */);
snd_pcm_sframes_t avail = snd_pcm_avail_update(pcm);
if (avail < 0)
{
std::cout << "snd_pcm_avail_update failed\n";
snd_pcm_recover (pcm, avail, 1);
}
snd_pcm_sframes_t nb_written = snd_pcm_writei(pcm, &buffer[0],
frames_per_buffer);
if (nb_written < 0) {
std::cout << "snd_pcm_writei failed\n";
snd_pcm_recover(pcm, nb_written, 1 /* silent */);
xrun_count++;
}
usleep (100000); // 100 msec
So basically I introduced a large sleep to force an audio drop (my
buffers are 3 x 64).
But this doesn't trigger an XRUN anyway.
What is unclear for me is if the code above shall trigger an XRUN or not?
Thanks,
Raphael
More information about the Alsa-devel
mailing list