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
This commit is contained in:
Lennart Poettering 2006-07-13 23:12:50 +00:00
parent 7484b62e1e
commit 5529604147

View file

@ -139,7 +139,8 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv,
t->avahi_poll = p; t->avahi_poll = p;
t->callback = callback; t->callback = callback;
t->userdata = userdata; 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; return t;
} }
@ -147,12 +148,20 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv,
static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { static void timeout_update(AvahiTimeout *t, const struct timeval *tv) {
assert(t); assert(t);
if (t->time_event && tv)
t->avahi_poll->mainloop->time_restart(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) { static void timeout_free(AvahiTimeout *t) {
assert(t); assert(t);
if (t->time_event)
t->avahi_poll->mainloop->time_free(t->time_event); t->avahi_poll->mainloop->time_free(t->time_event);
pa_xfree(t); pa_xfree(t);
} }