mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
spa: bluez: use spa_auto for DBusError
This commit is contained in:
parent
b52d590936
commit
ca85872e83
8 changed files with 44 additions and 124 deletions
|
|
@ -200,7 +200,7 @@ static int set_dbus_property(struct impl *backend,
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
m = dbus_message_new_method_call(HSPHFPD_SERVICE, path, DBUS_INTERFACE_PROPERTIES, "Set");
|
m = dbus_message_new_method_call(HSPHFPD_SERVICE, path, DBUS_INTERFACE_PROPERTIES, "Set");
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
|
|
@ -209,12 +209,9 @@ static int set_dbus_property(struct impl *backend,
|
||||||
dbus_message_iter_init_append(m, &iter);
|
dbus_message_iter_init_append(m, &iter);
|
||||||
dbus_message_iter_append_basic(&iter, type, value);
|
dbus_message_iter_append_basic(&iter, type, value);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
spa_log_error(backend->log, "Transport Set() failed for transport %s (%s)", path, err.message);
|
spa_log_error(backend->log, "Transport Set() failed for transport %s (%s)", path, err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -828,11 +825,9 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat
|
||||||
const char *transport_path;
|
const char *transport_path;
|
||||||
const char *service_id;
|
const char *service_id;
|
||||||
const char *agent_path;
|
const char *agent_path;
|
||||||
DBusError error;
|
spa_auto(DBusError) error = DBUS_ERROR_INIT;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dbus_error_init(&error);
|
|
||||||
|
|
||||||
backend->acquire_in_progress = false;
|
backend->acquire_in_progress = false;
|
||||||
|
|
||||||
spa_autoptr(DBusMessage) r = steal_reply_and_unref(&pending);
|
spa_autoptr(DBusMessage) r = steal_reply_and_unref(&pending);
|
||||||
|
|
@ -1198,8 +1193,7 @@ static int hsphfpd_register(struct impl *backend)
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
const char *path = APPLICATION_OBJECT_MANAGER_PATH;
|
const char *path = APPLICATION_OBJECT_MANAGER_PATH;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
int res;
|
|
||||||
|
|
||||||
spa_log_debug(backend->log, "Registering to hsphfpd");
|
spa_log_debug(backend->log, "Registering to hsphfpd");
|
||||||
|
|
||||||
|
|
@ -1210,21 +1204,17 @@ static int hsphfpd_register(struct impl *backend)
|
||||||
|
|
||||||
dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
|
dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
if (dbus_error_has_name(&err, "org.freedesktop.DBus.Error.ServiceUnknown")) {
|
if (dbus_error_has_name(&err, "org.freedesktop.DBus.Error.ServiceUnknown")) {
|
||||||
spa_log_info(backend->log, "hsphfpd not available: %s",
|
spa_log_info(backend->log, "hsphfpd not available: %s",
|
||||||
err.message);
|
err.message);
|
||||||
res = -ENOTSUP;
|
return -ENOTSUP;
|
||||||
} else {
|
} else {
|
||||||
spa_log_warn(backend->log, "Registering application %s failed: %s (%s)",
|
spa_log_warn(backend->log, "Registering application %s failed: %s (%s)",
|
||||||
path, err.message, err.name);
|
path, err.message, err.name);
|
||||||
res = -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
dbus_error_free(&err);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
|
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
|
||||||
|
|
@ -1389,18 +1379,17 @@ finish:
|
||||||
static int add_filters(void *data)
|
static int add_filters(void *data)
|
||||||
{
|
{
|
||||||
struct impl *backend = data;
|
struct impl *backend = data;
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
if (backend->filters_added)
|
if (backend->filters_added)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter(backend->conn, hsphfpd_filter_cb, backend, NULL)) {
|
if (!dbus_connection_add_filter(backend->conn, hsphfpd_filter_cb, backend, NULL)) {
|
||||||
spa_log_error(backend->log, "failed to add filter function");
|
spa_log_error(backend->log, "failed to add filter function");
|
||||||
goto fail;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
dbus_bus_add_match(backend->conn,
|
dbus_bus_add_match(backend->conn,
|
||||||
"type='signal',sender='" HSPHFPD_SERVICE "',"
|
"type='signal',sender='" HSPHFPD_SERVICE "',"
|
||||||
"interface='" DBUS_INTERFACE_OBJECTMANAGER "',member='InterfacesAdded'", &err);
|
"interface='" DBUS_INTERFACE_OBJECTMANAGER "',member='InterfacesAdded'", &err);
|
||||||
|
|
@ -1419,10 +1408,6 @@ static int add_filters(void *data)
|
||||||
backend->filters_added = true;
|
backend->filters_added = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int backend_hsphfpd_free(void *data)
|
static int backend_hsphfpd_free(void *data)
|
||||||
|
|
@ -1458,21 +1443,17 @@ static const struct spa_bt_backend_implementation backend_impl = {
|
||||||
static bool is_available(struct impl *backend)
|
static bool is_available(struct impl *backend)
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
m = dbus_message_new_method_call(HSPHFPD_SERVICE, "/",
|
m = dbus_message_new_method_call(HSPHFPD_SERVICE, "/",
|
||||||
DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
|
DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r && dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
if (r && dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!r)
|
|
||||||
dbus_error_free(&err);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2530,7 +2530,7 @@ static int register_profile(struct impl *backend, const char *profile, const cha
|
||||||
static void unregister_profile(struct impl *backend, const char *profile)
|
static void unregister_profile(struct impl *backend, const char *profile)
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_log_debug(backend->log, "Unregistering Profile %s", profile);
|
spa_log_debug(backend->log, "Unregistering Profile %s", profile);
|
||||||
|
|
||||||
|
|
@ -2541,12 +2541,9 @@ static void unregister_profile(struct impl *backend, const char *profile)
|
||||||
|
|
||||||
dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &profile, DBUS_TYPE_INVALID);
|
dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &profile, DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
spa_log_info(backend->log, "Unregistering Profile %s failed", profile);
|
spa_log_info(backend->log, "Unregistering Profile %s failed", profile);
|
||||||
dbus_error_free(&err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ finish:
|
||||||
static int _audio_acquire(struct impl *backend, const char *path, uint8_t *codec)
|
static int _audio_acquire(struct impl *backend, const char *path, uint8_t *codec)
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
m = dbus_message_new_method_call(OFONO_SERVICE, path,
|
m = dbus_message_new_method_call(OFONO_SERVICE, path,
|
||||||
|
|
@ -150,7 +150,6 @@ static int _audio_acquire(struct impl *backend, const char *path, uint8_t *codec
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: We assume here oFono replies. It however can happen that the headset does
|
* XXX: We assume here oFono replies. It however can happen that the headset does
|
||||||
|
|
@ -163,7 +162,6 @@ static int _audio_acquire(struct impl *backend, const char *path, uint8_t *codec
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
spa_log_error(backend->log, "Transport Acquire() failed for transport %s (%s)",
|
spa_log_error(backend->log, "Transport Acquire() failed for transport %s (%s)",
|
||||||
path, err.message);
|
path, err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,7 +175,6 @@ static int _audio_acquire(struct impl *backend, const char *path, uint8_t *codec
|
||||||
DBUS_TYPE_BYTE, codec,
|
DBUS_TYPE_BYTE, codec,
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
spa_log_error(backend->log, "Failed to parse Acquire() reply: %s", err.message);
|
spa_log_error(backend->log, "Failed to parse Acquire() reply: %s", err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -654,8 +651,8 @@ static int ofono_register(struct impl *backend)
|
||||||
const char *path = OFONO_AUDIO_CLIENT;
|
const char *path = OFONO_AUDIO_CLIENT;
|
||||||
uint8_t codecs[2];
|
uint8_t codecs[2];
|
||||||
const uint8_t *pcodecs = codecs;
|
const uint8_t *pcodecs = codecs;
|
||||||
int ncodecs = 0, res;
|
int ncodecs = 0;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_log_debug(backend->log, "Registering");
|
spa_log_debug(backend->log, "Registering");
|
||||||
|
|
||||||
|
|
@ -672,21 +669,17 @@ static int ofono_register(struct impl *backend)
|
||||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &pcodecs, ncodecs,
|
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &pcodecs, ncodecs,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
if (dbus_error_has_name(&err, "org.freedesktop.DBus.Error.ServiceUnknown")) {
|
if (dbus_error_has_name(&err, "org.freedesktop.DBus.Error.ServiceUnknown")) {
|
||||||
spa_log_info(backend->log, "oFono not available: %s",
|
spa_log_info(backend->log, "oFono not available: %s",
|
||||||
err.message);
|
err.message);
|
||||||
res = -ENOTSUP;
|
return -ENOTSUP;
|
||||||
} else {
|
} else {
|
||||||
spa_log_warn(backend->log, "Registering Profile %s failed: %s (%s)",
|
spa_log_warn(backend->log, "Registering Profile %s failed: %s (%s)",
|
||||||
path, err.message, err.name);
|
path, err.message, err.name);
|
||||||
res = -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
dbus_error_free(&err);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbus_message_is_error(r, OFONO_ERROR_INVALID_ARGUMENTS)) {
|
if (dbus_message_is_error(r, OFONO_ERROR_INVALID_ARGUMENTS)) {
|
||||||
|
|
@ -747,9 +740,6 @@ static int backend_ofono_register(void *data)
|
||||||
static DBusHandlerResult ofono_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
static DBusHandlerResult ofono_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
||||||
{
|
{
|
||||||
struct impl *backend = user_data;
|
struct impl *backend = user_data;
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (dbus_message_is_signal(m, OFONO_HF_AUDIO_MANAGER_INTERFACE, "CardAdded")) {
|
if (dbus_message_is_signal(m, OFONO_HF_AUDIO_MANAGER_INTERFACE, "CardAdded")) {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
@ -770,6 +760,7 @@ static DBusHandlerResult ofono_filter_cb(DBusConnection *bus, DBusMessage *m, vo
|
||||||
return ofono_audio_card_found(backend, p, &props_i);
|
return ofono_audio_card_found(backend, p, &props_i);
|
||||||
} else if (dbus_message_is_signal(m, OFONO_HF_AUDIO_MANAGER_INTERFACE, "CardRemoved")) {
|
} else if (dbus_message_is_signal(m, OFONO_HF_AUDIO_MANAGER_INTERFACE, "CardRemoved")) {
|
||||||
const char *p;
|
const char *p;
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
if (!dbus_message_get_args(m, &err, DBUS_TYPE_OBJECT_PATH, &p, DBUS_TYPE_INVALID)) {
|
if (!dbus_message_get_args(m, &err, DBUS_TYPE_OBJECT_PATH, &p, DBUS_TYPE_INVALID)) {
|
||||||
spa_log_error(backend->log, "Failed to parse org.ofono.HandsfreeAudioManager.CardRemoved: %s", err.message);
|
spa_log_error(backend->log, "Failed to parse org.ofono.HandsfreeAudioManager.CardRemoved: %s", err.message);
|
||||||
|
|
@ -785,18 +776,16 @@ fail:
|
||||||
|
|
||||||
static int add_filters(struct impl *backend)
|
static int add_filters(struct impl *backend)
|
||||||
{
|
{
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
if (backend->filters_added)
|
if (backend->filters_added)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter(backend->conn, ofono_filter_cb, backend, NULL)) {
|
if (!dbus_connection_add_filter(backend->conn, ofono_filter_cb, backend, NULL)) {
|
||||||
spa_log_error(backend->log, "failed to add filter function");
|
spa_log_error(backend->log, "failed to add filter function");
|
||||||
goto fail;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
dbus_bus_add_match(backend->conn,
|
dbus_bus_add_match(backend->conn,
|
||||||
"type='signal',sender='" OFONO_SERVICE "',"
|
"type='signal',sender='" OFONO_SERVICE "',"
|
||||||
"interface='" OFONO_HF_AUDIO_MANAGER_INTERFACE "',member='CardAdded'", &err);
|
"interface='" OFONO_HF_AUDIO_MANAGER_INTERFACE "',member='CardAdded'", &err);
|
||||||
|
|
@ -807,10 +796,6 @@ static int add_filters(struct impl *backend)
|
||||||
backend->filters_added = true;
|
backend->filters_added = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int backend_ofono_free(void *data)
|
static int backend_ofono_free(void *data)
|
||||||
|
|
@ -841,21 +826,17 @@ static const struct spa_bt_backend_implementation backend_impl = {
|
||||||
static bool is_available(struct impl *backend)
|
static bool is_available(struct impl *backend)
|
||||||
{
|
{
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
m = dbus_message_new_method_call(OFONO_SERVICE, "/",
|
m = dbus_message_new_method_call(OFONO_SERVICE, "/",
|
||||||
DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
|
DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||||
if (r && dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
if (r && dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!r)
|
|
||||||
dbus_error_free(&err);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -525,19 +525,16 @@ static DBusHandlerResult endpoint_select_configuration(DBusConnection *conn, DBu
|
||||||
uint8_t *cap, config[A2DP_MAX_CAPS_SIZE];
|
uint8_t *cap, config[A2DP_MAX_CAPS_SIZE];
|
||||||
uint8_t *pconf = (uint8_t *) config;
|
uint8_t *pconf = (uint8_t *) config;
|
||||||
spa_autoptr(DBusMessage) r = NULL;
|
spa_autoptr(DBusMessage) r = NULL;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
int size, res;
|
int size, res;
|
||||||
const struct media_codec *codec;
|
const struct media_codec *codec;
|
||||||
bool sink;
|
bool sink;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
path = dbus_message_get_path(m);
|
path = dbus_message_get_path(m);
|
||||||
|
|
||||||
if (!dbus_message_get_args(m, &err, DBUS_TYPE_ARRAY,
|
if (!dbus_message_get_args(m, &err, DBUS_TYPE_ARRAY,
|
||||||
DBUS_TYPE_BYTE, &cap, &size, DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_BYTE, &cap, &size, DBUS_TYPE_INVALID)) {
|
||||||
spa_log_error(monitor->log, "Endpoint SelectConfiguration(): %s", err.message);
|
spa_log_error(monitor->log, "Endpoint SelectConfiguration(): %s", err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
spa_log_info(monitor->log, "%p: %s select conf %d", monitor, path, size);
|
spa_log_info(monitor->log, "%p: %s select conf %d", monitor, path, size);
|
||||||
|
|
@ -3185,7 +3182,7 @@ static void transport_set_property_volume_reply(DBusPendingCall *pending, void *
|
||||||
{
|
{
|
||||||
struct spa_bt_transport *transport = user_data;
|
struct spa_bt_transport *transport = user_data;
|
||||||
struct spa_bt_monitor *monitor = transport->monitor;
|
struct spa_bt_monitor *monitor = transport->monitor;
|
||||||
DBusError err = DBUS_ERROR_INIT;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_assert(transport->volume_call == pending);
|
spa_assert(transport->volume_call == pending);
|
||||||
spa_autoptr(DBusMessage) r = steal_reply_and_unref(&transport->volume_call);
|
spa_autoptr(DBusMessage) r = steal_reply_and_unref(&transport->volume_call);
|
||||||
|
|
@ -3193,7 +3190,6 @@ static void transport_set_property_volume_reply(DBusPendingCall *pending, void *
|
||||||
if (dbus_set_error_from_message(&err, r)) {
|
if (dbus_set_error_from_message(&err, r)) {
|
||||||
spa_log_info(monitor->log, "transport %p: set volume failed for transport %s: %s",
|
spa_log_info(monitor->log, "transport %p: set volume failed for transport %s: %s",
|
||||||
transport, transport->path, err.message);
|
transport, transport->path, err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
} else {
|
} else {
|
||||||
spa_log_debug(monitor->log, "transport %p: set volume complete",
|
spa_log_debug(monitor->log, "transport %p: set volume complete",
|
||||||
transport);
|
transport);
|
||||||
|
|
@ -3322,7 +3318,7 @@ static void transport_acquire_reply(DBusPendingCall *pending, void *user_data)
|
||||||
struct spa_bt_monitor *monitor = transport->monitor;
|
struct spa_bt_monitor *monitor = transport->monitor;
|
||||||
struct spa_bt_device *device = transport->device;
|
struct spa_bt_device *device = transport->device;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
struct spa_bt_transport *t, *t_linked;
|
struct spa_bt_transport *t, *t_linked;
|
||||||
|
|
||||||
spa_assert(transport->acquire_call == pending);
|
spa_assert(transport->acquire_call == pending);
|
||||||
|
|
@ -3338,8 +3334,6 @@ static void transport_acquire_reply(DBusPendingCall *pending, void *user_data)
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (transport->fd >= 0) {
|
if (transport->fd >= 0) {
|
||||||
spa_log_error(monitor->log, "transport %p: invalid duplicate acquire", transport);
|
spa_log_error(monitor->log, "transport %p: invalid duplicate acquire", transport);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
@ -3353,7 +3347,6 @@ static void transport_acquire_reply(DBusPendingCall *pending, void *user_data)
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
spa_log_error(monitor->log, "Failed to parse Acquire %s reply: %s",
|
spa_log_error(monitor->log, "Failed to parse Acquire %s reply: %s",
|
||||||
transport->path, err.message);
|
transport->path, err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
@ -3515,7 +3508,6 @@ static int do_transport_release(struct spa_bt_transport *transport)
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
struct spa_bt_transport *t_linked;
|
struct spa_bt_transport *t_linked;
|
||||||
bool is_idle = (transport->state == SPA_BT_TRANSPORT_STATE_IDLE);
|
bool is_idle = (transport->state == SPA_BT_TRANSPORT_STATE_IDLE);
|
||||||
DBusError err;
|
|
||||||
bool linked = false;
|
bool linked = false;
|
||||||
|
|
||||||
spa_log_debug(monitor->log, "transport %p: Release %s",
|
spa_log_debug(monitor->log, "transport %p: Release %s",
|
||||||
|
|
@ -3563,7 +3555,7 @@ static int do_transport_release(struct spa_bt_transport *transport)
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
r = dbus_connection_send_with_reply_and_block(monitor->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(monitor->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
if (is_idle) {
|
if (is_idle) {
|
||||||
|
|
@ -3578,7 +3570,6 @@ static int do_transport_release(struct spa_bt_transport *transport)
|
||||||
spa_log_error(monitor->log, "Failed to release transport %s: %s",
|
spa_log_error(monitor->log, "Failed to release transport %s: %s",
|
||||||
transport->path, err.message);
|
transport->path, err.message);
|
||||||
}
|
}
|
||||||
dbus_error_free(&err);
|
|
||||||
} else {
|
} else {
|
||||||
spa_log_info(monitor->log, "Transport %s released", transport->path);
|
spa_log_info(monitor->log, "Transport %s released", transport->path);
|
||||||
}
|
}
|
||||||
|
|
@ -4250,19 +4241,16 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn,
|
||||||
static DBusHandlerResult endpoint_clear_configuration(DBusConnection *conn, DBusMessage *m, void *userdata)
|
static DBusHandlerResult endpoint_clear_configuration(DBusConnection *conn, DBusMessage *m, void *userdata)
|
||||||
{
|
{
|
||||||
struct spa_bt_monitor *monitor = userdata;
|
struct spa_bt_monitor *monitor = userdata;
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
spa_autoptr(DBusMessage) r = NULL;
|
spa_autoptr(DBusMessage) r = NULL;
|
||||||
const char *transport_path;
|
const char *transport_path;
|
||||||
struct spa_bt_transport *transport;
|
struct spa_bt_transport *transport;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_message_get_args(m, &err,
|
if (!dbus_message_get_args(m, &err,
|
||||||
DBUS_TYPE_OBJECT_PATH, &transport_path,
|
DBUS_TYPE_OBJECT_PATH, &transport_path,
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
spa_log_warn(monitor->log, "Bad ClearConfiguration method call: %s",
|
spa_log_warn(monitor->log, "Bad ClearConfiguration method call: %s",
|
||||||
err.message);
|
err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5128,12 +5116,10 @@ static void get_managed_objects(struct spa_bt_monitor *monitor)
|
||||||
static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
||||||
{
|
{
|
||||||
struct spa_bt_monitor *monitor = user_data;
|
struct spa_bt_monitor *monitor = user_data;
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
||||||
const char *name, *old_owner, *new_owner;
|
const char *name, *old_owner, *new_owner;
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_log_debug(monitor->log, "Name owner changed %s", dbus_message_get_path(m));
|
spa_log_debug(monitor->log, "Name owner changed %s", dbus_message_get_path(m));
|
||||||
|
|
||||||
|
|
@ -5143,7 +5129,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
|
||||||
DBUS_TYPE_STRING, &new_owner,
|
DBUS_TYPE_STRING, &new_owner,
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
spa_log_error(monitor->log, "Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
|
spa_log_error(monitor->log, "Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
|
||||||
goto fail;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spa_streq(name, BLUEZ_SERVICE)) {
|
if (spa_streq(name, BLUEZ_SERVICE)) {
|
||||||
|
|
@ -5310,26 +5296,22 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
finish:
|
finish:
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_filters(struct spa_bt_monitor *this)
|
static void add_filters(struct spa_bt_monitor *this)
|
||||||
{
|
{
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
if (this->filters_added)
|
if (this->filters_added)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter(this->conn, filter_cb, this, NULL)) {
|
if (!dbus_connection_add_filter(this->conn, filter_cb, this, NULL)) {
|
||||||
spa_log_error(this->log, "failed to add filter function");
|
spa_log_error(this->log, "failed to add filter function");
|
||||||
goto fail;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
dbus_bus_add_match(this->conn,
|
dbus_bus_add_match(this->conn,
|
||||||
"type='signal',sender='org.freedesktop.DBus',"
|
"type='signal',sender='org.freedesktop.DBus',"
|
||||||
"interface='org.freedesktop.DBus',member='NameOwnerChanged',"
|
"interface='org.freedesktop.DBus',member='NameOwnerChanged',"
|
||||||
|
|
@ -5378,11 +5360,6 @@ static void add_filters(struct spa_bt_monitor *this)
|
||||||
"arg0='" BLUEZ_MEDIA_TRANSPORT_INTERFACE "'", &err);
|
"arg0='" BLUEZ_MEDIA_TRANSPORT_INTERFACE "'", &err);
|
||||||
|
|
||||||
this->filters_added = true;
|
this->filters_added = true;
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
||||||
|
|
@ -65,4 +65,8 @@ static inline DBusPendingCall *send_with_reply(DBusConnection *conn,
|
||||||
return pending_call;
|
return pending_call;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_DEFINE_AUTO_CLEANUP(DBusError, DBusError, {
|
||||||
|
dbus_error_free(thing);
|
||||||
|
})
|
||||||
|
|
||||||
#endif /* SPA_BLUEZ5_DBUS_HELPERS_H */
|
#endif /* SPA_BLUEZ5_DBUS_HELPERS_H */
|
||||||
|
|
|
||||||
|
|
@ -464,12 +464,10 @@ static void mm_clean_modem(struct impl *this)
|
||||||
static DBusHandlerResult mm_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
static DBusHandlerResult mm_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
||||||
{
|
{
|
||||||
struct impl *this = user_data;
|
struct impl *this = user_data;
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
||||||
const char *name, *old_owner, *new_owner;
|
const char *name, *old_owner, *new_owner;
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_log_debug(this->log, "Name owner changed %s", dbus_message_get_path(m));
|
spa_log_debug(this->log, "Name owner changed %s", dbus_message_get_path(m));
|
||||||
|
|
||||||
|
|
@ -673,18 +671,16 @@ finish:
|
||||||
|
|
||||||
static int add_filters(struct impl *this)
|
static int add_filters(struct impl *this)
|
||||||
{
|
{
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
if (this->filters_added)
|
if (this->filters_added)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter(this->conn, mm_filter_cb, this, NULL)) {
|
if (!dbus_connection_add_filter(this->conn, mm_filter_cb, this, NULL)) {
|
||||||
spa_log_error(this->log, "failed to add filter function");
|
spa_log_error(this->log, "failed to add filter function");
|
||||||
goto fail;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
dbus_bus_add_match(this->conn,
|
dbus_bus_add_match(this->conn,
|
||||||
"type='signal',sender='org.freedesktop.DBus',"
|
"type='signal',sender='org.freedesktop.DBus',"
|
||||||
"interface='org.freedesktop.DBus',member='NameOwnerChanged'," "arg0='" MM_DBUS_SERVICE "'", &err);
|
"interface='org.freedesktop.DBus',member='NameOwnerChanged'," "arg0='" MM_DBUS_SERVICE "'", &err);
|
||||||
|
|
@ -710,10 +706,6 @@ static int add_filters(struct impl *this)
|
||||||
this->filters_added = true;
|
this->filters_added = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mm_is_available(void *modemmanager)
|
bool mm_is_available(void *modemmanager)
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ int spa_bt_player_register(struct spa_bt_player *player, const char *adapter_pat
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(player, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(player, struct impl, this);
|
||||||
|
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
DBusMessageIter i;
|
DBusMessageIter i;
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
|
|
||||||
|
|
@ -341,11 +341,9 @@ int spa_bt_player_register(struct spa_bt_player *player, const char *adapter_pat
|
||||||
dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &impl->path);
|
dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &impl->path);
|
||||||
append_properties(impl, &i);
|
append_properties(impl, &i);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
r = dbus_connection_send_with_reply_and_block(impl->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(impl->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
spa_log_error(impl->log, "RegisterPlayer() failed (%s)", err.message);
|
spa_log_error(impl->log, "RegisterPlayer() failed (%s)", err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,7 +359,7 @@ int spa_bt_player_unregister(struct spa_bt_player *player, const char *adapter_p
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(player, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(player, struct impl, this);
|
||||||
|
|
||||||
DBusError err;
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
DBusMessageIter i;
|
DBusMessageIter i;
|
||||||
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
spa_autoptr(DBusMessage) m = NULL, r = NULL;
|
||||||
|
|
||||||
|
|
@ -376,11 +374,9 @@ int spa_bt_player_unregister(struct spa_bt_player *player, const char *adapter_p
|
||||||
dbus_message_iter_init_append(m, &i);
|
dbus_message_iter_init_append(m, &i);
|
||||||
dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &impl->path);
|
dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &impl->path);
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
r = dbus_connection_send_with_reply_and_block(impl->conn, m, -1, &err);
|
r = dbus_connection_send_with_reply_and_block(impl->conn, m, -1, &err);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
spa_log_error(impl->log, "UnregisterPlayer() failed (%s)", err.message);
|
spa_log_error(impl->log, "UnregisterPlayer() failed (%s)", err.message);
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,10 @@ static void upower_clean(struct impl *this)
|
||||||
static DBusHandlerResult upower_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
static DBusHandlerResult upower_filter_cb(DBusConnection *bus, DBusMessage *m, void *user_data)
|
||||||
{
|
{
|
||||||
struct impl *this = user_data;
|
struct impl *this = user_data;
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
|
||||||
const char *name, *old_owner, *new_owner;
|
const char *name, *old_owner, *new_owner;
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
spa_log_debug(this->log, "Name owner changed %s", dbus_message_get_path(m));
|
spa_log_debug(this->log, "Name owner changed %s", dbus_message_get_path(m));
|
||||||
|
|
||||||
|
|
@ -171,18 +169,16 @@ finish:
|
||||||
|
|
||||||
static int add_filters(struct impl *this)
|
static int add_filters(struct impl *this)
|
||||||
{
|
{
|
||||||
DBusError err;
|
|
||||||
|
|
||||||
if (this->filters_added)
|
if (this->filters_added)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbus_error_init(&err);
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter(this->conn, upower_filter_cb, this, NULL)) {
|
if (!dbus_connection_add_filter(this->conn, upower_filter_cb, this, NULL)) {
|
||||||
spa_log_error(this->log, "failed to add filter function");
|
spa_log_error(this->log, "failed to add filter function");
|
||||||
goto fail;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spa_auto(DBusError) err = DBUS_ERROR_INIT;
|
||||||
|
|
||||||
dbus_bus_add_match(this->conn,
|
dbus_bus_add_match(this->conn,
|
||||||
"type='signal',sender='org.freedesktop.DBus',"
|
"type='signal',sender='org.freedesktop.DBus',"
|
||||||
"interface='org.freedesktop.DBus',member='NameOwnerChanged'," "arg0='" UPOWER_SERVICE "'", &err);
|
"interface='org.freedesktop.DBus',member='NameOwnerChanged'," "arg0='" UPOWER_SERVICE "'", &err);
|
||||||
|
|
@ -194,10 +190,6 @@ static int add_filters(struct impl *this)
|
||||||
this->filters_added = true;
|
this->filters_added = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
dbus_error_free(&err);
|
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *upower_register(struct spa_log *log,
|
void *upower_register(struct spa_log *log,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue