[PD-cvs] pd/src m_sched.c, 1.5.4.35.2.21.2.5, 1.5.4.35.2.21.2.6 s_main.c, 1.7.4.17.2.22.2.18, 1.7.4.17.2.22.2.19

Mathieu Bouchard matju at users.sourceforge.net
Thu Jun 28 07:56:43 CEST 2007


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

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


Index: s_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_main.c,v
retrieving revision 1.7.4.17.2.22.2.18
retrieving revision 1.7.4.17.2.22.2.19
diff -C2 -d -r1.7.4.17.2.22.2.18 -r1.7.4.17.2.22.2.19
*** s_main.c	28 Jun 2007 05:23:32 -0000	1.7.4.17.2.22.2.18
--- s_main.c	28 Jun 2007 05:56:41 -0000	1.7.4.17.2.22.2.19
***************
*** 134,168 ****
      sys_findprogdir(argv[0]);                   /* set sys_progname, guipath */
  
! 	/* tb: command line flag to defeat preset loading
! 	 * supported by vibrez.net
! 	 * { */
! 	for (i = 0; i != argc; ++i)
! 	{
! 	  if (!strcmp(argv[i],"-noprefs") || !strcmp(argv[i], "-rcfile"))
! 			noprefs = 1;
! 	}
! 	
! 	if (!noprefs) sys_rcfile(); /* parse the startup file */
! 	/* initalize idle callbacks before starting the gui */
! 	sys_init_idle_callbacks();
! 	
! 	/* } tb */
! 
!     if (sys_argparse(argc-1, argv+1))           /* parse cmd line */
!         return 1;
!     sys_afterargparse();                    /* post-argparse settings */
      if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
          pd_version, pd_compiletime, pd_compiledate);
!     if (sys_version)    /* if we were just asked our version, exit here. */
!         return 0;
! 
      if (sys_startgui()) return 1;      /* start the gui */
! 	
! 	/* tb: { *
! 	 * start the soundfiler helper thread */
  #ifdef THREADED_SF
!     sys_start_sfthread();     
  #endif /* THREDED_SF */
- 	
      /* try to set ftz and daz */
  #ifdef DAZ
--- 134,153 ----
      sys_findprogdir(argv[0]);                   /* set sys_progname, guipath */
  
!     /* tb: command line flag to defeat preset loading */
!     for (i = 0; i != argc; ++i) if (!strcmp(argv[i],"-noprefs") || !strcmp(argv[i],"-rcfile")) noprefs = 1;
!     if (!noprefs) sys_rcfile(); /* parse the startup file */
!     /* initalize idle callbacks before starting the gui */
!     sys_init_idle_callbacks();
!     /* } tb */
!     if (sys_argparse(argc-1, argv+1)) return 1; /* parse cmd line */
!     sys_afterargparse(); /* post-argparse settings */
      if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
          pd_version, pd_compiletime, pd_compiledate);
!     if (sys_version) return 0; /* if we were just asked our version, exit here. */
      if (sys_startgui()) return 1;      /* start the gui */
!     /* tb: { start the soundfiler helper thread */
  #ifdef THREADED_SF
!     sys_start_sfthread();
  #endif /* THREDED_SF */
      /* try to set ftz and daz */
  #ifdef DAZ
***************
*** 170,178 ****
      _mm_setcsr(_MM_DENORM_ZERO_ON | _mm_getcsr());
  #endif /* DAZ */
! 	/* } tb */
! 
      /* jsarlo { */
!     if (sys_externalschedlib)
!     {
  #ifdef MSW
          typedef int (*t_externalschedlibmain)(char *);
--- 155,161 ----
      _mm_setcsr(_MM_DENORM_ZERO_ON | _mm_getcsr());
  #endif /* DAZ */
!     /* } tb */
      /* jsarlo { */
!     if (sys_externalschedlib) {
  #ifdef MSW
          typedef int (*t_externalschedlibmain)(char *);

Index: m_sched.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v
retrieving revision 1.5.4.35.2.21.2.5
retrieving revision 1.5.4.35.2.21.2.6
diff -C2 -d -r1.5.4.35.2.21.2.5 -r1.5.4.35.2.21.2.6
*** m_sched.c	28 Jun 2007 05:23:32 -0000	1.5.4.35.2.21.2.5
--- m_sched.c	28 Jun 2007 05:56:41 -0000	1.5.4.35.2.21.2.6
***************
*** 163,168 ****
  static int sys_histphase;
  
! int sys_addhist(int phase)
! {
      int j, phasewas = sys_histphase;
      double newtime = sys_getrealtime();
--- 163,167 ----
  static int sys_histphase;
  
! int sys_addhist(int phase) {
      int j, phasewas = sys_histphase;
      double newtime = sys_getrealtime();
***************
*** 208,224 ****
      post("audio I/O error history:");
      post("seconds ago\terror type");
!     for (i = 0; i < nresync; i++)
!     {
          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--;
      }
--- 207,218 ----
      post("audio I/O error history:");
      post("seconds ago\terror type");
!     for (i = 0; i < nresync; i++) {
          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--;
      }
***************
*** 229,276 ****
  static int sched_meterson;
  
! 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;
!     if (type != ERR_NOTHING && !sched_diored &&
!         (sched_diddsp >= sched_dioredtime))
!     {
          sys_vgui("pdtk_pd_dio 1\n");
          sched_diored = 1;
      }
!     sched_dioredtime =
!         sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
  }
  
  static int sched_lastinclip, sched_lastoutclip, sched_lastindb, sched_lastoutdb;
  
! static void sched_pollformeters( void)
! {
      int inclip, outclip, indb, outdb;
      static int sched_nextmeterpolltime, sched_nextpingtime;
  
!         /* if there's no GUI but we're running in "realtime", here is
!         where we arrange to ping the watchdog every 2 seconds. */
  #ifdef __linux__
!     if (sys_hipriority && (sched_diddsp - sched_nextpingtime > 0))
!     {
          glob_watchdog(0);
!             /* ping every 2 seconds */
!         sched_nextpingtime = sched_diddsp +
!             2 * (int)(sys_dacsr /(double)sys_schedblocksize);
      }
  #endif
  
!     if (sched_diddsp - sched_nextmeterpolltime < 0)
!         return;
!     if (sched_diored && (sched_diddsp - sched_dioredtime > 0))
!     {
          sys_vgui("pdtk_pd_dio 0\n");
          sched_diored = 0;
      }
!     if (sched_meterson)
!     {
          float inmax, outmax;
          sys_getmeters(&inmax, &outmax);
--- 223,260 ----
  static int sched_meterson;
  
! 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;
!     if (type != ERR_NOTHING && !sched_diored && (sched_diddsp >= sched_dioredtime)) {
          sys_vgui("pdtk_pd_dio 1\n");
          sched_diored = 1;
      }
!     sched_dioredtime = sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
  }
  
  static int sched_lastinclip, sched_lastoutclip, sched_lastindb, sched_lastoutdb;
  
! static void sched_pollformeters( void) {
      int inclip, outclip, indb, outdb;
      static int sched_nextmeterpolltime, sched_nextpingtime;
  
!     /* if there's no GUI but we're running in "realtime", here is
!        where we arrange to ping the watchdog every 2 seconds. */
  #ifdef __linux__
!     if (sys_hipriority && (sched_diddsp - sched_nextpingtime > 0)) {
          glob_watchdog(0);
!         /* ping every 2 seconds */
!         sched_nextpingtime = sched_diddsp + 2*(int)(sys_dacsr /(double)sys_schedblocksize);
      }
  #endif
  
!     if (sched_diddsp - sched_nextmeterpolltime < 0) return;
!     if (sched_diored && sched_diddsp-sched_dioredtime > 0) {
          sys_vgui("pdtk_pd_dio 0\n");
          sched_diored = 0;
      }
!     if (sched_meterson) {
          float inmax, outmax;
          sys_getmeters(&inmax, &outmax);
***************
*** 279,291 ****
          inclip = (inmax > 0.999);
          outclip = (outmax >= 1.0);
!     }
!     else
!     {
          indb = outdb = 0;
          inclip = outclip = 0;
      }
      if (inclip != sched_lastinclip || outclip != sched_lastoutclip
!         || indb != sched_lastindb || outdb != sched_lastoutdb)
!     {
          sys_vgui("pdtk_pd_meters %d %d %d %d\n", indb, outdb, inclip, outclip);
          sched_lastinclip = inclip;
--- 263,272 ----
          inclip = (inmax > 0.999);
          outclip = (outmax >= 1.0);
!     } else {
          indb = outdb = 0;
          inclip = outclip = 0;
      }
      if (inclip != sched_lastinclip || outclip != sched_lastoutclip
!     || indb != sched_lastindb || outdb != sched_lastoutdb) {
          sys_vgui("pdtk_pd_meters %d %d %d %d\n", indb, outdb, inclip, outclip);
          sched_lastinclip = inclip;
***************
*** 294,313 ****
          sched_lastoutdb = outdb;
      }
!     sched_nextmeterpolltime =
!         sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
  }
  
! void glob_meters(void *dummy, float f)
! {
!     if (f == 0)
!         sys_getmeters(0, 0);
      sched_meterson = (f != 0);
!     sched_lastinclip = sched_lastoutclip = sched_lastindb = sched_lastoutdb =
!         -1;
  }
  
  #if 0
! void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
! {
      if (argc) sys_clearhist();
      else sys_printhist();
--- 275,289 ----
          sched_lastoutdb = outdb;
      }
!     sched_nextmeterpolltime = sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
  }
  
! void glob_meters(void *dummy, float f) {
!     if (f == 0) sys_getmeters(0, 0);
      sched_meterson = (f != 0);
!     sched_lastinclip = sched_lastoutclip = sched_lastindb = sched_lastoutdb = -1;
  }
  
  #if 0
! void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv) {
      if (argc) sys_clearhist();
      else sys_printhist();
***************
*** 321,348 ****
  double sys_time_per_dsp_tick;
  
! void sched_set_using_dacs(int flag)
! {
      sched_usedacs = flag;
!     if (!flag)
!     {
          sched_referencerealtime = sys_getrealtime();
          sched_referencelogicaltime = clock_getlogicaltime();
      }
!     sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
!         ((double)sys_schedblocksize) / sys_dacsr;
  }
  
  
! 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);
--- 297,318 ----
  double sys_time_per_dsp_tick;
  
! void sched_set_using_dacs(int flag) {
      sched_usedacs = flag;
!     if (!flag) {
          sched_referencerealtime = sys_getrealtime();
          sched_referencelogicaltime = clock_getlogicaltime();
      }
!     sys_time_per_dsp_tick = (TIMEUNITPERSEC) * ((double)sys_schedblocksize) / sys_dacsr;
  }
  
  
! 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);
***************
*** 396,410 ****
                  int timeforward;
              waitfortick:
!                 if (sched_usedacs)
!                 {
                      timeforward = sys_send_dacs();
                      /* if dacs remain "idle" for 1 sec, they're hung up. */
                      if (timeforward != 0)
                          idlecount = 0;
!                     else
!                     {
                          idlecount++;
!                         if (!(idlecount & 31))
!                         {
                              static double idletime;
                              /* on 32nd idle, start a clock watch;  every
--- 366,377 ----
                  int timeforward;
              waitfortick:
!                 if (sched_usedacs) {
                      timeforward = sys_send_dacs();
                      /* if dacs remain "idle" for 1 sec, they're hung up. */
                      if (timeforward != 0)
                          idlecount = 0;
!                     else {
                          idlecount++;
!                         if (!(idlecount & 31)) {
                              static double idletime;
                              /* on 32nd idle, start a clock watch;  every
***************
*** 500,505 ****
  /* osx doesn't define a pthread_mutex_timedlock ... maybe someday
     it will ... */
! int sys_timedlock(int microsec)
! {
          struct timespec timeout;
          int ret;
--- 467,471 ----
  /* osx doesn't define a pthread_mutex_timedlock ... maybe someday
     it will ... */
! int sys_timedlock(int microsec) {
          struct timespec timeout;
          int ret;
***************
*** 550,554 ****
  
  /* ------------ soft quit ------------------- */
! /* added by Thomas Grill - 
          just set the quit flag for the scheduler loop
          this is useful for applications using the PD shared library to signal the scheduler to terminate
--- 516,520 ----
  
  /* ------------ soft quit ------------------- */
! /* added by Thomas Grill -
          just set the quit flag for the scheduler loop
          this is useful for applications using the PD shared library to signal the scheduler to terminate
***************
*** 560,577 ****
  }
  
- 
  /* tb: place callbacks in scheduler 
   * {   */
! 
! /* linked list of callbacks 
!  * callback will be freed after returning 0 */
! typedef struct _sched_callback {
!     struct _sched_callback *next; /* next callback in ringbuffer / in fifo */
!     t_int (*function) (t_int *argv);
      t_int *argv;
      t_int argc;
! } t_sched_callback;
  
! void sys_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc) {
      t_sched_callback* noo = (t_sched_callback *)malloc(sizeof(t_sched_callback));
      noo->function = callback;
--- 526,540 ----
  }
  
  /* tb: place callbacks in scheduler 
   * {   */
! /* linked list of callbacks; callback will be freed after returning 0 */
! struct t_sched_callback {
!     struct t_sched_callback *next; /* next callback in ringbuffer / in fifo */
!     t_int (*function)(t_int *argv);
      t_int *argv;
      t_int argc;
! };
  
! void sys_callback(t_int (*callback)(t_int* argv), t_int* argv, t_int argc) {
      t_sched_callback* noo = (t_sched_callback *)malloc(sizeof(t_sched_callback));
      noo->function = callback;





More information about the Pd-cvs mailing list