From: Clemens Ladisch Date: Fri, 13 May 2005 05:50:28 +0000 (+0200) Subject: [ALSA] usb-audio - avoid unnecessary double buffering X-Git-Tag: v2.6.13-rc1~68^2~629 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29b16931f936fdbcd78995e66d0f5626f3afbda8;p=linux-2.6 [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 --- diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index a6ed0d0833..076da19a9e 100644 --- a/sound/usb/usbaudio.c +++ b/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;