Quellcode durchsuchen

[ALSA] usb-audio - avoid unnecessary double buffering

USB generic driver
When a USB packet boundary falls exactly on a buffer boundary, hwptr
remains at the end of the buffer which causes an overflow in the next
iteration and triggers double buffering although the next packet would
actually be contiguous.

This patch ensures that hwptr is always smaller than buffer_size.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Clemens Ladisch vor 20 Jahren
Ursprung
Commit
29b16931f9
1 geänderte Dateien mit 2 neuen und 0 gelöschten Zeilen
  1. 2 0
      sound/usb/usbaudio.c

+ 2 - 0
sound/usb/usbaudio.c

@@ -565,6 +565,8 @@ static int prepare_playback_urb(snd_usb_substream_t *subs,
 		/* set the buffer pointer */
 		urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride;
 		subs->hwptr += offs;
+		if (subs->hwptr == runtime->buffer_size)
+			subs->hwptr = 0;
 	}
 	spin_unlock_irqrestore(&subs->lock, flags);
 	urb->transfer_buffer_length = offs * stride;