]> code.delx.au - pulseaudio/blobdiff - src/pulse/mainloop-signal.c
proplist: Return early from pa_proplist_equal() if the pointers are equal.
[pulseaudio] / src / pulse / mainloop-signal.c
index 8ad465bd0bd90c9f9f70f1bcfbe388d9f5571da1..3dc74398182bf5ffbbda2b526aa55cf475a39f17 100644 (file)
@@ -1,14 +1,12 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
 /***
   This file is part of PulseAudio.
 
-  Copyright 2004-2006 Lennart Poettering
+  Copyright 2004-2008 Lennart Poettering
   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -40,6 +38,7 @@
 
 #include <pulse/xmalloc.h>
 #include <pulse/gccmacro.h>
 
 #include <pulse/xmalloc.h>
 #include <pulse/gccmacro.h>
+#include <pulse/i18n.h>
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
@@ -55,9 +54,9 @@ struct pa_signal_event {
 #else
     void (*saved_handler)(int sig);
 #endif
 #else
     void (*saved_handler)(int sig);
 #endif
-    void (*callback) (pa_mainloop_api*a, pa_signal_event *e, int sig, void *userdata);
     void *userdata;
     void *userdata;
-    void (*destroy_callback) (pa_mainloop_api*a, pa_signal_event*e, void *userdata);
+    pa_signal_cb_t callback;
+    pa_signal_destroy_cb_t destroy_callback;
     pa_signal_event *previous, *next;
 };
 
     pa_signal_event *previous, *next;
 };
 
@@ -74,6 +73,7 @@ static void signal_handler(int sig) {
 #ifndef HAVE_SIGACTION
     signal(sig, signal_handler);
 #endif
 #ifndef HAVE_SIGACTION
     signal(sig, signal_handler);
 #endif
+
     pa_write(signal_pipe[1], &sig, sizeof(sig), NULL);
 
     errno = saved_errno;
     pa_write(signal_pipe[1], &sig, sizeof(sig), NULL);
 
     errno = saved_errno;
@@ -90,7 +90,7 @@ static void dispatch(pa_mainloop_api*a, int sig) {
         }
 }
 
         }
 }
 
-static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags_t f, PA_GCC_UNUSED void *userdata) {
+static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags_t f, void *userdata) {
     ssize_t r;
     int sig;
 
     ssize_t r;
     int sig;
 
@@ -142,23 +142,21 @@ int pa_signal_init(pa_mainloop_api *a) {
 }
 
 void pa_signal_done(void) {
 }
 
 void pa_signal_done(void) {
-    pa_assert(api);
-    pa_assert(signal_pipe[0] >= 0);
-    pa_assert(signal_pipe[1] >= 0);
-    pa_assert(io_event);
-
     while (signals)
         pa_signal_free(signals);
 
     while (signals)
         pa_signal_free(signals);
 
-    api->io_free(io_event);
-    io_event = NULL;
+    if (io_event) {
+        pa_assert(api);
+        api->io_free(io_event);
+        io_event = NULL;
+    }
 
     pa_close_pipe(signal_pipe);
 
     api = NULL;
 }
 
 
     pa_close_pipe(signal_pipe);
 
     api = NULL;
 }
 
-pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata), void *userdata) {
+pa_signal_event* pa_signal_new(int sig, pa_signal_cb_t _callback, void *userdata) {
     pa_signal_event *e = NULL;
 
 #ifdef HAVE_SIGACTION
     pa_signal_event *e = NULL;
 
 #ifdef HAVE_SIGACTION
@@ -168,9 +166,11 @@ pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api,
     pa_assert(sig > 0);
     pa_assert(_callback);
 
     pa_assert(sig > 0);
     pa_assert(_callback);
 
+    pa_init_i18n();
+
     for (e = signals; e; e = e->next)
         if (e->sig == sig)
     for (e = signals; e; e = e->next)
         if (e->sig == sig)
-            goto fail;
+            return NULL;
 
     e = pa_xnew(pa_signal_event, 1);
     e->sig = sig;
 
     e = pa_xnew(pa_signal_event, 1);
     e->sig = sig;
@@ -196,8 +196,7 @@ pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api,
 
     return e;
 fail:
 
     return e;
 fail:
-    if (e)
-        pa_xfree(e);
+    pa_xfree(e);
     return NULL;
 }
 
     return NULL;
 }
 
@@ -223,7 +222,7 @@ void pa_signal_free(pa_signal_event *e) {
     pa_xfree(e);
 }
 
     pa_xfree(e);
 }
 
-void pa_signal_set_destroy(pa_signal_event *e, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata)) {
+void pa_signal_set_destroy(pa_signal_event *e, pa_signal_destroy_cb_t _callback) {
     pa_assert(e);
 
     e->destroy_callback = _callback;
     pa_assert(e);
 
     e->destroy_callback = _callback;