spa: bluez: add send_with_reply() dbus helper

This function sends a DBusMessage on a DBusConnection
and sets the reply callback of the resulting DBusPendingCall,
as well as properly cancelling the pending call if anything fails.
This commit is contained in:
Barnabás Pőcze 2023-07-11 19:57:23 +02:00
parent 6e581deb91
commit b52d590936
7 changed files with 64 additions and 96 deletions

View file

@ -2429,7 +2429,6 @@ static int register_profile(struct impl *backend, const char *profile, const cha
dbus_bool_t autoconnect;
dbus_uint16_t version, chan, features;
char *str;
DBusPendingCall *call;
if (!(backend->enabled_profiles & spa_bt_profile_from_uuid(uuid)))
return -ECANCELED;
@ -2522,8 +2521,8 @@ static int register_profile(struct impl *backend, const char *profile, const cha
}
dbus_message_iter_close_container(&it[0], &it[1]);
dbus_connection_send_with_reply(backend->conn, m, &call, -1);
dbus_pending_call_set_notify(call, register_profile_reply, backend, NULL);
if (!send_with_reply(backend->conn, m, register_profile_reply, backend))
return -EIO;
return 0;
}