Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28191
Modified Files: Tag: devel_0_38 m_sched.c Log Message: improved syslock handling, especially for idle callbacks
Index: m_sched.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v retrieving revision 1.5.4.27 retrieving revision 1.5.4.28 diff -C2 -d -r1.5.4.27 -r1.5.4.28 *** m_sched.c 8 May 2005 23:14:35 -0000 1.5.4.27 --- m_sched.c 10 May 2005 23:42:34 -0000 1.5.4.28 *************** *** 406,413 **** ((double)sys_schedblocksize) / sys_dacsr;
- #ifdef THREAD_LOCKING /* T.Grill - lock mutex */ sys_lock(); - #endif
sys_clearhist(); --- 406,411 ---- *************** *** 488,500 **** if (timeforward != SENDDACS_SLEPT) { - #ifdef THREAD_LOCKING - /* T.Grill - enter idle phase -> unlock thread lock */ - sys_unlock(); - #endif run_idle_callbacks(sys_sleepgrain); - #ifdef THREAD_LOCKING - /* T.Grill - leave idle phase -> lock thread lock */ - sys_lock(); - #endif } } --- 486,490 ---- *************** *** 510,515 ****
if (sys_pollgui()) didsomething = 1; ! /* test for idle; if so, do graphics updates. */ if (!didsomething) --- 500,509 ----
if (sys_pollgui()) + { + /* tb: allow the audio callback to run */ + sys_unlock(); + sys_lock(); didsomething = 1; ! } /* test for idle; if so, do graphics updates. */ if (!didsomething) *************** *** 517,539 **** sched_pollformeters(); } - - #ifdef THREAD_LOCKING - sys_unlock(); - #endif - run_idle_callbacks(sys_sleepgrain); ! #ifdef THREAD_LOCKING ! sys_lock(); ! #endif } sys_keepsched = 1; } - - #ifdef THREAD_LOCKING - /* T.Grill - done */ sys_unlock(); - #endif - return (0); } --- 511,521 ---- sched_pollformeters(); } ! run_idle_callbacks(sys_sleepgrain); } sys_keepsched = 1; } sys_unlock(); return (0); } *************** *** 565,568 **** --- 547,557 ---- int sys_timedlock(int microsec) { + #if 0 /* this would be the clean solution, why doesn't it work??? */ + struct timespec timeout; + timeout.tv_sec = 0; + timeout.tv_nsec = 1000 * microsec; + + return pthread_mutex_timedlock(&sys_mutex, &timeout); + #else int count = microsec * 0.001; int ret; *************** *** 578,581 **** --- 567,571 ---- } return ETIMEDOUT; + #endif } /* tb } */ *************** *** 639,646 **** static t_sched_callback *ringbuffer_head;
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 */ --- 629,641 ---- static t_sched_callback *ringbuffer_head;
+ static void run_idle_callbacks(int microsec) { t_sched_callback * new_callback; ! double stop; ! ! sys_unlock(); ! ! stop = sys_getrealtime()*1.e6 + (double)microsec;
/* append idle callback to ringbuffer */ *************** *** 672,677 **** do { ! int status = (idle_callback->function)(idle_callback->argv); ! switch (status) { --- 667,675 ---- do { ! int status; ! sys_lock(); ! status = (idle_callback->function)(idle_callback->argv); ! sys_unlock(); ! switch (status) { *************** *** 708,711 **** --- 706,710 ---- else sys_microsleep(microsec); + sys_lock(); } /* } tb */