]> err.no Git - linux-2.6/commitdiff
[ALSA] usb-audio - avoid unnecessary double buffering
authorClemens Ladisch <clemens@ladisch.de>
Fri, 13 May 2005 05:50:28 +0000 (07:50 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sun, 29 May 2005 08:08:53 +0000 (10:08 +0200)
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>
sound/usb/usbaudio.c

index a6ed0d08337e486ad46841e3dc0af5875a53da0e..076da19a9e282ff6c8dc415c9e68df57d74c34f3 100644 (file)
@@ -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;