[PD-cvs] pd/src m_sched.c,1.5.4.35.2.21.2.12,1.5.4.35.2.21.2.13

Mathieu Bouchard matju at users.sourceforge.net
Tue Jul 10 08:12:57 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18786

Modified Files:
      Tag: desiredata
	m_sched.c 
Log Message:
cleanup


Index: m_sched.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v
retrieving revision 1.5.4.35.2.21.2.12
retrieving revision 1.5.4.35.2.21.2.13
diff -C2 -d -r1.5.4.35.2.21.2.12 -r1.5.4.35.2.21.2.13
*** m_sched.c	9 Jul 2007 17:57:57 -0000	1.5.4.35.2.21.2.12
--- m_sched.c	10 Jul 2007 06:12:55 -0000	1.5.4.35.2.21.2.13
***************
*** 51,58 ****
  
  struct _clock {
!     double c_settime;
!     void *c_owner;
!     t_clockmethod c_fn;
!     struct _clock *c_next;
  };
  
--- 51,58 ----
  
  struct _clock {
!     double settime;
!     void *owner;
!     t_clockmethod fn;
!     struct _clock *next;
  };
  
***************
*** 60,79 ****
  t_clock *clock_new(void *owner, t_method fn) {
      t_clock *x = (t_clock *)malloc(sizeof(*x));
!     x->c_settime = -1;
!     x->c_owner = owner;
!     x->c_fn = (t_clockmethod)fn;
!     x->c_next = 0;
      return x;
  }
  
  void clock_unset(t_clock *x) {
!     if (x->c_settime >= 0) {
!         if (x == clock_setlist) clock_setlist = x->c_next;
          else {
              t_clock *x2 = clock_setlist;
!             while (x2->c_next != x) x2 = x2->c_next;
!             x2->c_next = x->c_next;
          }
!         x->c_settime = -1;
      }
  }
--- 60,79 ----
  t_clock *clock_new(void *owner, t_method fn) {
      t_clock *x = (t_clock *)malloc(sizeof(*x));
!     x->settime = -1;
!     x->owner = owner;
!     x->fn = (t_clockmethod)fn;
!     x->next = 0;
      return x;
  }
  
  void clock_unset(t_clock *x) {
!     if (x->settime >= 0) {
!         if (x == clock_setlist) clock_setlist = x->next;
          else {
              t_clock *x2 = clock_setlist;
!             while (x2->next != x) x2 = x2->next;
!             x2->next = x->next;
          }
!         x->settime = -1;
      }
  }
***************
*** 83,97 ****
      if (setticks < sys_time) setticks = sys_time;
      clock_unset(x);
!     x->c_settime = setticks;
!     if (clock_setlist && clock_setlist->c_settime <= setticks) {
          t_clock *cbefore, *cafter;
!         for (cbefore = clock_setlist, cafter = clock_setlist->c_next; cbefore; cbefore = cafter, cafter = cbefore->c_next) {
!             if (!cafter || cafter->c_settime > setticks) {
!                 cbefore->c_next = x;
!                 x->c_next = cafter;
                  return;
              }
          }
!     } else x->c_next = clock_setlist, clock_setlist = x;
  }
  
--- 83,97 ----
      if (setticks < sys_time) setticks = sys_time;
      clock_unset(x);
!     x->settime = setticks;
!     if (clock_setlist && clock_setlist->settime <= setticks) {
          t_clock *cbefore, *cafter;
!         for (cbefore = clock_setlist, cafter = clock_setlist->next; cbefore; cbefore = cafter, cafter = cbefore->next) {
!             if (!cafter || cafter->settime > setticks) {
!                 cbefore->next = x;
!                 x->next = cafter;
                  return;
              }
          }
!     } else x->next = clock_setlist, clock_setlist = x;
  }
  
***************
*** 143,150 ****
  
  void sys_printhist () {
!     unsigned i,j;
!     for (i=0; i<NHIST; i++) {
          int doit = 0;
!         for (j=0; j<NBIN; j++) if (sys_histogram[i][j]) doit = 1;
          if (doit) {
              post("%2d %8d %8d %8d %8d %8d %8d %8d %8d", i,
--- 143,149 ----
  
  void sys_printhist () {
!     for (int i=0; i<NHIST; i++) {
          int doit = 0;
!         for (unsigned int j=0; j<NBIN; j++) if (sys_histogram[i][j]) doit = 1;
          if (doit) {
              post("%2d %8d %8d %8d %8d %8d %8d %8d %8d", i,
***************
*** 159,166 ****
  
  int sys_addhist(int phase) {
!     int j, phasewas = sys_histphase;
      double newtime = sys_getrealtime();
      int msec = int((newtime-sys_histtime)*1000.);
!     for (j = NBIN-1; j >= 0; j--) {
          if (msec >= sys_bin[j]) {
              sys_histogram[phasewas][j]++;
--- 158,165 ----
  
  int sys_addhist(int phase) {
!     int phasewas = sys_histphase;
      double newtime = sys_getrealtime();
      int msec = int((newtime-sys_histtime)*1000.);
!     for (int j=NBIN-1; j >= 0; j--) {
          if (msec >= sys_bin[j]) {
              sys_histogram[phasewas][j]++;
***************
*** 176,181 ****
  
  struct t_resync {
!     int r_ntick;
!     int r_error;
  };
  
--- 175,180 ----
  
  struct t_resync {
!     int ntick;
!     int error;
  };
  
***************
*** 184,188 ****
  static t_resync oss_resync[NRESYNC];
  
- 
  static char *(oss_errornames[]) = {
  "unknown",
--- 183,186 ----
***************
*** 204,210 ****
          int errtype;
          if (nresyncphase < 0) nresyncphase += NRESYNC;
!         errtype = oss_resync[nresyncphase].r_error;
          if (errtype < 0 || errtype > 4) errtype = 0;
!         post("%9.2f\t%s", (sched_diddsp - oss_resync[nresyncphase].r_ntick)
                  * ((double)sys_schedblocksize) / sys_dacsr, oss_errornames[errtype]);
          nresyncphase--;
--- 202,208 ----
          int errtype;
          if (nresyncphase < 0) nresyncphase += NRESYNC;
!         errtype = oss_resync[nresyncphase].error;
          if (errtype < 0 || errtype > 4) errtype = 0;
!         post("%9.2f\t%s", (sched_diddsp - oss_resync[nresyncphase].ntick)
                  * ((double)sys_schedblocksize) / sys_dacsr, oss_errornames[errtype]);
          nresyncphase--;
***************
*** 217,222 ****
  
  void sys_log_error(int type) {
!     oss_resync[oss_resyncphase].r_ntick = sched_diddsp;
!     oss_resync[oss_resyncphase].r_error = type;
      oss_nresync++;
      if (++oss_resyncphase == NRESYNC) oss_resyncphase = 0;
--- 215,220 ----
  
  void sys_log_error(int type) {
!     oss_resync[oss_resyncphase].ntick = sched_diddsp;
!     oss_resync[oss_resyncphase].error = type;
      oss_nresync++;
      if (++oss_resyncphase == NRESYNC) oss_resyncphase = 0;
***************
*** 252,257 ****
          indb = int(0.5 + rmstodb(inmax));
          outdb = int(0.5 + rmstodb(outmax));
!         inclip = (inmax > 0.999);
!         outclip = (outmax >= 1.0);
      } else {
          indb = outdb = 0;
--- 250,255 ----
          indb = int(0.5 + rmstodb(inmax));
          outdb = int(0.5 + rmstodb(outmax));
!         inclip = inmax > 0.999;
!         outclip = outmax >= 1.0;
      } else {
          indb = outdb = 0;
***************
*** 297,310 ****
  }
  
- 
  static void run_clock_callbacks(double next_sys_time) {
!     if (clock_setlist && clock_setlist->c_settime <= next_sys_time) {
          do {
              t_clock *c = clock_setlist;
!             sys_time = c->c_settime;
              clock_unset(c); /* the compiler should easily inline this */
              outlet_setstacklim();
!             c->c_fn(c->c_owner);
!         } while (clock_setlist && clock_setlist->c_settime <= next_sys_time);
      }
  }
--- 295,307 ----
  }
  
  static void run_clock_callbacks(double next_sys_time) {
!     if (clock_setlist && clock_setlist->settime <= next_sys_time) {
          do {
              t_clock *c = clock_setlist;
!             sys_time = c->settime;
              clock_unset(c); /* the compiler should easily inline this */
              outlet_setstacklim();
!             c->fn(c->owner);
!         } while (clock_setlist && clock_setlist->settime <= next_sys_time);
      }
  }
***************
*** 581,586 ****
  static void run_idle_callbacks(int microsec) {
      t_sched_callback *new_callback;
!     double stop;
!     stop = sys_getrealtime()*1.e6 + (double)microsec;
      /* append idle callback to ringbuffer */
      while ((new_callback = (t_sched_callback*) fifo_get(callback_fifo))) {
--- 578,582 ----
  static void run_idle_callbacks(int microsec) {
      t_sched_callback *new_callback;
!     double stop = sys_getrealtime()*1.e6 + (double)microsec;
      /* append idle callback to ringbuffer */
      while ((new_callback = (t_sched_callback*) fifo_get(callback_fifo))) {
***************
*** 602,608 ****
          t_sched_callback *next;
          do {
-             int status;
  //            sys_lock();
!             status = (idle_callback->function)(idle_callback->argv);
  //            sys_unlock();
              switch (status) {
--- 598,603 ----
          t_sched_callback *next;
          do {
  //            sys_lock();
!             int status = idle_callback->function(idle_callback->argv);
  //            sys_unlock();
              switch (status) {
***************
*** 623,628 ****
              }
              remain = stop-sys_getrealtime()*1.e6;
!         }
!         while ((idle_callback != NULL) && (remain > 0));
          /* sleep for the rest of the time */
          if(remain > 0) {
--- 618,622 ----
              }
              remain = stop-sys_getrealtime()*1.e6;
!         } while (idle_callback && remain>0);
          /* sleep for the rest of the time */
          if(remain > 0) {





More information about the Pd-cvs mailing list