Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Shengjiu Wang <shengjiu.wang@freescale.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] PCM: snd_pcm_dmix_drain() maybe blocked after suspend and resume
Date: Mon, 08 Jun 2015 13:31:41 +0200	[thread overview]
Message-ID: <s5hsia2iggy.wl-tiwai@suse.de> (raw)
In-Reply-To: <1433756291-22999-1-git-send-email-shengjiu.wang@freescale.com>

At Mon, 8 Jun 2015 17:38:11 +0800,
Shengjiu Wang wrote:
> 
> 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@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)) {

It's better (shorter) to call snd_pcm_state(dmix->spcm) in this case.

And, I think we should have the check of SND_PCM_STATE_SUSPENDED at
the beginning of snd_pcm_dmix_drain() before entering to the loop,
too.

Last but not least, the very same bug is present for dshare.  Could
you fix this together?


thanks,

Takashi

> +			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
> 

  reply	other threads:[~2015-06-08 11:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08  9:38 [PATCH] PCM: snd_pcm_dmix_drain() maybe blocked after suspend and resume Shengjiu Wang
2015-06-08 11:31 ` Takashi Iwai [this message]
2015-06-09  2:35   ` Shengjiu Wang
2015-06-09  5:27     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hsia2iggy.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=shengjiu.wang@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox