Skip to content

Commit

Permalink
[ALSA] usb-audio - avoid unnecessary double buffering
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed May 29, 2005
1 parent 50cdbf1 commit 29b1693
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29b1693

Please sign in to comment.