Skip to content

Commit

Permalink
[ALSA] usb-audio: fix packets per URB calculation for playback
Browse files Browse the repository at this point in the history
USB generic driver
When determining how many packets are needed for one period, we cannot
assume that all packets have their maximum size -- we always use the
nominal sample rate when sending data, and could use an even lower rate
when the endpoint uses frequency feedback.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed Aug 30, 2005
1 parent 15a24c0 commit d6db392
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,15 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by

/* decide how many packets to be used */
if (is_playback) {
total_packs = (period_bytes + maxsize - 1) / maxsize;
unsigned int minsize;
/* determine how small a packet can be */
minsize = (subs->freqn >> (16 - subs->datainterval))
* (frame_bits >> 3);
/* with sync from device, assume it can be 25% lower */
if (subs->syncpipe)
minsize -= minsize >> 2;
minsize = max(minsize, 1u);
total_packs = (period_bytes + minsize - 1) / minsize;
if (total_packs < 2 * MIN_PACKS_URB)
total_packs = 2 * MIN_PACKS_URB;
} else {
Expand Down

0 comments on commit d6db392

Please sign in to comment.