]> code.delx.au - pulseaudio/blobdiff - src/modules/bluetooth/bluetooth-util.c
dbus: remove filter functions only if they were actually set before
[pulseaudio] / src / modules / bluetooth / bluetooth-util.c
index 47d6200575c399558f4b4d8c1effde00a5208d61..795d51081207153f2af0487c675c3ba56c3fed57 100644 (file)
@@ -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);
     }