Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH] ALSA: pcm: Don't issue XRUN during draining
Date: Mon, 25 Nov 2024 15:57:55 +0100	[thread overview]
Message-ID: <20241125145757.22891-1-tiwai@suse.de> (raw)

snd_pcm_stop_xrun() checks the stream status with snd_pcm_running()
helper, but this isn't really correct; namely, snd_pcm_running()
returns true also when the stream is in draining, but in principle,
the xrun at draining means nothing but the draining finished.  Hence,
we shouldn't issue XRUN when it happens during draining.

That is, for a proper state check, we should check the state only for
SNDRV_PCM_STATE_RUNNING, instead.

Fixes: 1fb8510cdb5b ("ALSA: pcm: Add snd_pcm_stop_xrun() helper")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/pcm_native.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 381a476a1045..7bcca443e333 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1577,7 +1577,8 @@ int snd_pcm_drain_done(struct snd_pcm_substream *substream)
 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
 {
 	guard(pcm_stream_lock_irqsave)(substream);
-	if (substream->runtime && snd_pcm_running(substream))
+	if (substream->runtime &&
+	    substream->runtime->state == SNDRV_PCM_STATE_RUNNING)
 		__snd_pcm_xrun(substream);
 	return 0;
 }
-- 
2.43.0


                 reply	other threads:[~2024-11-25 14:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20241125145757.22891-1-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-sound@vger.kernel.org \
    /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