vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Oct 12 22:48:38 2010 +0300| [44848fbc590944811ede09bd6ced0ef74a5bcfd7] | committer: Rémi Denis-Courmont
vlc_timer: compute overruns and adjust if they occur > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=44848fbc590944811ede09bd6ced0ef74a5bcfd7 --- src/misc/pthread.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/misc/pthread.c b/src/misc/pthread.c index ebbad78..12be0a8 100644 --- a/src/misc/pthread.c +++ b/src/misc/pthread.c @@ -851,6 +851,19 @@ static void *vlc_timer_thread (void *data) if (interval == 0) return NULL; + mtime_t now = mdate (); + unsigned misses = (now - value) / interval; + /* Try to compensate for one miss (mwait() will return immediately) + * but no more. Otherwise, we might busy loop, after extended periods + * without scheduling (suspend, SIGSTOP, RT preemption, ...). */ + if (misses > 1) + { + misses--; + vlc_mutex_lock (&timer->lock); + timer->overruns += misses; + vlc_mutex_unlock (&timer->lock); + value += misses * interval; + } value += interval; } } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
