All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Re: [PATCH] ALSA: pcm: Show closed for DISCONNECTED state
@ 2026-06-16  2:06 Ai Chao
  2026-06-16  7:24 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Ai Chao @ 2026-06-16  2:06 UTC (permalink / raw)
  To: perex, tiwai, kees; +Cc: linux-sound, linux-kernel

Hello Takashi

>Hmm, why it must be that?  The state is shown as "DISCONNECTED".
>
>IOW, does this matter for which application and how do we have to
>imitate as if the file got closed?

Test Environment: Dual-boot Linux and Android system.

Issue: When a recording app is opened in Linux, the system is switched to Android,
and then switched back to Linux, the recording app fails to save the recording
and keeps prompting "generating recording file".

Note: The USB hub resets during the system switching process.

Root Cause Analysis (from App Engineer): The recording app relies on the driver to
report the IN_CLOSE_WRITE event. Upon receiving this, the audio service
checks /proc/asound/card0/pcm0*/sub0/status. If the value is not "close", it assumes
the sound card is occupied and skips loading; if the value is "close", it considers
the sound card available and loads it normally.
syslog:
[ 1140.495952] retire_capture_urb: 17 callbacks suppressed
[ 1140.583090] usb 1-2.4.2: USB disconnect, device number 53
[ 1140.583965] usb 1-2.4.2: cannot submit urb (err = -19)
[ 1140.588816] usb 1-2.4.2: cannot submit urb 0, error -19: no device
[ 1140.662630] usb 2-4.3: USB disconnect, device number 15
[ 1140.722584] usb 1-2.3: USB disconnect, device number 51
[ 1140.722605] usb 1-2.3.2: USB disconnect, device number 52
[ 1140.805724] usb 2-4.4: USB disconnect, device number 16
[ 1141.352341] usb 1-2.3.3: USB disconnect, device number 54
[ 1141.558840] hub 1-2.4:1.0: hub_ext_port_status failed (err = -71)
[ 1141.613714] usb 1-2.3.5: USB disconnect, device number 55
[ 1141.757651] usb 1-2.4: USB disconnect, device number 49
[ 1144.324836] usb 1-2.4: new high-speed USB device number 56 using xhci_hcd
[ 1144.473047] usb 1-2.4: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11
[ 1144.473065] usb 1-2.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1144.473072] usb 1-2.4: Product: USB 2.0 Hub
[ 1144.473738] hub 1-2.4:1.0: USB hub found
[ 1144.473765] hub 1-2.4:1.0: 4 ports detected

Thanks,
Ai Chao

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH] ALSA: pcm: Show closed for DISCONNECTED state
@ 2026-06-15 13:26 Ai Chao
  2026-06-15 13:51 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Ai Chao @ 2026-06-15 13:26 UTC (permalink / raw)
  To: perex, tiwai, kees; +Cc: linux-sound, linux-kernel, Ai Chao

Show "closed" for DISCONNECTED state allow audio service
to detect USB reset/disconnect and reinitialize the device.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
 sound/core/pcm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index bfedf571e021..6ce35492ea56 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -450,6 +450,14 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
 		snd_iprintf(buffer, "error %d\n", err);
 		return;
 	}
+	/*
+	 * Show "closed" for DISCONNECTED state allow audio service
+	 * to detect USB reset/disconnect and reinitialize the device.
+	 */
+	if (status.state == SNDRV_PCM_STATE_DISCONNECTED) {
+		snd_iprintf(buffer, "closed\n");
+		return;
+	}
 	snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
 	snd_iprintf(buffer, "owner_pid   : %d\n", pid_vnr(substream->pid));
 	snd_iprintf(buffer, "trigger_time: %lld.%09lld\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-16  7:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16  2:06 Re: [PATCH] ALSA: pcm: Show closed for DISCONNECTED state Ai Chao
2026-06-16  7:24 ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2026-06-15 13:26 Ai Chao
2026-06-15 13:51 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.