[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.17 and 1.18

version 1.17, 2010/04/03 17:40:33 version 1.18, 2010/04/03 17:59:17
Line 132 
Line 132 
         if (debug_level >= 4) {          if (debug_level >= 4) {
                 aproc_dbg(p);                  aproc_dbg(p);
                 dbg_puts(": ");                  dbg_puts(": ");
                 dbg_putx(c);                  dbg_putu(c);
                 dbg_puts(": flushing realtime message\n");                  dbg_puts(": flushing realtime message\n");
         }          }
 #endif  #endif
Line 350 
Line 350 
 {  {
         struct ctl_slot *s;          struct ctl_slot *s;
   
           aproc_dbg(p);
         if (slot < 0) {          if (slot < 0) {
                 dbg_puts("none");                  dbg_puts("/none");
         } else {          } else {
                 s = p->u.ctl.slot + slot;                  s = p->u.ctl.slot + slot;
                 dbg_puts(s->name);                  dbg_puts(s->name);
                 dbg_putu(s->unit);                  dbg_putu(s->unit);
                 dbg_puts("(");                  dbg_puts("=");
                 dbg_putu(s->vol);                  dbg_putu(s->vol);
                 dbg_puts(")/");                  dbg_puts("/");
                 switch (s->tstate) {                  switch (s->tstate) {
                 case CTL_OFF:                  case CTL_OFF:
                         dbg_puts("off");                          dbg_puts("off");
Line 393 
Line 394 
   
         for (i = LIST_FIRST(&p->obuflist); i != NULL; i = inext) {          for (i = LIST_FIRST(&p->obuflist); i != NULL; i = inext) {
                 inext = LIST_NEXT(i, oent);                  inext = LIST_NEXT(i, oent);
                 if (i->duplex && i->duplex == ibuf)                  if (i->duplex == ibuf)
                         continue;                          continue;
                 itodo = len;                  itodo = len;
                 idata = msg;                  idata = msg;
Line 638 
Line 639 
   
         if (p->u.ctl.tstate != CTL_START) {          if (p->u.ctl.tstate != CTL_START) {
 #ifdef DEBUG  #ifdef DEBUG
                 if (debug_level >= 3) {                  aproc_dbg(p);
                         ctl_slotdbg(p, caller);                  dbg_puts(": not in starting state\n");
                         dbg_puts(": server not started, delayd\n");  
                 }  
 #endif  #endif
                 return 0;                  return 0;
         }          }
Line 650 
Line 649 
                         continue;                          continue;
                 if (s->tstate != CTL_OFF && s->tstate != CTL_START) {                  if (s->tstate != CTL_OFF && s->tstate != CTL_START) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 3) {                          ctl_slotdbg(p, i);
                                 ctl_slotdbg(p, i);                          dbg_puts(": not ready to start, start delayed\n");
                                 dbg_puts(": not ready, server delayed\n");  
                         }  
 #endif  #endif
                         return 0;                          return 0;
                 }                  }
Line 663 
Line 660 
                         continue;                          continue;
                 if (s->tstate == CTL_START) {                  if (s->tstate == CTL_START) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 3) {                          ctl_slotdbg(p, i);
                                 ctl_slotdbg(p, i);                          dbg_puts(": started\n");
                                 dbg_puts(": started\n");  
                         }  
 #endif  #endif
                         s->tstate = CTL_RUN;                          s->tstate = CTL_RUN;
                         s->ops->start(s->arg);                          s->ops->start(s->arg);
Line 676 
Line 671 
                 p->u.ctl.slot[caller].tstate = CTL_RUN;                  p->u.ctl.slot[caller].tstate = CTL_RUN;
         p->u.ctl.tstate = CTL_RUN;          p->u.ctl.tstate = CTL_RUN;
         p->u.ctl.delta = MTC_SEC * dev_getpos();          p->u.ctl.delta = MTC_SEC * dev_getpos();
         if (dev_rate % (30 * 4 * dev_round) == 0) {          if (dev_rate % (30 * 4 * dev_round)) {
                 p->u.ctl.fps_id = MTC_FPS_30;                  p->u.ctl.fps_id = MTC_FPS_30;
                 p->u.ctl.fps = 30;                  p->u.ctl.fps = 30;
         } else if (dev_rate % (25 * 4 * dev_round) == 0) {          } else if (dev_rate % (25 * 4 * dev_round)) {
                 p->u.ctl.fps_id = MTC_FPS_25;                  p->u.ctl.fps_id = MTC_FPS_25;
                 p->u.ctl.fps = 25;                  p->u.ctl.fps = 25;
         } else {          } else {
Line 687 
Line 682 
                 p->u.ctl.fps = 24;                  p->u.ctl.fps = 24;
         }          }
 #ifdef DEBUG  #ifdef DEBUG
         if (debug_level >= 3) {          ctl_slotdbg(p, caller);
                 ctl_slotdbg(p, caller);          dbg_puts(": started server at ");
                 dbg_puts(": started server at ");          dbg_puti(p->u.ctl.delta);
                 dbg_puti(p->u.ctl.delta);          dbg_puts(", ");
                 dbg_puts(", ");          dbg_puti(p->u.ctl.fps);
                 dbg_puti(p->u.ctl.fps);          dbg_puts(" mtc fps\n");
                 dbg_puts(" mtc fps\n");  
         }  
 #endif  #endif
         if (dev_pstate == DEV_INIT)  
                 dev_pstate = DEV_START;  
         ctl_full(p);          ctl_full(p);
         return 1;          return 1;
 }  }
Line 711 
Line 702 
         int idx;          int idx;
         struct ctl_slot *s;          struct ctl_slot *s;
   
         if (!APROC_OK(p)) {          if (p == NULL)
 #ifdef DEBUG  
                 if (debug_level >= 1) {  
                         dbg_puts(who);  
                         dbg_puts(": MIDI control not available\n");  
                 }  
 #endif  
                 return -1;                  return -1;
         }  
         idx = ctl_getidx(p, who);          idx = ctl_getidx(p, who);
         if (idx < 0)          if (idx < 0)
                 return -1;                  return -1;
Line 742 
Line 726 
         unsigned i;          unsigned i;
         struct ctl_slot *s;          struct ctl_slot *s;
   
         if (!APROC_OK(p))          if (p == NULL)
                 return;                  return;
         p->u.ctl.slot[index].ops = NULL;          p->u.ctl.slot[index].ops = NULL;
         if (!(p->flags & APROC_QUIT))          if (!(p->flags & APROC_QUIT))
Line 795 
Line 779 
 {  {
         unsigned char msg[3];          unsigned char msg[3];
   
         if (!APROC_OK(p))          if (p == NULL)
                 return;                  return;
 #ifdef DEBUG  #ifdef DEBUG
         if (debug_level >= 3) {          if (debug_level >= 3) {
Line 823 
Line 807 
 {  {
         struct ctl_slot *s = p->u.ctl.slot + slot;          struct ctl_slot *s = p->u.ctl.slot + slot;
   
         if (!APROC_OK(p))          if (p == NULL)
                 return 1;                  return 1;
         if (s->tstate == CTL_OFF || p->u.ctl.tstate == CTL_OFF)          if (s->tstate == CTL_OFF || p->u.ctl.tstate == CTL_OFF)
                 return 1;                  return 1;
Line 847 
Line 831 
 {  {
         struct ctl_slot *s = p->u.ctl.slot + slot;          struct ctl_slot *s = p->u.ctl.slot + slot;
   
         if (!APROC_OK(p))          if (p == NULL)
                 return;                  return;
         /*          /*
          * tag the stream as not trying to start,           * tag the stream as not trying to start,
Line 858 
Line 842 
 }  }
   
 /*  /*
  * start all slots simultaneously  
  */  
 void  
 ctl_start(struct aproc *p)  
 {  
         if (!APROC_OK(p))  
                 return;  
         if (p->u.ctl.tstate == CTL_STOP) {  
                 p->u.ctl.tstate = CTL_START;  
                 (void)ctl_trystart(p, -1);  
 #ifdef DEBUG  
         } else {  
                 if (debug_level >= 3) {  
                         aproc_dbg(p);  
                         dbg_puts(": ignoring mmc start\n");  
                 }  
 #endif  
         }  
 }  
   
 /*  
  * stop all slots simultaneously  
  */  
 void  
 ctl_stop(struct aproc *p)  
 {  
         unsigned i;  
         struct ctl_slot *s;  
   
         if (!APROC_OK(p))  
                 return;  
         switch (p->u.ctl.tstate) {  
         case CTL_START:  
                 p->u.ctl.tstate = CTL_STOP;  
                 return;  
         case CTL_RUN:  
                 p->u.ctl.tstate = CTL_STOP;  
                 break;  
         default:  
 #ifdef DEBUG  
                 if (debug_level >= 3) {  
                         aproc_dbg(p);  
                         dbg_puts(": ignored mmc stop\n");  
                 }  
 #endif  
                 return;  
         }  
         for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {  
                 if (!s->ops)  
                         continue;  
                 if (s->tstate == CTL_RUN) {  
 #ifdef DEBUG  
                         if (debug_level >= 3) {  
                                 ctl_slotdbg(p, i);  
                                 dbg_puts(": requested to stop\n");  
                         }  
 #endif  
                         s->ops->stop(s->arg);  
                 }  
         }  
 }  
   
 /*  
  * relocate all slots simultaneously  
  */  
 void  
 ctl_loc(struct aproc *p, unsigned origin)  
 {  
         unsigned i, tstate;  
         struct ctl_slot *s;  
   
         if (!APROC_OK(p))  
                 return;  
 #ifdef DEBUG  
         if (debug_level >= 2) {  
                 dbg_puts("server relocated to ");  
                 dbg_putu(origin);  
                 dbg_puts("\n");  
         }  
 #endif  
         tstate = p->u.ctl.tstate;  
         if (tstate == CTL_RUN)  
                 ctl_stop(p);  
         p->u.ctl.origin = origin;  
         for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {  
                 if (!s->ops)  
                         continue;  
                 s->ops->loc(s->arg, p->u.ctl.origin);  
         }  
         if (tstate == CTL_RUN)  
                 ctl_start(p);  
 }  
   
 /*  
  * check if there are controlled streams  
  */  
 int  
 ctl_idle(struct aproc *p)  
 {  
         unsigned i;  
         struct ctl_slot *s;  
   
         if (!APROC_OK(p))  
                 return 1;  
         for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {  
                 if (s->ops)  
                         return 0;  
         }  
         return 1;  
 }  
   
 /*  
  * handle a MIDI event received from ibuf   * handle a MIDI event received from ibuf
  */   */
 void  void
Line 1011 
Line 883 
                 switch (ibuf->r.midi.msg[4]) {                  switch (ibuf->r.midi.msg[4]) {
                 case 0x01:      /* mmc stop */                  case 0x01:      /* mmc stop */
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 3) {                          if (debug_level >= 1) {
                                 abuf_dbg(ibuf);                                  abuf_dbg(ibuf);
                                 dbg_puts(": mmc stop\n");                                  dbg_puts(": mmc stop\n");
                         }                          }
 #endif  #endif
                         ctl_stop(p);                          if (p->u.ctl.tstate == CTL_RUN ||
                               p->u.ctl.tstate == CTL_START)
                                   p->u.ctl.tstate = CTL_STOP;
   #ifdef DEBUG
                           else {
                                   if (debug_level >= 1) {
                                           aproc_dbg(p);
                                           dbg_puts(": ignored mmc stop\n");
                                   }
                           }
   #endif
                         break;                          break;
                 case 0x02:      /* mmc start */                  case 0x02:      /* mmc start */
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 3) {                          if (debug_level >= 1) {
                                 abuf_dbg(ibuf);                                  abuf_dbg(ibuf);
                                 dbg_puts(": mmc start\n");                                  dbg_puts(": mmc start\n");
                         }                          }
 #endif  #endif
                         ctl_start(p);                          if (p->u.ctl.tstate == CTL_STOP) {
                                   p->u.ctl.tstate = CTL_START;
                                   (void)ctl_trystart(p, -1);
   #ifdef DEBUG
                           } else {
                                   if (debug_level >= 1) {
                                           abuf_dbg(ibuf);
                                           dbg_puts(": ignoring mmc start\n");
                                   }
   #endif
                           }
                         break;                          break;
                 }                  }
         }          }
Line 1051 
Line 943 
                         p->u.ctl.origin = 0;                          p->u.ctl.origin = 0;
                         return;                          return;
                 }                  }
                 ctl_loc(p,                  p->u.ctl.origin =
                     (ibuf->r.midi.msg[7] & 0x1f) * 3600 * MTC_SEC +                      (ibuf->r.midi.msg[7] & 0x1f) * 3600 * MTC_SEC +
                     ibuf->r.midi.msg[8] * 60 * MTC_SEC +                      ibuf->r.midi.msg[8] * 60 * MTC_SEC +
                     ibuf->r.midi.msg[9] * MTC_SEC +                      ibuf->r.midi.msg[9] * MTC_SEC +
                     ibuf->r.midi.msg[10] * (MTC_SEC / fps) +                      ibuf->r.midi.msg[10] * (MTC_SEC / fps) +
                     ibuf->r.midi.msg[11] * (MTC_SEC / 100 / fps));                      ibuf->r.midi.msg[11] * (MTC_SEC / 100 / fps);
   #ifdef DEBUG
                   if (debug_level >= 1) {
                           aproc_dbg(p);
                           dbg_puts(": relocated to ");
                           dbg_putu(p->u.ctl.origin);
                           dbg_puts("\n");
                   }
   #endif
         }          }
 }  }
   

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18