Skip to content

Commit e98696e

Browse files
committed
ALSA: usb-audio: Avoid potentially repeated XRUN error messages
Some XRUN-related error messages may repeat themselves, because there can be multiple pending packets. Modify notify_xrun() function to return whether it's being stopped or not, and show the error message only once when the XRUN is actually handled. Along with it, fix a typo of word package to packet in the error message. Link: https://patch.msgid.link/20260216141209.1849200-5-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent fba2105 commit e98696e

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

sound/usb/endpoint.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,18 +402,21 @@ static int prepare_inbound_urb(struct snd_usb_endpoint *ep,
402402
}
403403

404404
/* notify an error as XRUN to the assigned PCM data substream */
405-
static void notify_xrun(struct snd_usb_endpoint *ep)
405+
static bool notify_xrun(struct snd_usb_endpoint *ep)
406406
{
407407
struct snd_usb_substream *data_subs;
408408
struct snd_pcm_substream *psubs;
409409

410410
data_subs = READ_ONCE(ep->data_subs);
411411
if (!data_subs)
412-
return;
412+
return false;
413413
psubs = data_subs->pcm_substream;
414414
if (psubs && psubs->runtime &&
415-
psubs->runtime->state == SNDRV_PCM_STATE_RUNNING)
415+
psubs->runtime->state == SNDRV_PCM_STATE_RUNNING) {
416416
snd_pcm_stop_xrun(psubs);
417+
return true;
418+
}
419+
return false;
417420
}
418421

419422
static struct snd_usb_packet_info *
@@ -594,8 +597,9 @@ static void snd_complete_urb(struct urb *urb)
594597
return;
595598

596599
if (!atomic_read(&ep->chip->shutdown)) {
597-
usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
598-
notify_xrun(ep);
600+
if (notify_xrun(ep))
601+
usb_audio_err(ep->chip,
602+
"cannot submit urb (err = %d)\n", err);
599603
}
600604

601605
exit_clear:
@@ -1779,10 +1783,11 @@ static void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
17791783
spin_lock_irqsave(&ep->lock, flags);
17801784
if (ep->next_packet_queued >= ARRAY_SIZE(ep->next_packet)) {
17811785
spin_unlock_irqrestore(&ep->lock, flags);
1782-
usb_audio_err(ep->chip,
1783-
"next package FIFO overflow EP 0x%x\n",
1784-
ep->ep_num);
1785-
notify_xrun(ep);
1786+
if (notify_xrun(ep)) {
1787+
usb_audio_err(ep->chip,
1788+
"next packet FIFO overflow EP 0x%x\n",
1789+
ep->ep_num);
1790+
}
17861791
return;
17871792
}
17881793

0 commit comments

Comments
 (0)