tree b7bde1b8f54e4cf8224ed6445d6b8cf9977151ab
parent a53fc188ec6fc406276799da465fe789c40d96b2
author Clemens Ladisch <[EMAIL PROTECTED]> Fri, 12 Aug 2005 08:25:26 +0200
committer Jaroslav Kysela <[EMAIL PROTECTED]> Tue, 30 Aug 2005 08:45:04 +0200

[ALSA] usb-audio: use 1 ms URBs when capturing

USB generic driver
When capturing audio data, we do not know beforehand how many samples
the device sends per frame, so we have to use URBs that are as short as
possible to make sure that we can handle period boundaries without any
additional latencies.

Furthermore, the total count of URBs submitted doesn't matter when
capturing, so we can just use the maximum number.

Signed-off-by: Clemens Ladisch <[EMAIL PROTECTED]>

 sound/usb/usbaudio.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(async_unlink, "Use asyn
 
 #define MAX_PACKS      10
 #define MAX_PACKS_HS   (MAX_PACKS * 8) /* in high speed mode */
-#define MAX_URBS       5       /* max. 20ms long packets */
+#define MAX_URBS       8
 #define SYNC_URBS      4       /* always four urbs for sync */
 #define MIN_PACKS_URB  1       /* minimum 1 packet per urb */
 
@@ -920,10 +920,12 @@ static int init_substream_urbs(snd_usb_s
        else
                subs->curpacksize = maxsize;
 
-       if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
+       if (is_playback)
                urb_packs = nrpacks;
        else
-               urb_packs = (nrpacks * 8) >> subs->datainterval;
+               urb_packs = 1;
+       if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
+               urb_packs = (urb_packs * 8) >> subs->datainterval;
 
        /* allocate a temporary buffer for playback */
        if (is_playback) {
@@ -935,9 +937,13 @@ static int init_substream_urbs(snd_usb_s
        }
 
        /* decide how many packets to be used */
-       total_packs = (period_bytes + maxsize - 1) / maxsize;
-       if (total_packs < 2 * MIN_PACKS_URB)
-               total_packs = 2 * MIN_PACKS_URB;
+       if (is_playback) {
+               total_packs = (period_bytes + maxsize - 1) / maxsize;
+               if (total_packs < 2 * MIN_PACKS_URB)
+                       total_packs = 2 * MIN_PACKS_URB;
+       } else {
+               total_packs = MAX_URBS * urb_packs;
+       }
        subs->nurbs = (total_packs + urb_packs - 1) / urb_packs;
        if (subs->nurbs > MAX_URBS) {
                /* too much... */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to