From 712a924fa2230288bb0786ab11933a99a4cca3b7 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 12 Jan 2006 08:19:21 +0100 Subject: [PATCH] --- yaml --- r: 22685 b: refs/heads/master c: 9568f461e50c023e45ec702027bb1a5f60e443dc h: refs/heads/master i: 22683: d6a68742a2b455127fe195c0c657dde3795ccac0 v: v3 --- [refs] | 2 +- trunk/sound/usb/usbaudio.c | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/[refs] b/[refs] index 55824336e44f..d29484cbb447 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7c79b7682ee6318a8e47173b158846ed0edd8f1a +refs/heads/master: 9568f461e50c023e45ec702027bb1a5f60e443dc diff --git a/trunk/sound/usb/usbaudio.c b/trunk/sound/usb/usbaudio.c index d5013383fad7..f5aadb001986 100644 --- a/trunk/sound/usb/usbaudio.c +++ b/trunk/sound/usb/usbaudio.c @@ -475,6 +475,18 @@ static int retire_playback_sync_urb_hs(struct snd_usb_substream *subs, return 0; } +/* determine the number of frames in the next packet */ +static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs) +{ + if (subs->fill_max) + return subs->maxframesize; + else { + subs->phase = (subs->phase & 0xffff) + + (subs->freqm << subs->datainterval); + return min(subs->phase >> 16, subs->maxframesize); + } +} + /* * Prepare urb for streaming before playback starts. * @@ -492,16 +504,7 @@ static int prepare_startup_playback_urb(struct snd_usb_substream *subs, urb->dev = ctx->subs->dev; urb->number_of_packets = subs->packs_per_ms; for (i = 0; i < subs->packs_per_ms; ++i) { - /* calculate the size of a packet */ - if (subs->fill_max) - counts = subs->maxframesize; /* fixed */ - else { - subs->phase = (subs->phase & 0xffff) - + (subs->freqm << subs->datainterval); - counts = subs->phase >> 16; - if (counts > subs->maxframesize) - counts = subs->maxframesize; - } + counts = snd_usb_audio_next_packet_size(subs); urb->iso_frame_desc[i].offset = offs * stride; urb->iso_frame_desc[i].length = counts * stride; offs += counts; @@ -538,16 +541,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, urb->number_of_packets = 0; spin_lock_irqsave(&subs->lock, flags); for (i = 0; i < ctx->packets; i++) { - /* calculate the size of a packet */ - if (subs->fill_max) - counts = subs->maxframesize; /* fixed */ - else { - subs->phase = (subs->phase & 0xffff) - + (subs->freqm << subs->datainterval); - counts = subs->phase >> 16; - if (counts > subs->maxframesize) - counts = subs->maxframesize; - } + counts = snd_usb_audio_next_packet_size(subs); /* set up descriptor */ urb->iso_frame_desc[i].offset = offs * stride; urb->iso_frame_desc[i].length = counts * stride;