Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 6523
b: refs/heads/master
c: a93bf99
h: refs/heads/master
i:
  6521: 17d1e3c
  6519: 0e95183
v: v3
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed Aug 30, 2005
1 parent 7e5092a commit 5470260
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 71d848ca00a16179b17e58e5f51c2d9a6c4f97a2
refs/heads/master: a93bf99077886d209f8e72bc134e1ceb36e76aa2
20 changes: 14 additions & 6 deletions trunk/sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by
{
unsigned int maxsize, n, i;
int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
unsigned int npacks[MAX_URBS], urb_packs, total_packs;
unsigned int npacks[MAX_URBS], urb_packs, total_packs, packs_per_ms;

/* calculate the frequency in 16.16 format */
if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
Expand All @@ -920,14 +920,18 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by
else
subs->curpacksize = maxsize;

if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
packs_per_ms = 8 >> subs->datainterval;
else
packs_per_ms = 1;

if (is_playback) {
urb_packs = nrpacks;
urb_packs = max(urb_packs, (unsigned int)MIN_PACKS_URB);
urb_packs = min(urb_packs, (unsigned int)MAX_PACKS);
} else
urb_packs = 1;
if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
urb_packs = (urb_packs * 8) >> subs->datainterval;
urb_packs *= packs_per_ms;

/* allocate a temporary buffer for playback */
if (is_playback) {
Expand All @@ -949,8 +953,12 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by
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;
/* round up to multiple of packs_per_ms */
total_packs = (total_packs + packs_per_ms - 1)
& ~(packs_per_ms - 1);
/* we need at least two URBs for queueing */
if (total_packs < 2 * MIN_PACKS_URB * packs_per_ms)
total_packs = 2 * MIN_PACKS_URB * packs_per_ms;
} else {
total_packs = MAX_URBS * urb_packs;
}
Expand All @@ -972,7 +980,7 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by
subs->nurbs = 2;
npacks[0] = (total_packs + 1) / 2;
npacks[1] = total_packs - npacks[0];
} else if (npacks[subs->nurbs-1] < MIN_PACKS_URB) {
} else if (npacks[subs->nurbs-1] < MIN_PACKS_URB * packs_per_ms) {
/* the last packet is too small.. */
if (subs->nurbs > 2) {
/* merge to the first one */
Expand Down

0 comments on commit 5470260

Please sign in to comment.