[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.15 and 1.16

version 1.15, 2014/03/17 17:16:06 version 1.16, 2014/03/17 17:53:33
Line 49 
Line 49 
 int play_filt_resamp(struct slot *, void *, void *, int);  int play_filt_resamp(struct slot *, void *, void *, int);
 int play_filt_dec(struct slot *, void *, void *, int);  int play_filt_dec(struct slot *, void *, void *, int);
 void dev_mix_badd(struct dev *, struct slot *);  void dev_mix_badd(struct dev *, struct slot *);
 void dev_empty_cycle(struct dev *);  
 void dev_mix_adjvol(struct dev *);  void dev_mix_adjvol(struct dev *);
 int rec_filt_resamp(struct slot *, void *, void *, int);  int rec_filt_resamp(struct slot *, void *, void *, int);
 int rec_filt_enc(struct slot *, void *, void *, int);  int rec_filt_enc(struct slot *, void *, void *, int);
 void dev_sub_bcopy(struct dev *, struct slot *);  void dev_sub_bcopy(struct dev *, struct slot *);
 void dev_full_cycle(struct dev *);  
   
 void dev_onmove(struct dev *, int);  void dev_onmove(struct dev *, int);
 void dev_master(struct dev *, unsigned int);  void dev_master(struct dev *, unsigned int);
Line 73 
Line 71 
 void dev_del(struct dev *);  void dev_del(struct dev *);
 unsigned int dev_roundof(struct dev *, unsigned int);  unsigned int dev_roundof(struct dev *, unsigned int);
 void dev_wakeup(struct dev *);  void dev_wakeup(struct dev *);
 void dev_clear(struct dev *);  
 void dev_sync_attach(struct dev *);  void dev_sync_attach(struct dev *);
 void dev_mmcstart(struct dev *);  void dev_mmcstart(struct dev *);
 void dev_mmcstop(struct dev *);  void dev_mmcstop(struct dev *);
Line 631 
Line 628 
         abuf_rdiscard(&s->mix.buf, s->round * s->mix.bpf);          abuf_rdiscard(&s->mix.buf, s->round * s->mix.bpf);
 }  }
   
 void  
 dev_empty_cycle(struct dev *d)  
 {  
         unsigned char *base;  
         int nsamp;  
   
         base = (unsigned char *)DEV_PBUF(d);  
         nsamp = d->round * d->pchan;  
         memset(base, 0, nsamp * sizeof(adata_t));  
         if (d->encbuf) {  
                 enc_do(&d->enc, (unsigned char *)DEV_PBUF(d),  
                     d->encbuf, d->round);  
         }  
 }  
   
 /*  /*
  * Normalize input levels.   * Normalize input levels.
  */   */
Line 759 
Line 741 
         abuf_wcommit(&s->sub.buf, ocount * s->sub.bpf);          abuf_wcommit(&s->sub.buf, ocount * s->sub.bpf);
 }  }
   
   /*
    * run a one block cycle: consume one recorded block from
    * rbuf and produce one play block in pbuf
    */
 void  void
 dev_full_cycle(struct dev *d)  dev_cycle(struct dev *d)
 {  {
         struct slot *s, **ps;          struct slot *s, **ps;
         unsigned char *base;          unsigned char *base;
         int nsamp;          int nsamp;
   
           /*
            * check if the device is actually used. If it isn't,
            * then close it
            */
           if (d->slot_list == NULL && d->tstate != MMC_RUN) {
                   if (log_level >= 2) {
                           dev_log(d);
                           log_puts(": device stopped\n");
                   }
                   dev_sio_stop(d);
                   d->pstate = DEV_INIT;
                   if (d->refcnt == 0)
                           dev_close(d);
                   return;
           }
   
           if (d->prime > 0) {
   #ifdef DEBUG
                   if (log_level >= 4) {
                           dev_log(d);
                           log_puts(": empty cycle, prime = ");
                           log_putu(d->prime);
                           log_puts("\n");
                   }
   #endif
                   base = (unsigned char *)DEV_PBUF(d);
                   nsamp = d->round * d->pchan;
                   memset(base, 0, nsamp * sizeof(adata_t));
                   if (d->encbuf) {
                           enc_do(&d->enc, (unsigned char *)DEV_PBUF(d),
                               d->encbuf, d->round);
                   }
                   d->prime -= d->round;
                   return;
           }
   
         d->delta -= d->round;          d->delta -= d->round;
 #ifdef DEBUG  #ifdef DEBUG
         if (log_level >= 4) {          if (log_level >= 4) {
                 dev_log(d);                  dev_log(d);
                 log_puts(": dev_full_cycle: clk=");                  log_puts(": full cycle: delta = ");
                 log_puti(d->delta);                  log_puti(d->delta);
                 if (d->mode & MODE_PLAY) {                  if (d->mode & MODE_PLAY) {
                         log_puts(", poffs = ");                          log_puts(", poffs = ");
Line 938 
Line 960 
                 dev_mix_adjvol(d);                  dev_mix_adjvol(d);
 }  }
   
 void  
 dev_cycle(struct dev *d)  
 {  
         if (d->slot_list == NULL && d->tstate != MMC_RUN) {  
                 if (log_level >= 2) {  
                         dev_log(d);  
                         log_puts(": device stopped\n");  
                 }  
                 dev_sio_stop(d);  
                 d->pstate = DEV_INIT;  
                 if (d->refcnt == 0)  
                         dev_close(d);  
                 else  
                         dev_clear(d);  
                 return;  
         }  
 #ifdef DEBUG  
         if (log_level >= 4) {  
                 dev_log(d);  
                 log_puts(": device cycle, prime = ");  
                 log_putu(d->prime);  
                 log_puts("\n");  
         }  
 #endif  
         if (d->prime > 0) {  
                 d->prime -= d->round;  
                 dev_empty_cycle(d);  
         } else {  
                 dev_full_cycle(d);  
         }  
 }  
   
 /*  /*
  * return the latency that a stream would have if it's attached   * return the latency that a stream would have if it's attached
  */   */
Line 1172 
Line 1162 
                         xfree(d->decbuf);                          xfree(d->decbuf);
                 xfree(d->rbuf);                  xfree(d->rbuf);
         }          }
         dev_clear(d);  
 }  }
   
 int  int
Line 1302 
Line 1291 
                 } else {                  } else {
                         d->prime = 0;                          d->prime = 0;
                 }                  }
                   d->poffs = 0;
   
                 /* empty cycles don't increment delta */                  /*
                    * empty cycles don't increment delta, so it's ok to
                    * start at 0
                    **/
                 d->delta = 0;                  d->delta = 0;
   
                 d->pstate = DEV_RUN;                  d->pstate = DEV_RUN;
                 dev_sio_start(d);                  dev_sio_start(d);
         }          }
 }  
   
 /*  
  * Clear buffers of the play and record chains so that when the device  
  * is started, playback and record start in sync.  
  */  
 void  
 dev_clear(struct dev *d)  
 {  
         d->poffs = 0;  
 }  }
   
 /*  /*

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16