[alsa-devel] Can't detect "XRUNs"

Takashi Iwai tiwai at suse.de
Wed Jul 4 17:14:42 CEST 2018


On Wed, 04 Jul 2018 17:11:17 +0200,
Raphaël Dingé wrote:
> 
> > I'm going back to the program to see if there is anything suspect.
> 
> So I got back to the program and put a bit more logging. I have new
> results, but they are even more confusing.
> 
> Here is the part that writes to the buffer :
> 
>     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++;
>     }
> 
> Not sure if this is the proper way, didn't write it myself, but looks
> more or less legit.
> 
> When I launch the program, nothing is output to the console.
> 
> But! If I echo 1 > xrun_injection, then I have "snd_pcm_avail_update
> failed" systematically.
> 
> However at the same time, no events are traces in
> /sys/kernel/debug/tracing/trace

You applied my patch, right?  Otherwise the xrun injection won't
trigger the xrun tracing event by itself, just calling
snd_pcm_stop().


Takashi


More information about the Alsa-devel mailing list