This is a minor optimization too, but the main benefit is that it's makes the code easier to understand (I hope), since run_callback() won't be called at times when it's not needed. --- src/modules/bluetooth/bluetooth-util.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c index 393aec3..6b3085b 100644 --- a/src/modules/bluetooth/bluetooth-util.c +++ b/src/modules/bluetooth/bluetooth-util.c @@ -516,6 +516,8 @@ static void device_update_any_audio_profile_connected(pa_bluetooth_device *d) { pa_log_debug("Device %s has now at least one audio profile connected.", d->path); else pa_log_debug("Device %s doesn't have any audio profiles connected anymore.", d->path); + + run_callback(d, false); } static void get_properties_reply(DBusPendingCall *pending, void *userdata) { @@ -553,7 +555,7 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) { if (dbus_message_is_error(r, DBUS_ERROR_SERVICE_UNKNOWN)) { pa_log_debug("Bluetooth daemon is apparently not available."); remove_all_devices(y); - goto finish2; + goto finish; } if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) { @@ -621,10 +623,6 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) { } finish: - if (d != NULL) - run_callback(d, FALSE); - -finish2: dbus_message_unref(r); PA_LLIST_REMOVE(pa_dbus_pending, y->pending, p); @@ -890,8 +888,6 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us device_update_any_audio_profile_connected(d); } - - run_callback(d, FALSE); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -- 1.7.10.4