[polypaudio-commits] r734 - /trunk/src/polyp/mainloop.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Apr 16 10:25:14 PDT 2006


Author: lennart
Date: Sun Apr 16 19:25:14 2006
New Revision: 734

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=734&root=polypaudio&view=rev
Log:
* add pa_mainloop_wakeup() calls for deferred events
* place pa_mainloop_wakeup() calls a little bit more carfully, to minimize needless wakeups.

Modified:
    trunk/src/polyp/mainloop.c

Modified: trunk/src/polyp/mainloop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/mainloop.c?rev=734&root=polypaudio&r1=733&r2=734&view=diff
==============================================================================
--- trunk/src/polyp/mainloop.c (original)
+++ trunk/src/polyp/mainloop.c Sun Apr 16 19:25:14 2006
@@ -121,8 +121,6 @@
     m = a->userdata;
     assert(a == &m->api);
 
-    pa_mainloop_wakeup(m);
-
     e = pa_xmalloc(sizeof(pa_io_event));
     e->mainloop = m;
     e->dead = 0;
@@ -156,24 +154,27 @@
 
     pa_idxset_put(m->io_events, e, NULL);
     m->rebuild_pollfds = 1;
+
+    pa_mainloop_wakeup(m);
+
     return e;
 }
 
 static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
     assert(e && e->mainloop);
 
-    pa_mainloop_wakeup(e->mainloop);
-
     e->events = events;
     e->mainloop->rebuild_pollfds = 1;
+
+    pa_mainloop_wakeup(e->mainloop);
 }
 
 static void mainloop_io_free(pa_io_event *e) {
     assert(e && e->mainloop);
 
+    e->dead = e->mainloop->io_events_scan_dead = e->mainloop->rebuild_pollfds = 1;
+
     pa_mainloop_wakeup(e->mainloop);
-
-    e->dead = e->mainloop->io_events_scan_dead = e->mainloop->rebuild_pollfds = 1;
 }
 
 static void mainloop_io_set_destroy(pa_io_event *e, void (*callback)(pa_mainloop_api*a, pa_io_event *e, void *userdata)) {
@@ -202,6 +203,9 @@
     pa_idxset_put(m->defer_events, e, NULL);
 
     m->deferred_pending++;
+
+    pa_mainloop_wakeup(e->mainloop);
+
     return e;
 }
 
@@ -211,8 +215,10 @@
     if (e->enabled && !b) {
         assert(e->mainloop->deferred_pending > 0);
         e->mainloop->deferred_pending--;
-    } else if (!e->enabled && b)
+    } else if (!e->enabled && b) {
         e->mainloop->deferred_pending++;
+        pa_mainloop_wakeup(e->mainloop);
+    }
     
     e->enabled = b;
 }
@@ -242,8 +248,6 @@
     m = a->userdata;
     assert(a == &m->api);
 
-    pa_mainloop_wakeup(m);
-
     e = pa_xmalloc(sizeof(pa_time_event));
     e->mainloop = m;
     e->dead = 0;
@@ -257,18 +261,21 @@
     e->destroy_callback = NULL;
 
     pa_idxset_put(m->time_events, e, NULL);
+
+    if (e->enabled)
+        pa_mainloop_wakeup(m);
     
     return e;
 }
 
 static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
     assert(e);
-
-    pa_mainloop_wakeup(e->mainloop);
 
     if (tv) {
         e->enabled = 1;
         e->timeval = *tv;
+
+        pa_mainloop_wakeup(e->mainloop);
     } else
         e->enabled = 0;
 }
@@ -276,9 +283,9 @@
 static void mainloop_time_free(pa_time_event *e) {
     assert(e);
 
-    pa_mainloop_wakeup(e->mainloop);
-
     e->dead = e->mainloop->time_events_scan_dead = 1;
+
+    /* no wakeup needed here. Think about it! */
 }
 
 static void mainloop_time_set_destroy(pa_time_event *e, void (*callback)(pa_mainloop_api*a, pa_time_event *e, void *userdata)) {
@@ -294,10 +301,10 @@
     m = a->userdata;
     assert(a == &m->api);
 
-    pa_mainloop_wakeup(m);
-
     m->quit = 1;
     m->retval = retval;
+
+    pa_mainloop_wakeup(m);
 }
     
 static const pa_mainloop_api vtable = {




More information about the pulseaudio-commits mailing list