[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-147-g906d06b

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Dec 17 12:32:44 PST 2008


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  dcd498c5ad86bfdbda6d29e1b48aa8f02dc8ceaa (commit)

- Log -----------------------------------------------------------------
906d06b... it's better to always use the index of a module instead of the pa_module*
f5d40fa... unload tunnel modules from a new stack frame
b95539b... actually unload the modules from a new stack frame
86c6fd8... Don't store pointer to pa_module
c5b8eb7... introduce new function pa_module_unload_request_by_index
-----------------------------------------------------------------------

Summary of changes:
 src/modules/bluetooth/module-bluetooth-discover.c |    6 ++--
 src/modules/module-always-sink.c                  |   28 +++++++++++---------
 src/modules/module-hal-detect.c                   |    2 +-
 src/modules/module-zeroconf-discover.c            |    4 +-
 src/pulsecore/module.c                            |   10 +++++++
 src/pulsecore/module.h                            |    6 +++-
 6 files changed, 35 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------

commit c5b8eb7edf73ecaccdce957b63f4113e34d5b291
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:19:34 2008 +0100

    introduce new function pa_module_unload_request_by_index

diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index 9b17cb9..56ed2c5 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -280,6 +280,16 @@ void pa_module_unload_request(pa_module *m, pa_bool_t force) {
     m->core->mainloop->defer_enable(m->core->module_defer_unload_event, 1);
 }
 
+void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force) {
+    pa_module *m;
+    pa_assert(c);
+
+    if (!(m = pa_idxset_get_by_index(c->modules, idx)))
+        return;
+
+    pa_module_unload_request(m, force);
+}
+
 void pa_module_set_used(pa_module*m, int used) {
     pa_assert(m);
 
diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h
index 365ab67..661b2dd 100644
--- a/src/pulsecore/module.h
+++ b/src/pulsecore/module.h
@@ -52,14 +52,16 @@ struct pa_module {
 };
 
 pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);
+
 void pa_module_unload(pa_core *c, pa_module *m, pa_bool_t force);
 void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force);
 
+void pa_module_unload_request(pa_module *m, pa_bool_t force);
+void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force);
+
 void pa_module_unload_all(pa_core *c);
 void pa_module_unload_unused(pa_core *c);
 
-void pa_module_unload_request(pa_module *m, pa_bool_t force);
-
 void pa_module_set_used(pa_module*m, int used);
 
 #define PA_MODULE_AUTHOR(s)                                     \

commit 86c6fd85f11d63ba1cf634124a0971a66f244139
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:19:53 2008 +0100

    Don't store pointer to pa_module
    
    pa_module pointers might become invalid at any time, so we use the
    stable uin32_t index of the module for identifying or modules instead.

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index ddf944a..2fe0937 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -44,7 +44,7 @@ PA_MODULE_USAGE("");
 
 struct module {
     char *profile;
-    pa_module *pa_m;
+    uint32_t index;
     PA_LLIST_FIELDS(struct module);
 };
 
@@ -78,7 +78,7 @@ static struct module *module_new(const char *profile, pa_module *pa_m) {
 
     m = pa_xnew(struct module, 1);
     m->profile = pa_xstrdup(profile);
-    m->pa_m = pa_m;
+    m->index = pa_m->index;
     PA_LLIST_INIT(struct module, m);
 
     return m;
@@ -364,7 +364,7 @@ static void unload_module_for_device(struct userdata *u, struct device *d, const
     if (!(m = module_find(d, profile)))
         return;
 
-    pa_module_unload_request(m->pa_m, TRUE);
+    pa_module_unload_request_by_index(u->module->core, m->index, TRUE);
 
     PA_LLIST_REMOVE(struct module, d->module_list, m);
     module_free(m);

commit b95539b18b50c7766ac824a1732aae2a4d92eaeb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:20:51 2008 +0100

    actually unload the modules from a new stack frame

diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c
index c76a366..8c1ab32 100644
--- a/src/modules/module-hal-detect.c
+++ b/src/modules/module-hal-detect.c
@@ -511,7 +511,7 @@ static void device_removed_cb(LibHalContext* context, const char *udi) {
     pa_log_debug("Device removed: %s", udi);
 
     if ((d = pa_hashmap_remove(u->devices, udi))) {
-        pa_module_unload_by_index(u->core, d->index, TRUE);
+        pa_module_unload_request_by_index(u->core, d->index, TRUE);
         hal_device_free(d);
     }
 }

commit f5d40fa44851b39ebf14452d06fc7669d6bc4b88
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:27:07 2008 +0100

    unload tunnel modules from a new stack frame

diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c
index c8087ab..9a867cb 100644
--- a/src/modules/module-zeroconf-discover.c
+++ b/src/modules/module-zeroconf-discover.c
@@ -286,7 +286,7 @@ static void browser_cb(
         struct tunnel *t2;
 
         if ((t2 = pa_hashmap_get(u->tunnels, t))) {
-            pa_module_unload_by_index(u->core, t2->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t2->module_index, TRUE);
             pa_hashmap_remove(u->tunnels, t2);
             tunnel_free(t2);
         }
@@ -427,7 +427,7 @@ void pa__done(pa_module*m) {
         struct tunnel *t;
 
         while ((t = pa_hashmap_steal_first(u->tunnels))) {
-            pa_module_unload_by_index(u->core, t->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t->module_index, TRUE);
             tunnel_free(t);
         }
 

commit 906d06bd24b6a76003c101d83a08c030799ed037
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:32:40 2008 +0100

    it's better to always use the index of a module instead of the pa_module*

diff --git a/src/modules/module-always-sink.c b/src/modules/module-always-sink.c
index 9d60c29..cd3f311 100644
--- a/src/modules/module-always-sink.c
+++ b/src/modules/module-always-sink.c
@@ -50,7 +50,7 @@ static const char* const valid_modargs[] = {
 
 struct userdata {
     pa_hook_slot *put_slot, *unlink_slot;
-    pa_module* null_module;
+    uint32_t null_module;
     pa_bool_t ignore;
     char *sink_name;
 };
@@ -59,10 +59,11 @@ static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata*
     pa_sink *target;
     uint32_t idx;
     char *t;
+    pa_module *m;
 
     pa_assert(c);
     pa_assert(u);
-    pa_assert(!u->null_module);
+    pa_assert(u->null_module == PA_INVALID_INDEX);
 
     /* Loop through all sinks and check to see if we have *any*
      * sinks. Ignore the sink passed in (if it's not null) */
@@ -78,12 +79,13 @@ static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata*
     u->ignore = TRUE;
 
     t = pa_sprintf_malloc("sink_name=%s", u->sink_name);
-    u->null_module = pa_module_load(c, "module-null-sink", t);
+    m = pa_module_load(c, "module-null-sink", t);
+    u->null_module = m ? m->index : PA_INVALID_INDEX;
     pa_xfree(t);
 
     u->ignore = FALSE;
 
-    if (!u->null_module)
+    if (!m)
         pa_log_warn("Unable to load module-null-sink");
 }
 
@@ -99,17 +101,17 @@ static pa_hook_result_t put_hook_callback(pa_core *c, pa_sink *sink, void* userd
         return PA_HOOK_OK;
 
     /* Auto-loaded null-sink not active, so ignoring newly detected sink. */
-    if (!u->null_module)
+    if (u->null_module == PA_INVALID_INDEX)
         return PA_HOOK_OK;
 
     /* This is us detecting ourselves on load in a different way... just ignore this too. */
-    if (sink->module == u->null_module)
+    if (sink->module && sink->module->index == u->null_module)
         return PA_HOOK_OK;
 
     pa_log_info("A new sink has been discovered. Unloading null-sink.");
 
-    pa_module_unload_request(u->null_module, TRUE);
-    u->null_module = NULL;
+    pa_module_unload_request_by_index(c, u->null_module, TRUE);
+    u->null_module = PA_INVALID_INDEX;
 
     return PA_HOOK_OK;
 }
@@ -122,9 +124,9 @@ static pa_hook_result_t unlink_hook_callback(pa_core *c, pa_sink *sink, void* us
     pa_assert(u);
 
     /* First check to see if it's our own null-sink that's been removed... */
-    if (u->null_module && sink->module == u->null_module) {
+    if (u->null_module != PA_INVALID_INDEX && sink->module && sink->module->index == u->null_module) {
         pa_log_debug("Autoloaded null-sink removed");
-        u->null_module = NULL;
+        u->null_module = PA_INVALID_INDEX;
         return PA_HOOK_OK;
     }
 
@@ -148,7 +150,7 @@ int pa__init(pa_module*m) {
     u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
     u->put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) put_hook_callback, u);
     u->unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) unlink_hook_callback, u);
-    u->null_module = NULL;
+    u->null_module = PA_INVALID_INDEX;
     u->ignore = FALSE;
 
     pa_modargs_free(ma);
@@ -170,8 +172,8 @@ void pa__done(pa_module*m) {
         pa_hook_slot_free(u->put_slot);
     if (u->unlink_slot)
         pa_hook_slot_free(u->unlink_slot);
-    if (u->null_module)
-        pa_module_unload_request(u->null_module, TRUE);
+    if (u->null_module != PA_INVALID_INDEX)
+        pa_module_unload_request_by_index(m->core, u->null_module, TRUE);
 
     pa_xfree(u->sink_name);
     pa_xfree(u);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list