[PATCH] better USB_MON dependencies
[powerpc.git] / sound / usb / usbaudio.c
index 076da19..a756950 100644 (file)
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(async_unlink, "Use async unlink mode.");
 #define MAX_PACKS      10
 #define MAX_PACKS_HS   (MAX_PACKS * 8) /* in high speed mode */
 #define MAX_URBS       5       /* max. 20ms long packets */
-#define SYNC_URBS      2       /* always two urbs for sync */
+#define SYNC_URBS      4       /* always four urbs for sync */
 #define MIN_PACKS_URB  1       /* minimum 1 packet per urb */
 
 typedef struct snd_usb_substream snd_usb_substream_t;
@@ -859,10 +859,8 @@ static void release_urb_ctx(snd_urb_ctx_t *u)
                usb_free_urb(u->urb);
                u->urb = NULL;
        }
-       if (u->buf) {
-               kfree(u->buf);
-               u->buf = NULL;
-       }
+       kfree(u->buf);
+       u->buf = NULL;
 }
 
 /*
@@ -880,10 +878,8 @@ static void release_substream_urbs(snd_usb_substream_t *subs, int force)
                release_urb_ctx(&subs->dataurb[i]);
        for (i = 0; i < SYNC_URBS; i++)
                release_urb_ctx(&subs->syncurb[i]);
-       if (subs->tmpbuf) {
-               kfree(subs->tmpbuf);
-               subs->tmpbuf = NULL;
-       }
+       kfree(subs->tmpbuf);
+       subs->tmpbuf = NULL;
        subs->nurbs = 0;
 }
 
@@ -1240,8 +1236,13 @@ static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt)
                    get_endpoint(alts, 1)->bRefresh >= 1 &&
                    get_endpoint(alts, 1)->bRefresh <= 9)
                        subs->syncinterval = get_endpoint(alts, 1)->bRefresh;
-               else
+               else if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
                        subs->syncinterval = 1;
+               else if (get_endpoint(alts, 1)->bInterval >= 1 &&
+                        get_endpoint(alts, 1)->bInterval <= 16)
+                       subs->syncinterval = get_endpoint(alts, 1)->bInterval - 1;
+               else
+                       subs->syncinterval = 3;
        }
 
        /* always fill max packet size */