From 07a1c45cc1bd647d9a9c579a0c2bffd4c3d5fc1b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 22 Jul 2006 00:54:23 +0000 Subject: fix horribly broken glib timeout event handling git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1138 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulse/glib-mainloop.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pulse/glib-mainloop.c b/src/pulse/glib-mainloop.c index cdaecdf8..77f93450 100644 --- a/src/pulse/glib-mainloop.c +++ b/src/pulse/glib-mainloop.c @@ -312,7 +312,7 @@ static void glib_time_restart(pa_time_event*e, const struct timeval *tv) { assert(e); assert(!e->dead); - if (e->enabled && !!tv) + if (e->enabled && !tv) e->mainloop->n_enabled_time_events--; else if (!e->enabled && tv) e->mainloop->n_enabled_time_events++; @@ -476,13 +476,11 @@ static gboolean prepare_func(GSource *source, gint *timeout) { tvnow.tv_sec = now.tv_sec; tvnow.tv_usec = now.tv_usec; - usec = pa_timeval_diff(&t->timeval, &tvnow); - - if (usec <= 0) { + if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) { *timeout = 0; return TRUE; - } - + } + usec = pa_timeval_diff(&t->timeval, &tvnow); *timeout = (gint) (usec / 1000); } else *timeout = -1; @@ -554,7 +552,7 @@ static gboolean dispatch_func(GSource *source, PA_GCC_UNUSED GSourceFunc callbac tvnow.tv_sec = now.tv_sec; tvnow.tv_usec = now.tv_usec; - if (pa_timeval_cmp(&t->timeval, &tvnow) < 0) { + if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) { t->callback(&g->api, t, &t->timeval, t->userdata); return TRUE; } -- cgit