Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: pcm: update state after xrun
Date: Tue, 27 Oct 2026 14:12:33 +0100	[thread overview]
Message-ID: <20261027131233.17692-1-mikachu@gmail.com> (raw)

If the snd_pcm_update_hw_ptr call from snd_pcm_status is what triggers
the xrun state (eg, as opposed to an IRQ), the returned status->state
was stale and told userspace the device was still playing, so they could
get confused about device state and hang indefinitely.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222201
Signed-off-by: Mikael Magnusson <mikachu@gmail.com>
---
 sound/core/pcm_native.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 35152fae74..62a2bea043 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1132,6 +1132,9 @@ int snd_pcm_status64(struct snd_pcm_substream *substream,
 	status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec;
 	if (snd_pcm_running(substream)) {
 		snd_pcm_update_hw_ptr(substream);
+		/* update_hw_ptr may have put us in xrun state, update state */
+		status->state = runtime->state;
+		status->suspended_state = runtime->suspended_state;
 		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
 			status->tstamp_sec = runtime->status->tstamp.tv_sec;
 			status->tstamp_nsec =

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
-- 
2.38.1


             reply	other threads:[~2026-10-27 13:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 13:12 Mikael Magnusson [this message]
2026-10-27 13:23 ` [PATCH] ALSA: pcm: update state after xrun sashiko-bot
2026-10-27 14:50 ` Takashi Iwai
2026-10-27 17:18   ` Mikael Magnusson

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