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

Diff for /src/usr.bin/aucat/Attic/sock.c between version 1.54 and 1.55

version 1.54, 2011/04/08 13:00:57 version 1.55, 2011/04/16 10:52:22
Line 707 
Line 707 
         unsigned n;          unsigned n;
   
 #ifdef DEBUG  #ifdef DEBUG
         if (f->pstate != SOCK_MIDI && f->rtodo == 0) {          if (f->rtodo == 0) {
                 sock_dbg(f);                  sock_dbg(f);
                 dbg_puts(": data block already read\n");                  dbg_puts(": data block already read\n");
                 dbg_panic();                  dbg_panic();
Line 719 
Line 719 
                 return 0;                  return 0;
         if (!ABUF_WOK(obuf) || !(f->pipe.file.state & FILE_ROK))          if (!ABUF_WOK(obuf) || !(f->pipe.file.state & FILE_ROK))
                 return 0;                  return 0;
         if (f->pstate == SOCK_MIDI) {          if (!rfile_do(p, f->rtodo, &n))
                 if (!rfile_do(p, obuf->len, NULL))                  return 0;
                         return 0;          f->rtodo -= n;
         } else {          if (f->pstate == SOCK_START) {
                 if (!rfile_do(p, f->rtodo, &n))                  if (!ABUF_WOK(obuf) || (f->pipe.file.state & FILE_EOF))
                         return 0;                          f->pstate = SOCK_READY;
                 f->rtodo -= n;  
                 if (f->pstate == SOCK_START) {  
                         if (!ABUF_WOK(obuf) || (f->pipe.file.state & FILE_EOF))  
                                 f->pstate = SOCK_READY;  
                 }  
         }          }
         return 1;          return 1;
 }  }
Line 746 
Line 741 
         unsigned n;          unsigned n;
   
 #ifdef DEBUG  #ifdef DEBUG
         if (f->pstate != SOCK_MIDI && f->wtodo == 0) {          if (f->wtodo == 0) {
                 sock_dbg(f);                  sock_dbg(f);
                 dbg_puts(": attempted to write zero-sized data block\n");                  dbg_puts(": attempted to write zero-sized data block\n");
                 dbg_panic();                  dbg_panic();
Line 757 
Line 752 
         p = f->pipe.file.wproc;          p = f->pipe.file.wproc;
         ibuf = LIST_FIRST(&p->ins);          ibuf = LIST_FIRST(&p->ins);
 #ifdef DEBUG  #ifdef DEBUG
         if (f->pstate != SOCK_MIDI && ibuf == NULL) {          if (ibuf == NULL) {
                 sock_dbg(f);                  sock_dbg(f);
                 dbg_puts(": attempted to write on detached buffer\n");                  dbg_puts(": attempted to write on detached buffer\n");
                 dbg_panic();                  dbg_panic();
Line 767 
Line 762 
                 return 0;                  return 0;
         if (!ABUF_ROK(ibuf))          if (!ABUF_ROK(ibuf))
                 return 0;                  return 0;
         if (f->pstate == SOCK_MIDI) {          if (!wfile_do(p, f->wtodo, &n))
                 if (!wfile_do(p, ibuf->len, NULL))                  return 0;
                         return 0;          f->wtodo -= n;
         } else {  
                 if (!wfile_do(p, f->wtodo, &n))  
                         return 0;  
                 f->wtodo -= n;  
         }  
         return 1;          return 1;
 }  }
   
Line 1102 
Line 1092 
                         dbg_puts(": DATA message\n");                          dbg_puts(": DATA message\n");
                 }                  }
 #endif  #endif
                 if (f->pstate != SOCK_RUN && f->pstate != SOCK_START &&                  if (f->pstate != SOCK_MIDI && f->pstate != SOCK_RUN &&
                     f->pstate != SOCK_READY) {                      f->pstate != SOCK_START && f->pstate != SOCK_READY) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 1) {                          if (debug_level >= 1) {
                                 sock_dbg(f);                                  sock_dbg(f);
Line 1113 
Line 1103 
                         aproc_del(f->pipe.file.rproc);                          aproc_del(f->pipe.file.rproc);
                         return 0;                          return 0;
                 }                  }
                 if (!(f->mode & MODE_PLAY)) {                  if (!(f->mode & (MODE_PLAY | MODE_MIDIOUT))) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 1) {                          if (debug_level >= 1) {
                                 sock_dbg(f);                                  sock_dbg(f);
Line 1147 
Line 1137 
                 f->rstate = SOCK_RDATA;                  f->rstate = SOCK_RDATA;
                 f->rtodo = m->u.data.size / obuf->bpf;                  f->rtodo = m->u.data.size / obuf->bpf;
 #ifdef DEBUG  #ifdef DEBUG
                 if (f->rtodo > f->rmax && debug_level >= 2) {                  if (debug_level >= 2 &&
                       f->pstate != SOCK_MIDI && f->rtodo > f->rmax) {
                         sock_dbg(f);                          sock_dbg(f);
                         dbg_puts(": received past current position, rtodo = ");                          dbg_puts(": received past current position, rtodo = ");
                         dbg_putu(f->rtodo);                          dbg_putu(f->rtodo);
Line 1158 
Line 1149 
                         return 0;                          return 0;
                 }                  }
 #endif  #endif
                 f->rmax -= f->rtodo;                  if (f->pstate != SOCK_MIDI)
                           f->rmax -= f->rtodo;
                 if (f->rtodo == 0) {                  if (f->rtodo == 0) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 1) {                          if (debug_level >= 1) {
Line 1221 
Line 1213 
                 else                  else
                         f->pstate = SOCK_STOP;                          f->pstate = SOCK_STOP;
                 AMSG_INIT(m);                  AMSG_INIT(m);
                 m->cmd = AMSG_ACK;                  m->cmd = AMSG_STOP;
                 f->rstate = SOCK_RRET;                  f->rstate = SOCK_RRET;
                 f->rtodo = sizeof(struct amsg);                  f->rtodo = sizeof(struct amsg);
                 break;                  break;
Line 1390 
Line 1382 
                         dbg_puts(": BYE message\n");                          dbg_puts(": BYE message\n");
                 }                  }
 #endif  #endif
                 if (f->pstate != SOCK_INIT) {                  if (f->pstate != SOCK_INIT && f->pstate != SOCK_MIDI) {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug_level >= 1) {                          if (debug_level >= 1) {
                                 sock_dbg(f);                                  sock_dbg(f);
Line 1423 
Line 1415 
         struct abuf *ibuf;          struct abuf *ibuf;
         unsigned size, max;          unsigned size, max;
   
         if (f->pstate == SOCK_MIDI) {  
 #ifdef DEBUG  
                 if (debug_level >= 3) {  
                         sock_dbg(f);  
                         dbg_puts(": switching to MIDI mode\n");  
                 }  
 #endif  
                 f->wstate = SOCK_WDATA;  
                 f->wtodo = 0;  
                 return 1;  
         }  
   
         /*          /*
          * Send initial position           * Send initial position
          */           */
Line 1509 
Line 1489 
         ibuf = LIST_FIRST(&p->ins);          ibuf = LIST_FIRST(&p->ins);
         if (ibuf && ABUF_ROK(ibuf)) {          if (ibuf && ABUF_ROK(ibuf)) {
 #ifdef DEBUG  #ifdef DEBUG
                 if (ibuf->used > f->wmax && debug_level >= 3) {                  if (debug_level >= 3 &&
                       f->pstate != SOCK_MIDI && ibuf->used > f->wmax) {
                         sock_dbg(f);                          sock_dbg(f);
                         dbg_puts(": attempt to send past current position: used = ");                          dbg_puts(": attempt to send past current position: used = ");
                         dbg_putu(ibuf->used);                          dbg_putu(ibuf->used);
Line 1518 
Line 1499 
                         dbg_puts("\n");                          dbg_puts("\n");
                 }                  }
 #endif  #endif
                 max = AMSG_DATAMAX / ibuf->bpf;  
                 size = ibuf->used;                  size = ibuf->used;
                 if (size > f->walign)                  if (f->pstate == SOCK_MIDI) {
                         size = f->walign;                          if (size > AMSG_DATAMAX)
                 if (size > f->wmax)                                  size = AMSG_DATAMAX;
                         size = f->wmax;                          if (size == 0)
                 if (size > max)                                  return 0;
                         size = max;                  } else {
                 if (size == 0)                          max = AMSG_DATAMAX / ibuf->bpf;
                         return 0;                          if (size > max)
                 f->walign -= size;                                  size = max;
                 f->wmax -= size;                          if (size > f->walign)
                 if (f->walign == 0)                                  size = f->walign;
                         f->walign = f->round;                          if (size > f->wmax)
                                   size = f->wmax;
                           if (size == 0)
                                   return 0;
                           f->walign -= size;
                           f->wmax -= size;
                           if (f->walign == 0)
                                   f->walign = f->round;
                           size *= ibuf->bpf;
                   }
                 AMSG_INIT(&f->wmsg);                  AMSG_INIT(&f->wmsg);
                 f->wmsg.cmd = AMSG_DATA;                  f->wmsg.cmd = AMSG_DATA;
                 f->wmsg.u.data.size = size * ibuf->bpf;                  f->wmsg.u.data.size = size;
                 f->wtodo = sizeof(struct amsg);                  f->wtodo = sizeof(struct amsg);
                 f->wstate = SOCK_WMSG;                  f->wstate = SOCK_WMSG;
                 return 1;                  return 1;
Line 1575 
Line 1564 
         case SOCK_RDATA:          case SOCK_RDATA:
                 if (!sock_rdata(f))                  if (!sock_rdata(f))
                         return 0;                          return 0;
                 if (f->pstate != SOCK_MIDI && f->rtodo == 0) {                  if (f->rtodo == 0) {
                         f->rstate = SOCK_RMSG;                          f->rstate = SOCK_RMSG;
                         f->rtodo = sizeof(struct amsg);                          f->rtodo = sizeof(struct amsg);
                 }                  }
Line 1623 
Line 1612 
                         dbg_puts(": sent RRET message\n");                          dbg_puts(": sent RRET message\n");
                 }                  }
 #endif  #endif
                 if (f->pstate == SOCK_MIDI && (f->mode & MODE_MIDIOUT)) {                  f->rstate = SOCK_RMSG;
                         f->rstate = SOCK_RDATA;                  f->rtodo = sizeof(struct amsg);
                         f->rtodo = 0;  
                 } else {  
                         f->rstate = SOCK_RMSG;  
                         f->rtodo = sizeof(struct amsg);  
                 }  
                 if (f->pipe.file.state & FILE_RINUSE)                  if (f->pipe.file.state & FILE_RINUSE)
                         break;                          break;
                 f->pipe.file.state |= FILE_RINUSE;                  f->pipe.file.state |= FILE_RINUSE;
Line 1687 
Line 1671 
         case SOCK_WDATA:          case SOCK_WDATA:
                 if (!sock_wdata(f))                  if (!sock_wdata(f))
                         return 0;                          return 0;
                 if (f->pstate == SOCK_MIDI || f->wtodo > 0)                  if (f->wtodo > 0)
                         break;                          break;
                 f->wstate = SOCK_WIDLE;                  f->wstate = SOCK_WIDLE;
                 f->wtodo = 0xdeadbeef;                  f->wtodo = 0xdeadbeef;

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55