[BACK]Return to midi.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / aucat

Diff for /src/usr.bin/aucat/Attic/midi.c between version 1.5 and 1.6

version 1.5, 2009/08/26 06:10:15 version 1.6, 2009/08/26 08:28:21
Line 331 
Line 331 
         struct ctl_slot *slot;          struct ctl_slot *slot;
         char name[CTL_NAMEMAX];          char name[CTL_NAMEMAX];
         unsigned i, unit, umap = 0;          unsigned i, unit, umap = 0;
           unsigned ser, bestser, bestidx;
   
         /*          /*
          * create a ``valid'' control name (lowcase, remove [^a-z], trucate)           * create a ``valid'' control name (lowcase, remove [^a-z], trucate)
Line 380 
Line 381 
         }          }
   
         /*          /*
          * couldn't find a matching slot, pick the first free one           * couldn't find a matching slot, pick oldest free slot
          */           */
         for (i = 0, slot = p->u.ctl.slot; ; i++, slot++) {          bestser = 0;
                 if (i == CTL_NSLOT)          bestidx = CTL_NSLOT;
                         return -1;          for (i = 0, slot = p->u.ctl.slot; i < CTL_NSLOT; i++, slot++) {
                 if (slot->cb == NULL)                  if (slot->cb != NULL)
                         break;                          continue;
                   ser = p->u.ctl.serial - slot->serial;
                   if (ser > bestser) {
                           bestser = ser;
                           bestidx = i;
                   }
         }          }
         DPRINTFN(1, "ctl_newslot: overwritten %u\n", i);          if (bestidx == CTL_NSLOT)
                   return -1;
           slot = p->u.ctl.slot + bestidx;
         strlcpy(slot->name, name, CTL_NAMEMAX);          strlcpy(slot->name, name, CTL_NAMEMAX);
           slot->serial = p->u.ctl.serial++;
         slot->unit = unit;          slot->unit = unit;
         slot->cb = cb;          slot->cb = cb;
         slot->arg = arg;          slot->arg = arg;
         return i;          DPRINTFN(1, "ctl_newslot: %u overwritten)\n", bestidx);
           return bestidx;
 }  }
   
 void  void
Line 509 
Line 519 
   
         for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {          for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {
                 if (s->cb != NULL)                  if (s->cb != NULL)
                         DPRINTF("ctl_done: %s%u not freed\n", s->name, s->unit);                          DPRINTF("ctl_done: %s%u in use\n", s->name, s->unit);
         }          }
 }  }
   
Line 534 
Line 544 
         unsigned i;          unsigned i;
   
         p = aproc_new(&ctl_ops, name);          p = aproc_new(&ctl_ops, name);
           p->u.ctl.serial = 0;
         for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {          for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {
                 p->u.ctl.slot[i].unit = i;                  p->u.ctl.slot[i].unit = i;
                 p->u.ctl.slot[i].cb = NULL;                  p->u.ctl.slot[i].cb = NULL;
                   p->u.ctl.slot[i].serial = p->u.ctl.serial++;
                 strlcpy(p->u.ctl.slot[i].name, "unknown", CTL_NAMEMAX);                  strlcpy(p->u.ctl.slot[i].name, "unknown", CTL_NAMEMAX);
         }          }
         return p;          return p;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6