From 981f641ef44fe4d72dcb0e1248a2f96ba53cee69 Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Sat, 6 Nov 2004 16:07:34 +0000 Subject: 0.38 test 9 (mostly bug fixes) svn path=/trunk/; revision=2226 --- pd/src/m_sched.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pd/src/m_sched.c') diff --git a/pd/src/m_sched.c b/pd/src/m_sched.c index b0854984..10c03473 100644 --- a/pd/src/m_sched.c +++ b/pd/src/m_sched.c @@ -382,6 +382,11 @@ the audio I/O system is still busy with previous transfers. void sys_pollmidiqueue( void); void sys_initmidiqueue( void); + /* sys_idlehook is a hook the user can fill in to grab idle time. Return +nonzero if you actually used the time; otherwise we're really really idle and +will now sleep. */ +int (*sys_idlehook)(void); + int m_scheduler( void) { int idlecount = 0; @@ -468,8 +473,13 @@ int m_scheduler( void) /* T.Grill - enter idle phase -> unlock thread lock */ sys_unlock(); #endif - if (timeforward != SENDDACS_SLEPT) - sys_microsleep(sys_sleepgrain); + /* call externally installed idle function if any. */ + if (!sys_idlehook || !sys_idlehook()) + { + /* if even that had nothing to do, sleep. */ + if (timeforward != SENDDACS_SLEPT) + sys_microsleep(sys_sleepgrain); + } #ifdef THREAD_LOCKING /* T.Grill - leave idle phase -> lock thread lock */ sys_lock(); -- cgit v1.2.1