[alsa-devel] underruns and strange code in pcm_rate.c (and patch)

Stas Sergeev stsp at aknet.ru
Mon Nov 5 00:48:52 CET 2007


Hi.

I spent 4 week-ends debugging the
constant underruns and lock-ups with
the libao-based programs.
Now I've finally tracked the problem
to some strange code in pcm_rate.c,
namely snd_pcm_rate_poll_descriptors().
I am not sure what was the reason
behind altering the "avail_min" every
time. Looks like some heuristic was
intended, say "see what amount of
fragment part was written now, and
make sure that amount of free space will
be available next time, after poll".
Whatever, this code gives underruns.
It can increase avail_min by almost period_size.
libao sets avail_min==period_size,
so we can end up with avail_min==period_size*2.
libao sets buffer_size==stop_threshold==period_size*2.
So we end up with avail_min~=stop_threshold,
which gives underruns.
Since I don't know how this code was
indended to work, I just removed it,
and everything works perfectly now
(also had to patch libao to check
the returned rate).

The patch is attached, any comments?

Signed-off-by: Stas Sergeev <stsp at aknet.ru>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pcm_rate.diff
Type: text/x-patch
Size: 1676 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20071105/cb8fc54f/attachment.diff 


More information about the Alsa-devel mailing list