[polypaudio-commits] r757 - in /trunk/src: daemon/main.c polyp/mainloop-signal.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Apr 19 04:53:25 PDT 2006


Author: ossman
Date: Wed Apr 19 13:53:24 2006
New Revision: 757

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=757&root=polypaudio&view=rev
Log:
Having constant deferred events isn't allowed and causes problems. Use timers
instead.

Modified:
    trunk/src/daemon/main.c
    trunk/src/polyp/mainloop-signal.c

Modified: trunk/src/daemon/main.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/daemon/main.c?rev=757&root=polypaudio&r1=756&r2=757&view=diff
==============================================================================
--- trunk/src/daemon/main.c (original)
+++ trunk/src/daemon/main.c Wed Apr 19 13:53:24 2006
@@ -79,8 +79,9 @@
 
 #ifdef OS_IS_WIN32
 
-static void message_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
+static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
     MSG msg;
+    struct timeval tvnext;
 
     while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
         if (msg.message == WM_QUIT)
@@ -90,6 +91,9 @@
             DispatchMessage(&msg);
         }
     }
+
+    pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
+    a->time_restart(e, &tvnext);
 }
 
 #endif
@@ -153,7 +157,8 @@
 #endif
 
 #ifdef OS_IS_WIN32
-    pa_defer_event *defer;
+    pa_time_event *timer;
+    struct timeval tv;
 #endif
 
     pa_limit_caps();
@@ -386,8 +391,9 @@
 #endif
     
 #ifdef OS_IS_WIN32
-    defer = pa_mainloop_get_api(mainloop)->defer_new(pa_mainloop_get_api(mainloop), message_cb, NULL);
-    assert(defer);
+    timer = pa_mainloop_get_api(mainloop)->time_new(
+        pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
+    assert(timer);
 #endif
 
     if (conf->daemonize)
@@ -446,7 +452,7 @@
     }
 
 #ifdef OS_IS_WIN32
-    pa_mainloop_get_api(mainloop)->defer_free(defer);
+    pa_mainloop_get_api(mainloop)->time_free(timer);
 #endif
 
     pa_core_free(c);

Modified: trunk/src/polyp/mainloop-signal.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/mainloop-signal.c?rev=757&root=polypaudio&r1=756&r2=757&view=diff
==============================================================================
--- trunk/src/polyp/mainloop-signal.c (original)
+++ trunk/src/polyp/mainloop-signal.c Wed Apr 19 13:53:24 2006
@@ -59,7 +59,7 @@
 static pa_mainloop_api *api = NULL;
 static int signal_pipe[2] = { -1, -1 };
 static pa_io_event* io_event = NULL;
-static pa_defer_event *defer_event = NULL;
+static pa_time_event *time_event = NULL;
 static pa_signal_event *signals = NULL;
 
 #ifdef OS_IS_WIN32
@@ -92,10 +92,11 @@
 }
 
 #ifdef OS_IS_WIN32
-static void defer(pa_mainloop_api*a, PA_GCC_UNUSED pa_defer_event*e, PA_GCC_UNUSED void *userdata) {
+static void timer(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, PA_GCC_UNUSED void *userdata) {
     ssize_t r;
     int sig;
     unsigned int sigs;
+    struct timeval tvnext;
 
     EnterCriticalSection(&crit);
     sigs = waiting_signals;
@@ -117,6 +118,9 @@
 
         sigs--;
     }
+
+    pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
+    a->time_restart(e, &tvnext);
 }
 #endif
 
@@ -143,7 +147,11 @@
 }
 
 int pa_signal_init(pa_mainloop_api *a) {
-    assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event && !defer_event);
+#ifdef OS_IS_WIN32
+    struct timeval tv;
+#endif
+
+    assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event && !time_event);
 
 #ifdef OS_IS_WIN32
     if (_pipe(signal_pipe, 200, _O_BINARY) < 0) {
@@ -165,8 +173,8 @@
     io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
     assert(io_event);
 #else
-    defer_event = api->defer_new(api, defer, NULL);
-    assert(defer_event);
+    time_event = api->time_new(api, pa_gettimeofday(&tv), timer, NULL);
+    assert(time_event);
 
     InitializeCriticalSection(&crit);
 #endif
@@ -175,7 +183,7 @@
 }
 
 void pa_signal_done(void) {
-    assert(api && signal_pipe[0] >= 0 && signal_pipe[1] >= 0 && (io_event || defer_event));
+    assert(api && signal_pipe[0] >= 0 && signal_pipe[1] >= 0 && (io_event || time_event));
 
     while (signals)
         pa_signal_free(signals);
@@ -184,8 +192,8 @@
     api->io_free(io_event);
     io_event = NULL;
 #else
-    api->defer_free(defer_event);
-    defer_event = NULL;
+    api->time_free(time_event);
+    time_event = NULL;
 
     DeleteCriticalSection(&crit);
 #endif




More information about the pulseaudio-commits mailing list