Commit 44848fbc authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_timer: compute overruns and adjust if they occur

parent 86d92ca8
......@@ -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;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment