summaryrefslogtreecommitdiffstats
path: root/src/modules/bluetooth
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-08 20:06:21 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-08 20:06:21 +0100
commitc41ee00893b6b0d5cc48ee041b8e4835eac548f0 (patch)
tree60074e8bf938ce598ff68ecf22aa8726aaf86a12 /src/modules/bluetooth
parent06327b1e67af661cb3d73598e6f5f51e475e7ce6 (diff)
dbus: remove filter functions only if they were actually set before
This fixes an assert when destructing modules that have not been fully initialized. https://bugzilla.redhat.com/show_bug.cgi?id=548525
Diffstat (limited to 'src/modules/bluetooth')
-rw-r--r--src/modules/bluetooth/bluetooth-util.c5
-rw-r--r--src/modules/bluetooth/module-bluetooth-device.c7
-rw-r--r--src/modules/bluetooth/module-bluetooth-proximity.c11
3 files changed, 15 insertions, 8 deletions
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 47d62005..795d5108 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -37,6 +37,7 @@ struct pa_bluetooth_discovery {
PA_LLIST_HEAD(pa_dbus_pending, pending);
pa_hashmap *devices;
pa_hook hook;
+ pa_bool_t filter_added;
};
static void get_properties_reply(DBusPendingCall *pending, void *userdata);
@@ -788,6 +789,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
pa_log_error("Failed to add filter function");
goto fail;
}
+ y->filter_added = TRUE;
if (pa_dbus_add_matches(
pa_dbus_connection_get(y->connection), &err,
@@ -856,7 +858,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
"type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'", NULL);
- dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
+ if (y->filter_added)
+ dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
pa_dbus_connection_unref(y->connection);
}
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 0ba1421b..19676dfa 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -179,6 +179,8 @@ struct userdata {
int stream_write_type;
int service_write_type, service_read_type;
+
+ pa_bool_t filter_added;
};
#define FIXED_LATENCY_PLAYBACK_A2DP (25*PA_USEC_PER_MSEC)
@@ -2405,6 +2407,7 @@ int pa__init(pa_module* m) {
pa_log_error("Failed to add filter function");
goto fail;
}
+ u->filter_added = TRUE;
speaker = pa_sprintf_malloc("type='signal',sender='org.bluez',interface='org.bluez.Headset',member='SpeakerGainChanged',path='%s'", u->path);
mike = pa_sprintf_malloc("type='signal',sender='org.bluez',interface='org.bluez.Headset',member='MicrophoneGainChanged',path='%s'", u->path);
@@ -2494,7 +2497,9 @@ void pa__done(pa_module *m) {
pa_xfree(mike);
}
- dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
+ if (u->filter_added)
+ dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
+
pa_dbus_connection_unref(u->connection);
}
diff --git a/src/modules/bluetooth/module-bluetooth-proximity.c b/src/modules/bluetooth/module-bluetooth-proximity.c
index c4cfd733..3eed9cea 100644
--- a/src/modules/bluetooth/module-bluetooth-proximity.c
+++ b/src/modules/bluetooth/module-bluetooth-proximity.c
@@ -92,7 +92,8 @@ struct userdata {
unsigned n_found;
unsigned n_unknown;
- pa_bool_t muted;
+ pa_bool_t muted:1;
+ pa_bool_t filter_added:1;
};
static void update_volume(struct userdata *u) {
@@ -358,9 +359,10 @@ static int add_matches(struct userdata *u, pa_bool_t add) {
} else
dbus_bus_remove_match(pa_dbus_connection_get(u->dbus_connection), filter2, &e);
- if (add)
+ if (add) {
pa_assert_se(dbus_connection_add_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u, NULL));
- else
+ u->filter_added = TRUE;
+ } else if (u->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u);
r = 0;
@@ -393,9 +395,6 @@ int pa__init(pa_module*m) {
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
u->hci = pa_xstrdup(pa_modargs_get_value(ma, "hci", DEFAULT_HCI));
u->hci_path = pa_sprintf_malloc("/org/bluez/%s", u->hci);
- u->n_found = u->n_unknown = 0;
- u->muted = FALSE;
-
u->bondings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (!(u->dbus_connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &e))) {