From 8495f42feb7549550e7446912875b646dbf48249 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Nov 2005 10:47:42 +0000 Subject: [PATCH] abort snd_pcm_dmix_drain when state is SND_PCM_STATE_XRU From: Sascha Sommer this is a fix for bug 0001559. Unlike my first guesses the real problem is not in the kernel driver but in alsa-lib. Whenever the current dmix status is xrun and snd_pcm_dmix_drain gets called the process will hang forever in the poll function. The reason is that poll gets called even though the timer already stopped. As described in the bugtracking system this bug was not noticable with alsa versions that used the old IOCTLS because the SNDRV_TIMER_IOCTL_STOP ioctl never reached the timer kernel module. Attached patch fixes this problem for alsa-lib 1.0.10 by simply calling snd_pcm_dmix_drop when snd_pcm_dmix_drain gets called in the state SND_PCM_STATE_XRUN. --- src/pcm/pcm_dmix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index 1d27c09e..958df2c9 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -532,6 +532,12 @@ static int snd_pcm_dmix_drain(snd_pcm_t *pcm) return 0; } } + + if (dmix->state == SND_PCM_STATE_XRUN) { + snd_pcm_dmix_drop(pcm); + return 0; + } + stop_threshold = pcm->stop_threshold; if (pcm->stop_threshold > pcm->buffer_size) pcm->stop_threshold = pcm->buffer_size;