This fixes a bug where calling time_restart can leave the current event
in the cache, even though the restart scheduled the event in the future.
This would cause the event to get executed more frequently than it should.
if ((e->enabled = !!tv))
e->timeval = *tv;
+ if (e->mainloop->cached_next_time_event == e)
+ e->mainloop->cached_next_time_event = NULL;
+
if (e->mainloop->cached_next_time_event && e->enabled) {
g_assert(e->mainloop->cached_next_time_event->enabled);
if (pa_timeval_cmp(tv, &e->mainloop->cached_next_time_event->timeval) < 0)
e->mainloop->cached_next_time_event = e;
- } else if (e->mainloop->cached_next_time_event == e)
- e->mainloop->cached_next_time_event = NULL;
+ }
}
static void glib_time_free(pa_time_event *e) {
pa_mainloop_wakeup(e->mainloop);
}
+ if (e->mainloop->cached_next_time_event == e)
+ e->mainloop->cached_next_time_event = NULL;
+
if (e->mainloop->cached_next_time_event && e->enabled) {
pa_assert(e->mainloop->cached_next_time_event->enabled);
if (t < e->mainloop->cached_next_time_event->time)
e->mainloop->cached_next_time_event = e;
- } else if (e->mainloop->cached_next_time_event == e)
- e->mainloop->cached_next_time_event = NULL;
+ }
}
static void mainloop_time_free(pa_time_event *e) {