From 55296041473306ca4aa346197b60545814dfebe8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 13 Jul 2006 23:12:50 +0000 Subject: support time events with NULL timevals which are OK in avahi, but not in PA. This makes padevchooser actually work on top of the new avahi browsing stuff git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1076 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/avahi-wrap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pulsecore/avahi-wrap.c b/src/pulsecore/avahi-wrap.c index 9da76558..80256a12 100644 --- a/src/pulsecore/avahi-wrap.c +++ b/src/pulsecore/avahi-wrap.c @@ -139,7 +139,8 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, t->avahi_poll = p; t->callback = callback; t->userdata = userdata; - t->time_event = p->mainloop->time_new(p->mainloop, tv, timeout_callback, t); + + t->time_event = tv ? p->mainloop->time_new(p->mainloop, tv, timeout_callback, t) : NULL; return t; } @@ -147,13 +148,21 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { assert(t); - t->avahi_poll->mainloop->time_restart(t->time_event, tv); + if (t->time_event && tv) + t->avahi_poll->mainloop->time_restart(t->time_event, tv); + else if (!t->time_event && tv) + t->time_event = t->avahi_poll->mainloop->time_new(t->avahi_poll->mainloop, tv, timeout_callback, t); + else if (t->time_event && !tv) { + t->avahi_poll->mainloop->time_free(t->time_event); + t->time_event = NULL; + } } static void timeout_free(AvahiTimeout *t) { assert(t); - t->avahi_poll->mainloop->time_free(t->time_event); + if (t->time_event) + t->avahi_poll->mainloop->time_free(t->time_event); pa_xfree(t); } -- cgit