Update of /cvsroot/alsa/alsa-kernel/usb
In directory usw-pr-cvs1:/tmp/cvs-serv22692

Modified Files:
        usbmixer.c 
Log Message:
optimization - the product map-table is searched only once at the
initialization.



Index: usbmixer.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/usb/usbmixer.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- usbmixer.c  11 Oct 2002 11:32:43 -0000      1.6
+++ usbmixer.c  11 Oct 2002 13:41:27 -0000      1.7
@@ -55,6 +55,8 @@
        int name;
 };
 
+struct usbmix_name_map;
+
 struct usb_mixer_build {
        snd_usb_audio_t *chip;
        unsigned char *buffer;
@@ -62,6 +64,7 @@
        unsigned int ctrlif;
        DECLARE_BITMAP(unitbitmap, 32*32);
        usb_audio_term_t oterm;
+       const struct usbmix_name_map *map;
 };
 
 struct usb_mixer_elem_info {
@@ -147,22 +150,18 @@
 /* get the mapped name if the unit matches */
 static int check_mapped_name(mixer_build_t *state, int unitid, int control, char 
*buf, int buflen)
 {
-       const struct usbmix_ctl_map *map;
        const struct usbmix_name_map *p;
-       struct usb_device_descriptor *dev = &state->chip->dev->descriptor;
 
-       for (map = usbmix_ctl_maps; map->vendor; map++) {
-               if (map->vendor != dev->idVendor ||
-                   map->product != dev->idProduct)
-                       continue;
-               for (p = map->map; p->id; p++) {
-                       if (p->id == unitid &&
-                           (! control || ! p->control || control == p->control)) {
-                               buflen--;
-                               strncpy(buf, p->name, buflen - 1);
-                               buf[buflen] = 0;
-                               return strlen(buf);
-                       }
+       if (! state->map)
+               return 0;
+
+       for (p = state->map; p->id; p++) {
+               if (p->id == unitid &&
+                   (! control || ! p->control || control == p->control)) {
+                       buflen--;
+                       strncpy(buf, p->name, buflen - 1);
+                       buf[buflen] = 0;
+                       return strlen(buf);
                }
        }
        return 0;
@@ -1385,6 +1384,8 @@
        unsigned char *desc;
        mixer_build_t state;
        int err;
+       const struct usbmix_ctl_map *map;
+       struct usb_device_descriptor *dev = &chip->dev->descriptor;
 
        strcpy(chip->card->mixername, "USB Mixer");
 
@@ -1393,6 +1394,15 @@
        state.buffer = buffer;
        state.buflen = buflen;
        state.ctrlif = ctrlif;
+
+       /* check the mapping table */
+       for (map = usbmix_ctl_maps; map->vendor; map++) {
+               if (map->vendor == dev->idVendor && map->product == dev->idProduct) {
+                       state.map = map->map;
+                       break;
+               }
+       }
+
        desc = NULL;
        while ((desc = snd_usb_find_csint_desc(buffer, buflen, desc, OUTPUT_TERMINAL, 
ctrlif, -1)) != NULL) {
                if (desc[0] < 9)



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to