From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx> The use of the pseudo-blocking D-Bus calls leads to the problem that NameLost signals are received after the reply to ReleaseName(). The problem with this is that a later acquisition of the same audio device can potentially receive the NameLost signal corresponding to the previous instance, due to the fact that the signal hasn't been popped from the D-Bus message queue. The simplest approach to solve this problem is to use private connections. In this case the DBusConnection will not be reused across different device reservations, avoiding any possible ambiguous D-Bus messages. --- src/modules/reserve-wrap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/reserve-wrap.c b/src/modules/reserve-wrap.c index 1411d27..8671d68 100644 --- a/src/modules/reserve-wrap.c +++ b/src/modules/reserve-wrap.c @@ -34,6 +34,7 @@ #ifdef HAVE_DBUS #include <pulsecore/dbus-shared.h> +#include <pulsecore/dbus-util.h> #include "reserve.h" #include "reserve-monitor.h" #endif @@ -46,7 +47,7 @@ struct pa_reserve_wrapper { pa_hook hook; char *shared_name; #ifdef HAVE_DBUS - pa_dbus_connection *connection; + pa_dbus_wrap_connection *connection; struct rd_device *device; #endif }; @@ -69,8 +70,10 @@ static void reserve_wrapper_free(pa_reserve_wrapper *r) { if (r->device) rd_release(r->device); - if (r->connection) - pa_dbus_connection_unref(r->connection); + if (r->connection) { + pa_assert_se(rm_unregister_private_bus(pa_dbus_wrap_connection_get(r->connection)) == 0); + pa_dbus_wrap_connection_free(r->connection); + } #endif pa_hook_done(&r->hook); @@ -108,6 +111,7 @@ pa_reserve_wrapper* pa_reserve_wrapper_get(pa_core *c, const char *device_name) char *t; #ifdef HAVE_DBUS int k; + DBusConnection *conn; DBusError error; dbus_error_init(&error); @@ -136,7 +140,7 @@ pa_reserve_wrapper* pa_reserve_wrapper_get(pa_core *c, const char *device_name) pa_assert_se(pa_shared_set(c, r->shared_name, r) >= 0); #ifdef HAVE_DBUS - if (!(r->connection = pa_dbus_bus_get(c, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) { + if (!(conn = dbus_bus_get_private(DBUS_BUS_SESSION, &error))) { pa_log_debug("Unable to contact D-Bus session bus: %s: %s", error.name, error.message); /* We don't treat this as error here because we want allow PA @@ -144,9 +148,12 @@ pa_reserve_wrapper* pa_reserve_wrapper_get(pa_core *c, const char *device_name) return r; } + pa_assert_se(r->connection = pa_dbus_wrap_connection_new_from_existing(c->mainloop, FALSE, conn)); + pa_assert_se(rm_register_private_bus(conn) == 0); + if ((k = rd_acquire( &r->device, - pa_dbus_connection_get(r->connection), + conn, device_name, _("PulseAudio Sound Server"), 0, -- 1.7.11.7