[alsa-devel] [PATCH] PCM: snd_pcm_dmix_drain() maybe blocked after suspend and resume
Shengjiu Wang
shengjiu.wang at freescale.com
Mon Jun 8 11:38:11 CEST 2015
After suspend and resume, the alsa driver is stopped. But if alsa-lib run
into snd_pcm_dmix_drain(), it need to wait avail >= pcm->stop_threshold,
otherwise, it will not exit the loop, so finally it is blocked at poll() of
snd_pcm_wait_nocheck(pcm, -1).
This patch is to add state check after snd_pcm_wait_nocheck(pcm, -1), if
the state is SND_PCM_STATE_SUSPENDED, then return error.
Signed-off-by: Shengjiu Wang <shengjiu.wang at freescale.com>
---
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 babde6a..0cc318e 100644
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -647,6 +647,12 @@ static int snd_pcm_dmix_drain(snd_pcm_t *pcm)
if (dmix->state == SND_PCM_STATE_DRAINING) {
snd_pcm_dmix_sync_area(pcm);
snd_pcm_wait_nocheck(pcm, -1);
+ switch (snd_pcm_state(pcm)) {
+ case SND_PCM_STATE_SUSPENDED:
+ return -ESTRPIPE;
+ default:
+ break;
+ }
snd_pcm_direct_clear_timer_queue(dmix); /* force poll to wait */
}
} while (dmix->state == SND_PCM_STATE_DRAINING);
--
1.7.9.5
More information about the Alsa-devel
mailing list