Skip to content

Commit 809f44a

Browse files
committed
ALSA: usb-audio: Clear fixed clock rate at closing EP
The recent commit c11117b ("ALSA: usb-audio: Refcount multiple accesses on the single clock") tries to manage the clock rate shared by several endpoints. This was intended for avoiding the unmatched rate by a different endpoint, but unfortunately, it introduced a regression for PulseAudio and pipewire, too; those applications try to probe the multiple possible rates (44.1k and 48kHz) and setting up the normal rate fails but only the last rate is applied. The cause is that the last sample rate is still left to the clock reference even after closing the endpoint, and this value is still used at the next open. It happens only when applications set up via PCM prepare but don't start/stop the stream; the rate is reset when the stream is stopped, but it's not cleared at close. This patch addresses the issue above, simply by clearing the rate set in the clock reference at the last close of each endpoint. Fixes: c11117b ("ALSA: usb-audio: Refcount multiple accesses on the single clock") Reported-by: Jason A. Donenfeld <[email protected]> Tested-by: Jason A. Donenfeld <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2620 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d29f590 commit 809f44a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/usb/endpoint.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip,
925925
endpoint_set_interface(chip, ep, false);
926926

927927
if (!--ep->opened) {
928+
if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked))
929+
ep->clock_ref->rate = 0;
928930
ep->iface = 0;
929931
ep->altsetting = 0;
930932
ep->cur_audiofmt = NULL;

0 commit comments

Comments
 (0)