support time events with NULL timevals which are OK in avahi, but not in PA. This...
authorLennart Poettering <lennart@poettering.net>
Thu, 13 Jul 2006 23:12:50 +0000 (23:12 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 13 Jul 2006 23:12:50 +0000 (23:12 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1076 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulsecore/avahi-wrap.c

index 9da7655..80256a1 100644 (file)
@@ -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);
 }