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

Diff for /src/usr.bin/sndiod/dev.c between version 1.78 and 1.79

version 1.78, 2021/01/28 11:02:28 version 1.79, 2021/01/28 11:06:07
Line 1575 
Line 1575 
                 if (!s->ops || !s->opt->mmc)                  if (!s->ops || !s->opt->mmc)
                         continue;                          continue;
                 slot_attach(s);                  slot_attach(s);
                   s->pstate = SLOT_RUN;
         }          }
         d->tstate = MMC_RUN;          d->tstate = MMC_RUN;
         dev_midi_full(d);          dev_midi_full(d);
Line 2000 
Line 2001 
 {  {
         struct dev *d = s->dev;          struct dev *d = s->dev;
         long long pos;          long long pos;
         int startpos;  
   
         /*          /*
          * start the device if not started           * start the device if not started
Line 2008 
Line 2008 
         dev_wakeup(d);          dev_wakeup(d);
   
         /*          /*
          * get the current position, the origin is when the first sample  
          * played and/or recorded  
          */  
         startpos = dev_getpos(d) * (int)s->round / (int)d->round;  
   
         /*  
          * adjust initial clock           * adjust initial clock
          */           */
         pos = (long long)d->delta * s->round;          pos = s->delta_rem +
         s->delta = startpos + pos / (int)d->round;              (long long)s->delta * d->round +
               (long long)d->delta * s->round;
           s->delta = pos / (int)d->round;
         s->delta_rem = pos % d->round;          s->delta_rem = pos % d->round;
           if (s->delta_rem < 0) {
                   s->delta_rem += d->round;
                   s->delta--;
           }
   
         s->pstate = SLOT_RUN;  
 #ifdef DEBUG  #ifdef DEBUG
         if (log_level >= 2) {          if (log_level >= 2) {
                 slot_log(s);                  slot_log(s);
                 log_puts(": attached at ");                  log_puts(": attached at ");
                 log_puti(startpos);                  log_puti(s->delta);
                 log_puts(", delta = ");                  log_puts(" + ");
                 log_puti(d->delta);                  log_puti(s->delta_rem);
                   log_puts("/");
                   log_puti(s->round);
                 log_puts("\n");                  log_puts("\n");
         }          }
 #endif  #endif
Line 2065 
Line 2066 
          */           */
         if (s->dev->pstate == DEV_CFG)          if (s->dev->pstate == DEV_CFG)
                 return;                  return;
         if (!s->opt->mmc)          if (!s->opt->mmc) {
                 slot_attach(s);                  slot_attach(s);
         else                  s->pstate = SLOT_RUN;
           } else
                 dev_sync_attach(s->dev);                  dev_sync_attach(s->dev);
 }  }
   
Line 2115 
Line 2117 
         }          }
         s->skip = 0;          s->skip = 0;
   
           /*
            * get the current position, the origin is when the first sample
            * played and/or recorded
            */
           s->delta = dev_getpos(s->dev) * (int)s->round / (int)s->dev->round;
           s->delta_rem = 0;
   
         if (s->mode & MODE_PLAY) {          if (s->mode & MODE_PLAY) {
                 s->pstate = SLOT_START;                  s->pstate = SLOT_START;
         } else {          } else {
Line 2130 
Line 2139 
 slot_detach(struct slot *s)  slot_detach(struct slot *s)
 {  {
         struct slot **ps;          struct slot **ps;
           struct dev *d;
           long long pos;
   
 #ifdef DEBUG  #ifdef DEBUG
         if (log_level >= 3) {          if (log_level >= 3) {
Line 2147 
Line 2158 
 #endif  #endif
         }          }
         *ps = s->next;          *ps = s->next;
   
           d = s->dev;
   
           /*
            * adjust clock, go back d->delta ticks so that slot_attach()
            * could be called with the resulting state
            */
           pos = s->delta_rem +
               (long long)s->delta * d->round -
               (long long)d->delta * s->round;
           s->delta = pos / (int)d->round;
           s->delta_rem = pos % d->round;
           if (s->delta_rem < 0) {
                   s->delta_rem += d->round;
                   s->delta--;
           }
   
   #ifdef DEBUG
           if (log_level >= 2) {
                   slot_log(s);
                   log_puts(": detached at ");
                   log_puti(s->delta);
                   log_puts(" + ");
                   log_puti(s->delta_rem);
                   log_puts("/");
                   log_puti(d->round);
                   log_puts("\n");
           }
   #endif
         if (s->mode & MODE_PLAY)          if (s->mode & MODE_PLAY)
                 dev_mix_adjvol(s->dev);                  dev_mix_adjvol(s->dev);
 }  }

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79