]> code.delx.au - pulseaudio/blobdiff - src/modules/gconf/module-gconf.c
Remove unnecessary #includes
[pulseaudio] / src / modules / gconf / module-gconf.c
index a2a43278c17a87a5409c6b48ff464456262df775..3bad911315a15f4673b08e779fd99670ea7933b5 100644 (file)
@@ -5,7 +5,7 @@
 
   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
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <fcntl.h>
 
 #include <pulse/xmalloc.h>
 #include <pulsecore/module.h>
 #include <pulsecore/core.h>
-#include <pulsecore/llist.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
 #include <pulse/mainloop-api.h>
@@ -52,9 +50,6 @@ PA_MODULE_LOAD_ONCE(TRUE);
 #define MAX_MODULES 10
 #define BUF_MAX 2048
 
-/* #undef PA_GCONF_HELPER */
-/* #define PA_GCONF_HELPER "/home/lennart/projects/pulseaudio/src/gconf-helper" */
-
 struct module_item {
     char *name;
     char *args;
@@ -96,7 +91,7 @@ static int fill_buf(struct userdata *u) {
     if ((r = pa_read(u->fd, u->buf + u->buf_fill, BUF_MAX - u->buf_fill, &u->fd_type)) <= 0)
         return -1;
 
-    u->buf_fill += r;
+    u->buf_fill += (size_t) r;
     return 0;
 }
 
@@ -123,7 +118,7 @@ static char *read_string(struct userdata *u) {
 
         if ((e = memchr(u->buf, 0, u->buf_fill))) {
             char *ret = pa_xstrdup(u->buf);
-            u->buf_fill -= e - u->buf +1;
+            u->buf_fill -= (size_t) (e - u->buf +1);
             memmove(u->buf, e+1, u->buf_fill);
             return ret;
         }
@@ -142,7 +137,7 @@ static void unload_one_module(struct userdata *u, struct module_info*m, unsigned
         return;
 
     pa_log_debug("Unloading module #%i", m->items[i].index);
-    pa_module_unload_by_index(u->core, m->items[i].index);
+    pa_module_unload_by_index(u->core, m->items[i].index, TRUE);
     m->items[i].index = PA_INVALID_INDEX;
     pa_xfree(m->items[i].name);
     pa_xfree(m->items[i].args);
@@ -164,10 +159,10 @@ static void unload_all_modules(struct userdata *u, struct module_info*m) {
 static void load_module(
         struct userdata *u,
         struct module_info *m,
-        int i,
+        unsigned i,
         const char *name,
         const char *args,
-        int is_new) {
+        pa_bool_t is_new) {
 
     pa_module *mod;
 
@@ -324,7 +319,7 @@ static void io_event_cb(
             u->io_event = NULL;
         }
 
-        pa_module_unload_request(u->module);
+        pa_module_unload_request(u->module, TRUE);
     }
 }
 
@@ -343,7 +338,11 @@ int pa__init(pa_module*m) {
     u->io_event = NULL;
     u->buf_fill = 0;
 
-    if ((u->fd = pa_start_child_for_read(PA_GCONF_HELPER, NULL, &u->pid)) < 0)
+    if ((u->fd = pa_start_child_for_read(
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+                              pa_run_from_build_tree() ? PA_BUILDDIR "/gconf-helper" :
+#endif
+                 PA_GCONF_HELPER, NULL, &u->pid)) < 0)
         goto fail;
 
     u->io_event = m->core->mainloop->io_new(
@@ -378,7 +377,16 @@ void pa__done(pa_module*m) {
 
     if (u->pid != (pid_t) -1) {
         kill(u->pid, SIGTERM);
-        waitpid(u->pid, NULL, 0);
+
+        for (;;) {
+            if (waitpid(u->pid, NULL, 0) >= 0)
+                break;
+
+            if (errno != EINTR) {
+                pa_log("waitpid() failed: %s", pa_cstrerror(errno));
+                break;
+            }
+        }
     }
 
     if (u->io_event)
@@ -387,7 +395,6 @@ void pa__done(pa_module*m) {
     if (u->fd >= 0)
         pa_close(u->fd);
 
-
     if (u->module_infos)
         pa_hashmap_free(u->module_infos, module_info_free, u);