ALSA: usb-audio: Avoid killing in-flight URBs during draining
authorTakashi Iwai <tiwai@suse.de>
Wed, 29 Sep 2021 08:08:44 +0000 (10:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Dec 2021 08:04:37 +0000 (09:04 +0100)
commit458871f21e693ce64906b7481bd4aa522c6aceb6
tree063fbd6e04bf66e025579a8d99b35bacb679464e
parentff39117fac654c908845f1781ffeb7128baef979
ALSA: usb-audio: Avoid killing in-flight URBs during draining

commit 813a17cab9b708bbb1e0db8902e19857b57196ec upstream.

While draining a stream, ALSA PCM core stops the stream by issuing
snd_pcm_stop() after all data has been sent out.  And, at PCM trigger
stop, currently USB-audio driver kills the in-flight URBs explicitly,
then at sync-stop ops, sync with the finish of all remaining URBs.
This might result in a drop of the drained samples as most of
USB-audio devices / hosts allow relatively long in-flight samples (as
a sort of FIFO).

For avoiding the trimming, this patch changes the stream-stop behavior
during PCM draining state.  Under that condition, the pending URBs
won't be killed.  The leftover in-flight URBs are caught by the
sync-stop operation that shall be performed after the trigger-stop
operation.

Link: https://lore.kernel.org/r/20210929080844.11583-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/endpoint.c
sound/usb/endpoint.h
sound/usb/pcm.c