mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
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:
parent
6e581deb91
commit
b52d590936
7 changed files with 64 additions and 96 deletions
|
|
@ -44,4 +44,25 @@ static inline bool reply_with_error(DBusConnection *conn,
|
|||
return reply && dbus_connection_send(conn, reply, NULL);
|
||||
}
|
||||
|
||||
static inline DBusPendingCall *send_with_reply(DBusConnection *conn,
|
||||
DBusMessage *m,
|
||||
DBusPendingCallNotifyFunction callback, void *user_data)
|
||||
{
|
||||
DBusPendingCall *pending_call;
|
||||
|
||||
if (!dbus_connection_send_with_reply(conn, m, &pending_call, DBUS_TIMEOUT_USE_DEFAULT))
|
||||
return NULL;
|
||||
|
||||
if (!pending_call)
|
||||
return NULL;
|
||||
|
||||
if (!dbus_pending_call_set_notify(pending_call, callback, user_data, NULL)) {
|
||||
dbus_pending_call_cancel(pending_call);
|
||||
dbus_pending_call_unref(pending_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pending_call;
|
||||
}
|
||||
|
||||
#endif /* SPA_BLUEZ5_DBUS_HELPERS_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue