Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12251
Modified Files: Tag: devel_0_38 m_sched.c Log Message: fixed idle callback bug
Index: m_sched.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v retrieving revision 1.5.4.35 retrieving revision 1.5.4.36 diff -C2 -d -r1.5.4.35 -r1.5.4.36 *** m_sched.c 18 May 2005 09:15:18 -0000 1.5.4.35 --- m_sched.c 16 Jun 2005 12:40:52 -0000 1.5.4.36 *************** *** 378,390 **** (*c->c_fn)(c->c_owner); if (sys_quit) ! return; } }
- /* take the scheduler forward one DSP tick, also handling clock timeouts */ void sched_tick(double next_sys_time) { - run_clock_callbacks(next_sys_time); /* tb: is the dsp tick the right place for this? */ sys_time = next_sys_time; sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */ --- 378,388 ---- (*c->c_fn)(c->c_owner); if (sys_quit) ! break; } }
/* take the scheduler forward one DSP tick, also handling clock timeouts */ void sched_tick(double next_sys_time) { sys_time = next_sys_time; sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */ *************** *** 425,433 **** /* tb: adapt sleepgrain with advance */ sys_update_sleepgrain(); ! sys_initmidiqueue();
- callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */ - while (!sys_quit) { --- 423,429 ---- /* tb: adapt sleepgrain with advance */ sys_update_sleepgrain(); ! sys_initmidiqueue();
while (!sys_quit) { *************** *** 475,479 **** --- 471,478 ----
if (timeforward != SENDDACS_NO) + { sched_tick(sys_time + sys_time_per_dsp_tick); + run_clock_callbacks(sys_time); + } if (timeforward == SENDDACS_YES) didsomething = 1; *************** *** 484,488 **** didsomething = 1; } ! /* test for idle; if so, do graphics updates. */ if (!didsomething) --- 483,488 ---- didsomething = 1; } ! ! /* test for idle; if so, do graphics updates. */ if (!didsomething) *************** *** 520,523 **** --- 520,525 ---- } + run_clock_callbacks(sys_time); + /* test for idle; if so, do graphics updates. */ if (!didsomething) *************** *** 643,647 **** ret = pthread_cond_timedwait(&sys_cond, &sys_mutex, &timeout); ! return ret; } --- 645,649 ---- ret = pthread_cond_timedwait(&sys_cond, &sys_mutex, &timeout); ! return ret; } *************** *** 703,706 **** --- 705,713 ----
+ void sys_init_idle_callbacks(void) + { + callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */ + } + static t_sched_callback *ringbuffer_head;
*************** *** 713,720 ****
/* append idle callback to ringbuffer */ ! new_callback = (t_sched_callback*) fifo_get(callback_fifo); ! while (new_callback != NULL) { t_sched_callback * next; if (ringbuffer_head == NULL) { --- 720,729 ----
/* append idle callback to ringbuffer */ ! while (new_callback = (t_sched_callback*) fifo_get(callback_fifo)) { t_sched_callback * next; + + /* set the next field to NULL ... it might be set in the fifo */ + new_callback->next = NULL; if (ringbuffer_head == NULL) { *************** *** 728,732 **** next->next = new_callback; } - new_callback = (t_sched_callback*) fifo_get(callback_fifo); }
--- 737,740 ---- *************** *** 775,779 ****
/* sleep for the rest of the time */ ! if(remain > 0) sys_microsleep(remain); } else --- 783,788 ----
/* sleep for the rest of the time */ ! if(remain > 0) ! sys_microsleep(remain); } else *************** *** 782,783 **** --- 791,803 ---- /* } tb */
+ void sys_setscheduler(int scheduler) + { + sys_keepsched = 0; + sys_callbackscheduler = scheduler; + return; + } + + int sys_getscheduler(void) + { + return sys_callbackscheduler; + }