From 0d7be3148e872d0d2a68ecd740a596a3bcf4db5a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 26 Jul 2006 22:39:06 +0000 Subject: mainloop fixes: when disabling time events when dispatching them, make sure to adjust the cache time event and enabled time event counters git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1153 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulse/glib-mainloop.c | 7 ++++++- src/pulse/mainloop.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/glib-mainloop.c b/src/pulse/glib-mainloop.c index 76767552..201b6e23 100644 --- a/src/pulse/glib-mainloop.c +++ b/src/pulse/glib-mainloop.c @@ -573,7 +573,10 @@ static gboolean dispatch_func(GSource *source, PA_GCC_UNUSED GSourceFunc callbac tvnow.tv_usec = now.tv_usec; if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) { - t->enabled = 0; + + /* Disable time event */ + glib_time_restart(t, NULL); + t->callback(&g->api, t, &t->timeval, t->userdata); return TRUE; } @@ -634,6 +637,8 @@ pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) { g->n_enabled_defer_events = g->n_enabled_time_events = 0; g->io_events_please_scan = g->time_events_please_scan = g->defer_events_please_scan = 0; + + g->cached_next_time_event = NULL; g_source_attach(&g->source, g->context); g_source_set_can_recurse(&g->source, FALSE); diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 682b2ccd..699c0ee7 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -766,7 +766,12 @@ static int dispatch_timeout(pa_mainloop *m) { if (pa_timeval_cmp(&e->timeval, &now) <= 0) { assert(e->callback); - e->enabled = 0; + /* Disable time event */ + mainloop_time_restart(e, NULL); + + if (m->cached_next_time_event == e) + m->cached_next_time_event = NULL; + e->callback(&m->api, e, &e->timeval, e->userdata); r++; -- cgit