Patch "ALSA: usb-audio: Notify xrun for low-latency mode" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ALSA: usb-audio: Notify xrun for low-latency mode

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     alsa-usb-audio-notify-xrun-for-low-latency-mode.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9051d85f4a4e99d173be5df5b19064c0b095385c
Author: Takashi Iwai <tiwai@xxxxxxx>
Date:   Thu Nov 28 09:04:16 2024 +0100

    ALSA: usb-audio: Notify xrun for low-latency mode
    
    [ Upstream commit 4f9d674377d090e38d93360bd4df21b67534d622 ]
    
    The low-latency mode of USB-audio driver uses a similar approach like
    the implicit feedback mode but it has an explicit queuing at the
    trigger start time.  The difference is, however, that no packet will
    be handled any longer after all queued packets are handled but no
    enough data is fed.  In the case of implicit feedback mode, the
    capture-side packet handling triggers the re-queuing, and this checks
    the XRUN.  OTOH, in the low-latency mode, it just stops without XRUN
    notification unless any new action is taken from user-space via ack
    callback.  For example, when you stop the stream in aplay, no XRUN is
    reported.
    
    This patch adds the XRUN check at the packet complete callback in the
    case all pending URBs are exhausted.  Strictly speaking, this state
    doesn't match really with XRUN; in theory the application may queue
    immediately after this happens.  But such behavior is only for
    1-period configuration, which the USB-audio driver doesn't support.
    So we may conclude that this situation leads certainly to XRUN.
    
    A caveat is that the XRUN should be triggered only for the PCM RUNNING
    state, and not during DRAINING.  This additional state check is put in
    notify_xrun(), too.
    
    Fixes: d5f871f89e21 ("ALSA: usb-audio: Improved lowlatency playback support")
    Reported-by: Leonard Crestez <cdleonard@xxxxxxxxx>
    Link: https://lore.kernel.org/25d5b0d8-4efd-4630-9d33-7a9e3fa9dc2b@xxxxxxxxx
    Link: https://patch.msgid.link/20241128080446.1181-1-tiwai@xxxxxxx
    Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 647fa054d8b1d..e3684dfa5f1fa 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -403,10 +403,15 @@ static int prepare_inbound_urb(struct snd_usb_endpoint *ep,
 static void notify_xrun(struct snd_usb_endpoint *ep)
 {
 	struct snd_usb_substream *data_subs;
+	struct snd_pcm_substream *psubs;
 
 	data_subs = READ_ONCE(ep->data_subs);
-	if (data_subs && data_subs->pcm_substream)
-		snd_pcm_stop_xrun(data_subs->pcm_substream);
+	if (!data_subs)
+		return;
+	psubs = data_subs->pcm_substream;
+	if (psubs && psubs->runtime &&
+	    psubs->runtime->state == SNDRV_PCM_STATE_RUNNING)
+		snd_pcm_stop_xrun(psubs);
 }
 
 static struct snd_usb_packet_info *
@@ -557,7 +562,10 @@ static void snd_complete_urb(struct urb *urb)
 			push_back_to_ready_list(ep, ctx);
 			clear_bit(ctx->index, &ep->active_mask);
 			snd_usb_queue_pending_output_urbs(ep, false);
-			atomic_dec(&ep->submitted_urbs); /* decrement at last */
+			/* decrement at last, and check xrun */
+			if (atomic_dec_and_test(&ep->submitted_urbs) &&
+			    !snd_usb_endpoint_implicit_feedback_sink(ep))
+				notify_xrun(ep);
 			return;
 		}
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux