ALSA: usb-audio: Prevent starting of audio stream if in use
authorWesley Cheng <quic_wcheng@quicinc.com>
Wed, 9 Apr 2025 19:47:44 +0000 (12:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Apr 2025 11:02:30 +0000 (13:02 +0200)
commitf15d1e557b01b19f4b20aae8cf1a1f2b1f565571
tree1978a6e760f6e761ccf7f242a4b5b3beffcf3959
parentd893d5eaabfa948e983cc447bacf80a8306358da
ALSA: usb-audio: Prevent starting of audio stream if in use

With USB audio offloading, an audio session is started from the ASoC
platform sound card and PCM devices.  Likewise, the USB SND path is still
readily available for use, in case the non-offload path is desired.  In
order to prevent the two entities from attempting to use the USB bus,
introduce a flag that determines when either paths are in use.

If a PCM device is already in use, the check will return an error to
userspace notifying that the stream is currently busy.  This ensures that
only one path is using the USB substream.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20250409194804.3773260-12-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/card.h
sound/usb/pcm.c