[alsa-devel] [patch] snd_pcm_drain and lock-ups

Mike Gorse mgorse at mgorse.dhs.org
Thu Sep 20 02:54:07 CEST 2007

Hi again,

I posted last week because I am getting lockups when portaudio calls 
snd_pcm_drain, and snd_pcm_rate_drain calls snd_pcm_wait on its slave.

Now that I've looked at this more, I'm seeing that it involves dmix, since 
a dmix plugin is behind the rate plugin.

The dmix code in alsa-lib is setting a xrun state because 
snd_pcm_mmap_playback_avail returns a large value.

snd_pcm_wait is then called on the slave of the rate pcm, which is a pcm 
with a type of SND_PCM_TYPE_ROUTE whose slave is the dmix, but the route 
pcm is returning a different value for snd_pcm_mmap_avail than the dmix 
pcm, so it is not triggering snd_pcm_wait to check for a xrun.

The following patch stops snd_pcm_wait from locking up for me, although 
I'm not sure if it is the best way of handling things:

--- src/pcm/pcm.c.orig	2007-09-12 05:20:32.000000000 -0400
+++ src/pcm/pcm.c	2007-09-19 19:52:10.000000000 -0400
@@ -2255,7 +2255,7 @@
  int snd_pcm_wait(snd_pcm_t *pcm, int timeout)
-	if (snd_pcm_mmap_avail(pcm) >= pcm->avail_min) {
+	if (snd_pcm_mmap_avail(pcm) >= pcm->avail_min || pcm->type == SND_PCM_TYPE_ROUTE) {
  		/* check more precisely */
  		switch (snd_pcm_state(pcm)) {

-- Mike Gorse / AIM:linvortex / http://mgorse.freeshell.org --

More information about the Alsa-devel mailing list