[FFmpeg-devel] [PATCH] ALSA for libavdevice

Luca Abeni lucabe72
Mon Dec 29 01:39:45 CET 2008

Hi all,

On Sun, 2008-12-28 at 21:39 +0100, Nicolas George wrote:
> (I was busy and not well last seek, I am a bit late in my various works.
> Sorry.)
> Le quintidi 5 niv?se, an CCXVII, Stefano Sabatini a ?crit :
> > Maybe complaining upstream could help, if we get it fixed then we just
> > have to check for some ALSA version, rather than put random magik in
> > configure.
> Although I completely agree this should be reported upstream (but I can not
> do it myself, because It Works For Me(tm))
Ok; since I had some non working alsa installations, I decided to have a
better look at this issue... I downloaded the source for the latest alsa
lib, and I tried to debug the problem.

Here is a summary of my findings: maybe someone can report them to the
alsa people, or can suggest a possible solution to our current

It turned out that snd_pcm_htimestamp() hangs in
src/pcm/pcm_dsnoop.c:snd_pcm_dsnoop_htimestamp(), which enters an
endless loop... Looking at the code (see
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm_dsnoop.c;h=9d42c1230339129b95d6e06aecfe8b95ca276726;hb=HEAD )
it seems that snd_pcm_dsnoop_htimestamp() is just broken (look at the
"ok" variable: it is never set to 1...).
I discovered that there is a file named src/pcm/pcm_hw.c which
implements a similar function (snd_pcm_hw_htimestamp()) in a correct
way... So, I added an "ok = 1" at the end of the while loop in
snd_pcm_dsnoop_htimestamp() (similarly to what snd_pcm_hw_htimestamp()
does) and everything is now working correctly ;-)

So, summing up:
1) It seems that my alsa library is configured to use
"pcm_dsnoop" (whatever it is :), whereas Nicolas is probably using
"pcm_hw". Now, I do not really know what "dsnoop" is, nor why my alsa is
trying to use it (I did not change anything in my alsa
configuration...). This is probably why Nicolas is not seeing the
problem I am experiencing. How can I use "pcm_hw" instead of this broken
2) I believe pcm_dsnoop.c is broken (in particular, the
snd_pcm_dsnoop_htimestamp() function is missing an "ok = 1" at the end
of the while loop... This is still broken in alsa git. Maybe someone
with a better alsa knowledge than me can check, and report the problem?

> I am pondering the best way to implement a robust generic timestamp filter
> that will allow to just use av_gettime.
I think that your current code is the best solution in the long term,
but we really need a fallback solution until alsa lib is fixed (or we
need to document how to use "pcm_hw" instead of "pcm_dsnoop").
Maybe a possible solution is to have a configure check for the presence
of snd_pcm_htimestamp(), and to provide some mechanism for allowing the
user to disable the usage of such function (if alsalib provides it, but
it is broken)...


More information about the ffmpeg-devel mailing list