[alsa-devel] Available frames > buffer size

Clemens Ladisch clemens at ladisch.de
Thu Dec 10 20:24:50 CET 2015


Rob Duncan wrote:
> Is it ever correct for snd_pcm_avail() to return a value that’s greater
> than that returned by snd_pcm_hw_params_get_buffer_size()?

Yes, but only if have disabled stop-on-underrun (by setting the
stop_threshold to the boundary value).

> the writei() call returns 2080.  I immediately ask how many frames are
> available now (I usually get a small number in response ~ 20-30) but
> this time I get an XRUN.

The XRUN state can indicate either an underrun or some other error that
makes the stream stop.  What exactly that some other error could be
depends on the driver.

> I call snd_pcm_recover() and then snd_pcm_avail() again and now I get
> 4126 frames.
>
> As you can see the time between these two logs is less than
> 1 millisecond, so I don’t understand how the PCM can go from
> 2080 frames available to >4096 frames available so quickly.

This sounds like a bug. Which version of alsa-lib are you using?


Regards,
Clemens


More information about the Alsa-devel mailing list