Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8056
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.8 retrieving revision 1.5.4.35.2.21.2.9 diff -C2 -d -r1.5.4.35.2.21.2.8 -r1.5.4.35.2.21.2.9 *** m_sched.c 28 Jun 2007 09:01:50 -0000 1.5.4.35.2.21.2.8 --- m_sched.c 28 Jun 2007 15:53:39 -0000 1.5.4.35.2.21.2.9 *************** *** 86,92 **** 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; --- 86,90 ---- 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; *************** *** 177,185 **** #define NRESYNC 20
! typedef struct _resync ! { int r_ntick; int r_error; ! } t_resync;
static int oss_resyncphase = 0; --- 175,182 ---- #define NRESYNC 20
! struct t_resync { int r_ntick; int r_error; ! };
static int oss_resyncphase = 0; *************** *** 200,204 **** void glob_audiostatus (void *dummy) { int nresync, nresyncphase, i; ! nresync = (oss_nresync >= NRESYNC ? NRESYNC : oss_nresync); nresyncphase = oss_resyncphase - 1; post("audio I/O error history:"); --- 197,201 ---- void glob_audiostatus (void *dummy) { int nresync, nresyncphase, i; ! nresync = oss_nresync >= NRESYNC ? NRESYNC : oss_nresync; nresyncphase = oss_resyncphase - 1; post("audio I/O error history:"); *************** *** 209,214 **** 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--; --- 206,210 ---- 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--; *************** *** 237,241 **** 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. */ --- 233,236 ---- *************** *** 247,251 **** } #endif - if (sched_diddsp - sched_nextmeterpolltime < 0) return; if (sched_diored && sched_diddsp-sched_dioredtime > 0) { --- 242,245 ---- *************** *** 312,330 **** outlet_setstacklim(); c->c_fn(c->c_owner); ! } ! while (clock_setlist && clock_setlist->c_settime <= next_sys_time); } }
! ! /* take the scheduler forward one DSP tick, also handling clock timeouts */ ! void sched_tick(double next_sys_time) ! { run_clock_callbacks(next_sys_time); sys_time = next_sys_time; sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */ dsp_tick(); - - /* rethink: should we really do all this midi messaging in the realtime thread ? */ sys_pollmidiqueue(); --- 306,319 ---- outlet_setstacklim(); c->c_fn(c->c_owner); ! } while (clock_setlist && clock_setlist->c_settime <= next_sys_time); } }
! /* take the scheduler forward one DSP tick, also handling clock timeouts */ ! void sched_tick(double next_sys_time) { run_clock_callbacks(next_sys_time); sys_time = next_sys_time; sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */ dsp_tick(); /* rethink: should we really do all this midi messaging in the realtime thread ? */ sys_pollmidiqueue(); *************** *** 405,426 **** } else /* tb: scheduler for callback-based dsp scheduling */ ! while(sys_keepsched) ! { /* tb: allow the audio callback to run */ sys_unlock(); sys_microsleep(sys_sleepgrain); sys_lock(); - sys_pollmidiqueue(); sys_setmiditimediff(0, 1e-6 * sys_schedadvance); ! if (sys_pollgui()) ! continue; /* do graphics updates and run idle callbacks */ sched_pollformeters(); - } sys_keepsched = 1; } - sys_close_audio(); sys_unlock(); --- 394,410 ---- } else /* tb: scheduler for callback-based dsp scheduling */ ! while(sys_keepsched) { /* tb: allow the audio callback to run */ sys_unlock(); sys_microsleep(sys_sleepgrain); sys_lock(); sys_pollmidiqueue(); sys_setmiditimediff(0, 1e-6 * sys_schedadvance); ! if (sys_pollgui()) continue; /* do graphics updates and run idle callbacks */ sched_pollformeters(); } sys_keepsched = 1; } sys_close_audio(); sys_unlock(); *************** *** 428,432 **** }
- /* ------------ thread locking ------------------- */ /* added by Thomas Grill */ --- 412,415 ---- *************** *** 466,470 **** int sys_timedlock(int microsec) { struct timespec timeout; - int ret; struct timeval now; /* timedlock seems to have a resolution of 1ms */ --- 449,452 ---- *************** *** 477,481 **** timeout.tv_nsec -= 1e9; } ! ret = pthread_mutex_timedlock(&sys_mutex, &timeout); if (ret) post("timeout, %d", ret); return ret; --- 459,463 ---- timeout.tv_nsec -= 1e9; } ! int ret = pthread_mutex_timedlock(&sys_mutex, &timeout); if (ret) post("timeout, %d", ret); return ret; *************** *** 485,489 **** int sys_timedlock(int microsec) { struct timespec timeout; - int ret; struct timeval now; if (sys_trylock() == 0) return 0; --- 467,470 ---- *************** *** 499,504 **** again before waiting for the signal */ if (sys_trylock() == 0) return 0; ! ret = pthread_cond_timedwait(&sys_cond, &sys_mutex, &timeout); ! return ret; } #endif --- 480,484 ---- again before waiting for the signal */ if (sys_trylock() == 0) return 0; ! return pthread_cond_timedwait(&sys_cond, &sys_mutex, &timeout); } #endif *************** *** 555,559 ****
extern "C" void run_all_idle_callbacks () { ! t_sched_callback * new_callback; /* append idle callback to ringbuffer */ while ((new_callback = (t_sched_callback*) fifo_get(callback_fifo))) { --- 535,539 ----
extern "C" void run_all_idle_callbacks () { ! t_sched_callback *new_callback; /* append idle callback to ringbuffer */ while ((new_callback = (t_sched_callback*) fifo_get(callback_fifo))) {