Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17147/src
Modified Files: Tag: devel_0_38 m_sched.c Log Message: improved midi timing for the cb scheduler
Index: m_sched.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v retrieving revision 1.5.4.36 retrieving revision 1.5.4.37 diff -C2 -d -r1.5.4.36 -r1.5.4.37 *** m_sched.c 16 Jun 2005 12:40:52 -0000 1.5.4.36 --- m_sched.c 19 Jun 2005 19:25:24 -0000 1.5.4.37 *************** *** 75,89 **** 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; ! } }
--- 75,92 ---- void clock_unset(t_clock *x) { ! if (x == clock_setlist) clock_setlist = x->c_next; ! else ! { ! t_clock *x2 = clock_setlist; ! if (x2 == NULL) ! return; ! ! while (x2->c_next != x) ! if (x2->c_next == NULL) ! return; ! else ! x2 = x2->c_next; ! x2->c_next = x->c_next; ! } }
*************** *** 368,383 ****
! static void run_clock_callbacks(double next_sys_time) { ! while (clock_setlist && clock_setlist->c_settime < next_sys_time) ! { ! t_clock *c = clock_setlist; ! sys_time = c->c_settime; ! clock_unset(clock_setlist); ! outlet_setstacklim(); ! (*c->c_fn)(c->c_owner); ! if (sys_quit) ! break; ! } }
--- 371,392 ----
! static int run_clock_callbacks(double next_sys_time) { ! if (clock_setlist && clock_setlist->c_settime < next_sys_time) ! { ! do ! { ! t_clock *c = clock_setlist; ! clock_setlist = clock_setlist->c_next; ! outlet_setstacklim(); ! (*c->c_fn)(c->c_owner); ! if (sys_quit) ! break; ! } ! while (clock_setlist && clock_setlist->c_settime < next_sys_time); ! return 1; ! } ! else ! return 0; }
*************** *** 388,391 **** --- 397,404 ---- 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(); + sys_setmiditimediff(0, 1e-6 * sys_schedadvance); }
*************** *** 494,500 **** if (timeforward != SENDDACS_SLEPT) { - sys_unlock(); run_idle_callbacks(sys_sleepgrain); - sys_lock(); } } --- 507,511 ---- *************** *** 504,536 **** { int didsomething = 0; - - sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
! ! sys_pollmidiqueue(); sys_unlock(); sys_lock();
! if (sys_pollgui()) ! { ! /* tb: allow the audio callback to run */ ! sys_unlock(); ! sys_lock(); ! didsomething = 1; ! } ! ! run_clock_callbacks(sys_time); ! /* test for idle; if so, do graphics updates. */ ! if (!didsomething) ! { ! sched_pollformeters(); ! sys_unlock(); ! sys_lock(); ! } ! sys_unlock(); run_idle_callbacks(sys_sleepgrain); - sys_lock(); } sys_keepsched = 1; --- 515,534 ---- { int didsomething = 0;
! /* tb: allow the audio callback to run */ sys_unlock(); sys_lock();
! sys_pollmidiqueue(); ! if (sys_pollgui()) ! continue; ! ! if (run_clock_callbacks(sys_time)) ! continue; ! /* do graphics updates and run idle callbacks */ ! sched_pollformeters(); run_idle_callbacks(sys_sleepgrain); } sys_keepsched = 1; *************** *** 716,722 **** 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)) --- 714,722 ---- t_sched_callback * new_callback; double stop; ! ! sys_unlock(); ! stop = sys_getrealtime()*1.e6 + (double)microsec; ! /* append idle callback to ringbuffer */ while (new_callback = (t_sched_callback*) fifo_get(callback_fifo)) *************** *** 788,791 **** --- 788,792 ---- else sys_microsleep(microsec); + sys_lock(); } /* } tb */