bluez5: improve debug

This commit is contained in:
Frédéric Danis 2020-12-08 18:24:31 +01:00 committed by Wim Taymans
parent a54cd1ee2b
commit bd051e89a5
2 changed files with 111 additions and 107 deletions

View file

@ -37,6 +37,8 @@
#include "defs.h"
#define NAME "hsphfpd"
struct spa_bt_backend {
struct spa_bt_monitor *monitor;
@ -222,13 +224,13 @@ static int set_dbus_property(struct spa_bt_backend *backend,
m = NULL;
if (r == NULL) {
spa_log_error(backend->log, "Transport Set() failed for transport %s (%s)", path, err.message);
spa_log_error(backend->log, NAME": Transport Set() failed for transport %s (%s)", path, err.message);
dbus_error_free(&err);
return -EIO;
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
spa_log_error(backend->log, "Set() returned error: %s", dbus_message_get_error_name(r));
spa_log_error(backend->log, NAME": Set() returned error: %s", dbus_message_get_error_name(r));
return -EIO;
}
@ -246,7 +248,7 @@ static inline void set_rx_volume_gain_property(const struct spa_bt_transport *tr
if (set_dbus_property(backend, HSPHFPD_SERVICE, transport_data->transport_path,
HSPHFPD_AUDIO_TRANSPORT_INTERFACE, "RxVolumeGain",
DBUS_TYPE_UINT16, &gain))
spa_log_error(backend->log, "Changing rx volume gain to %u for transport %s failed",
spa_log_error(backend->log, NAME": Changing rx volume gain to %u for transport %s failed",
(unsigned)gain, transport_data->transport_path);
}
@ -260,7 +262,7 @@ static inline void set_tx_volume_gain_property(const struct spa_bt_transport *tr
if (set_dbus_property(backend, HSPHFPD_SERVICE, transport_data->transport_path,
HSPHFPD_AUDIO_TRANSPORT_INTERFACE, "TxVolumeGain",
DBUS_TYPE_UINT16, &gain))
spa_log_error(backend->log, "Changing tx volume gain to %u for transport %s failed",
spa_log_error(backend->log, NAME": Changing tx volume gain to %u for transport %s failed",
(unsigned)gain, transport_data->transport_path);
}
@ -288,19 +290,19 @@ static void parse_transport_properties_values(struct spa_bt_backend *backend,
dbus_message_iter_recurse(&element_i, &dict_i);
if (dbus_message_iter_get_arg_type(&dict_i) != DBUS_TYPE_STRING) {
spa_log_error(backend->log, "Received invalid property for transport %s", transport_path);
spa_log_error(backend->log, NAME": Received invalid property for transport %s", transport_path);
return;
}
dbus_message_iter_get_basic(&dict_i, &key);
if (!dbus_message_iter_next(&dict_i)) {
spa_log_error(backend->log, "Received invalid property for transport %s", transport_path);
spa_log_error(backend->log, NAME": Received invalid property for transport %s", transport_path);
return;
}
if (dbus_message_iter_get_arg_type(&dict_i) != DBUS_TYPE_VARIANT) {
spa_log_error(backend->log, "Received invalid property for transport %s", transport_path);
spa_log_error(backend->log, NAME": Received invalid property for transport %s", transport_path);
return;
}
@ -323,7 +325,7 @@ static void parse_transport_properties_values(struct spa_bt_backend *backend,
volume_control = 0;
if (!volume_control)
spa_log_warn(backend->log, "Transport %s received invalid '%s' property value '%s', ignoring", transport_path, key, value);
spa_log_warn(backend->log, NAME": Transport %s received invalid '%s' property value '%s', ignoring", transport_path, key, value);
else if (strcmp(key, "RxVolumeControl") == 0)
*rx_volume_control = volume_control;
else if (strcmp(key, "TxVolumeControl") == 0)
@ -373,20 +375,20 @@ static void hsphfpd_parse_transport_properties(struct spa_bt_backend *backend, s
&rx_volume_gain, &tx_volume_gain, &mtu);
if (endpoint_path)
spa_log_warn(backend->log, "Transport %s received a duplicate '%s' property, ignoring",
spa_log_warn(backend->log, NAME": Transport %s received a duplicate '%s' property, ignoring",
transport_data->transport_path, "Endpoint");
if (air_codec)
spa_log_warn(backend->log, "Transport %s received a duplicate '%s' property, ignoring",
spa_log_warn(backend->log, NAME": Transport %s received a duplicate '%s' property, ignoring",
transport_data->transport_path, "AirCodec");
if (mtu)
spa_log_warn(backend->log, "Transport %s received a duplicate '%s' property, ignoring",
spa_log_warn(backend->log, NAME": Transport %s received a duplicate '%s' property, ignoring",
transport_data->transport_path, "MTU");
if (rx_volume_control) {
if (!!transport_data->rx_soft_volume != !!(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
spa_log_info(backend->log, "Transport %s changed rx soft volume from %d to %d",
spa_log_info(backend->log, NAME": Transport %s changed rx soft volume from %d to %d",
transport_data->transport_path, transport_data->rx_soft_volume,
(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport_data->rx_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
@ -400,7 +402,7 @@ static void hsphfpd_parse_transport_properties(struct spa_bt_backend *backend, s
if (tx_volume_control) {
if (!!transport_data->tx_soft_volume != !!(tx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
spa_log_info(backend->log, "Transport %s changed tx soft volume from %d to %d",
spa_log_info(backend->log, NAME": Transport %s changed tx soft volume from %d to %d",
transport_data->transport_path, transport_data->rx_soft_volume,
(tx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport_data->tx_soft_volume = (tx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
@ -414,7 +416,7 @@ static void hsphfpd_parse_transport_properties(struct spa_bt_backend *backend, s
if (rx_volume_gain != (uint16_t)-1) {
if (transport_data->rx_volume_gain != rx_volume_gain) {
spa_log_info(backend->log, "Transport %s changed rx volume gain from %u to %u",
spa_log_info(backend->log, NAME": Transport %s changed rx volume gain from %u to %u",
transport_data->transport_path, (unsigned)transport_data->rx_volume_gain, (unsigned)rx_volume_gain);
transport_data->rx_volume_gain = rx_volume_gain;
rx_volume_gain_changed = true;
@ -423,7 +425,7 @@ static void hsphfpd_parse_transport_properties(struct spa_bt_backend *backend, s
if (tx_volume_gain != (uint16_t)-1) {
if (transport_data->tx_volume_gain != tx_volume_gain) {
spa_log_info(backend->log, "Transport %s changed tx volume gain from %u to %u",
spa_log_info(backend->log, NAME": Transport %s changed tx volume gain from %u to %u",
transport_data->transport_path, (unsigned)transport_data->tx_volume_gain, (unsigned)tx_volume_gain);
transport_data->tx_volume_gain = tx_volume_gain;
tx_volume_gain_changed = true;
@ -437,8 +439,8 @@ static void hsphfpd_parse_transport_properties(struct spa_bt_backend *backend, s
if (tx_volume_gain_changed || tx_soft_volume_changed)
pa_hook_fire(pa_bluetooth_discovery_hook(transport_data->hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), transport);
#else
spa_log_debug(backend->log, "RX volume gain changed: %d, soft volume changed: %d", rx_volume_gain_changed, rx_soft_volume_changed);
spa_log_debug(backend->log, "TX volume gain changed: %d, soft volume changed: %d", tx_volume_gain_changed, tx_soft_volume_changed);
spa_log_debug(backend->log, NAME": RX volume gain changed: %d, soft volume changed: %d", rx_volume_gain_changed, rx_soft_volume_changed);
spa_log_debug(backend->log, NAME": TX volume gain changed: %d, soft volume changed: %d", tx_volume_gain_changed, tx_soft_volume_changed);
#endif
if (rx_volume_control_changed)
@ -581,12 +583,12 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
dbus_message_iter_next(&arg_i);
dbus_message_iter_get_basic(&arg_i, &fd);
spa_log_debug(backend->log, "NewConnection %s, fd %d", transport_path, fd);
spa_log_debug(backend->log, NAME": NewConnection %s, fd %d", transport_path, fd);
sender = dbus_message_get_sender(m);
if (strcmp(sender, backend->hsphfpd_service_id) != 0) {
close(fd);
spa_log_error(backend->log, "Sender '%s' is not authorized", sender);
spa_log_error(backend->log, NAME": Sender '%s' is not authorized", sender);
r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Sender '%s' is not authorized", sender);
goto fail;
}
@ -609,28 +611,28 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
if (!endpoint_path) {
close(fd);
spa_log_error(backend->log, "Endpoint property was not specified");
spa_log_error(backend->log, NAME": Endpoint property was not specified");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "Endpoint property was not specified");
goto fail;
}
if (!air_codec) {
close(fd);
spa_log_error(backend->log, "AirCodec property was not specified");
spa_log_error(backend->log, NAME": AirCodec property was not specified");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "AirCodec property was not specified");
goto fail;
}
if (!rx_volume_control) {
close(fd);
spa_log_error(backend->log, "RxVolumeControl property was not specified");
spa_log_error(backend->log, NAME": RxVolumeControl property was not specified");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "RxVolumeControl property was not specified");
goto fail;
}
if (!tx_volume_control) {
close(fd);
spa_log_error(backend->log, "TxVolumeControl property was not specified");
spa_log_error(backend->log, NAME": TxVolumeControl property was not specified");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "TxVolumeControl property was not specified");
goto fail;
}
@ -638,7 +640,7 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
if (rx_volume_control != HSPHFPD_VOLUME_CONTROL_NONE) {
if (rx_volume_gain == (uint16_t)-1) {
close(fd);
spa_log_error(backend->log, "RxVolumeGain property was not specified, but VolumeControl is not none");
spa_log_error(backend->log, NAME": RxVolumeGain property was not specified, but VolumeControl is not none");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "RxVolumeGain property was not specified, but VolumeControl is not none");
goto fail;
}
@ -649,7 +651,7 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
if (tx_volume_control != HSPHFPD_VOLUME_CONTROL_NONE) {
if (tx_volume_gain == (uint16_t)-1) {
close(fd);
spa_log_error(backend->log, "TxVolumeGain property was not specified, but VolumeControl is not none");
spa_log_error(backend->log, NAME": TxVolumeGain property was not specified, but VolumeControl is not none");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "TxVolumeGain property was not specified, but VolumeControl is not none");
goto fail;
}
@ -659,7 +661,7 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
if (!mtu) {
close(fd);
spa_log_error(backend->log, "MTU property was not specified");
spa_log_error(backend->log, NAME": MTU property was not specified");
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "MTU property was not specified");
goto fail;
}
@ -667,14 +669,14 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
endpoint = endpoint_find(backend, endpoint_path);
if (!endpoint) {
close(fd);
spa_log_error(backend->log, "Endpoint %s does not exist", endpoint_path);
spa_log_error(backend->log, NAME": Endpoint %s does not exist", endpoint_path);
r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Endpoint %s does not exist", endpoint_path);
goto fail;
}
if (!endpoint->valid) {
close(fd);
spa_log_error(backend->log, "Endpoint %s is not valid", endpoint_path);
spa_log_error(backend->log, NAME": Endpoint %s is not valid", endpoint_path);
r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Endpoint %s is not valid", endpoint_path);
goto fail;
}
@ -682,17 +684,17 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
transport = spa_bt_transport_find(backend->monitor, endpoint_path);
if (!transport) {
close(fd);
spa_log_error(backend->log, "Endpoint %s is not connected", endpoint_path);
spa_log_error(backend->log, NAME": Endpoint %s is not connected", endpoint_path);
r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Endpoint %s is not connected", endpoint_path);
goto fail;
}
if (transport->codec != codec)
spa_log_warn(backend->log, "Expecting codec to be %d, got %d", transport->codec, codec);
spa_log_warn(backend->log, NAME": Expecting codec to be %d, got %d", transport->codec, codec);
if (transport->fd >= 0) {
close(fd);
spa_log_error(backend->log, "Endpoint %s has already active transport", endpoint_path);
spa_log_error(backend->log, NAME": Endpoint %s has already active transport", endpoint_path);
r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Endpoint %s has already active transport", endpoint_path);
goto fail;
}
@ -757,7 +759,7 @@ static DBusHandlerResult audio_agent_endpoint_handler(DBusConnection *c, DBusMes
interface = dbus_message_get_interface(m);
member = dbus_message_get_member(m);
spa_log_debug(backend->log, "dbus: path=%s, interface=%s, member=%s", path, interface, member);
spa_log_debug(backend->log, NAME": dbus: path=%s, interface=%s, member=%s", path, interface, member);
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
const char *xml = AUDIO_AGENT_ENDPOINT_INTROSPECT_XML;
@ -822,7 +824,7 @@ static DBusHandlerResult application_object_manager_handler(DBusConnection *c, D
interface = dbus_message_get_interface(m);
member = dbus_message_get_member(m);
spa_log_debug(backend->log, "dbus: path=%s, interface=%s, member=%s", path, interface, member);
spa_log_debug(backend->log, NAME": dbus: path=%s, interface=%s, member=%s", path, interface, member);
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
const char *xml = APPLICATION_OBJECT_MANAGER_INTROSPECT_XML;
@ -873,18 +875,18 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat
return;
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
spa_log_error(backend->log, "RegisterApplication() failed: %s",
spa_log_error(backend->log, NAME": RegisterApplication() failed: %s",
dbus_message_get_error_name(r));
goto finish;
}
if (strcmp(dbus_message_get_sender(r), backend->hsphfpd_service_id) != 0) {
spa_log_error(backend->log, "Reply for " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() from invalid sender");
spa_log_error(backend->log, NAME": Reply for " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() from invalid sender");
goto finish;
}
if (strcmp(dbus_message_get_signature(r), "oso") != 0) {
spa_log_error(backend->log, "Invalid reply signature for " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio()");
spa_log_error(backend->log, NAME": Invalid reply signature for " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio()");
goto finish;
}
@ -893,7 +895,7 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat
DBUS_TYPE_STRING, &service_id,
DBUS_TYPE_OBJECT_PATH, &agent_path,
DBUS_TYPE_INVALID) == FALSE) {
spa_log_error(backend->log, "Failed to parse " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() reply: %s", error.message);
spa_log_error(backend->log, NAME": Failed to parse " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() reply: %s", error.message);
goto finish;
}
@ -902,7 +904,7 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat
goto finish;
}
spa_log_debug(backend->log, "hsphfpd audio acquired");
spa_log_debug(backend->log, NAME": hsphfpd audio acquired");
finish:
dbus_message_unref(r);
@ -958,11 +960,11 @@ static int hsphfpd_audio_release(void *data)
struct hsphfpd_transport_data *transport_data = transport->user_data;
if (transport->fd < 0) {
spa_log_info(backend->log, "transport %s already released", transport->path);
spa_log_info(backend->log, NAME": transport %s already released", transport->path);
return 0;
}
spa_log_debug(backend->log, "transport %p: Release %s",
spa_log_debug(backend->log, NAME": transport %p: Release %s",
transport, transport->path);
/* shutdown to make sure connection is dropped immediately */
@ -1023,24 +1025,24 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
endpoint->local_address = strdup(value);
else if (strcmp(key, "Profile") == 0) {
if (endpoint->profile)
spa_log_warn(backend->log, "Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
else if (strcmp(value, "headset") == 0)
endpoint->profile = HSPHFPD_PROFILE_HEADSET;
else if (strcmp(value, "handsfree") == 0)
endpoint->profile = HSPHFPD_PROFILE_HANDSFREE;
else
spa_log_warn(backend->log, "Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
} else if (strcmp(key, "Role") == 0) {
if (endpoint->role)
spa_log_warn(backend->log, "Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
else if (strcmp(value, "client") == 0)
endpoint->role = HSPHFPD_ROLE_CLIENT;
else if (strcmp(value, "gateway") == 0)
endpoint->role = HSPHFPD_ROLE_GATEWAY;
else
spa_log_warn(backend->log, "Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
}
spa_log_trace(backend->log, " %s: %s (%p)", key, value, endpoint);
spa_log_trace(backend->log, NAME": %s: %s (%p)", key, value, endpoint);
}
break;
@ -1050,7 +1052,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
dbus_message_iter_get_basic(&value_i, &value);
if (strcmp(key, "Connected") == 0)
endpoint->connected = value;
spa_log_trace(backend->log, " %s: %d", key, value);
spa_log_trace(backend->log, NAME": %s: %d", key, value);
}
break;
@ -1083,7 +1085,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
d = spa_bt_device_find_by_address(backend->monitor, endpoint->remote_address, endpoint->local_address);
if (!d) {
spa_log_debug(backend->log, "No device for %s", endpoint->path);
spa_log_debug(backend->log, NAME": No device for %s", endpoint->path);
return DBUS_HANDLER_RESULT_HANDLED;
}
@ -1093,9 +1095,9 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
if (!endpoint->connected || (backend->msbc_supported && (endpoint->air_codecs & HFP_AUDIO_CODEC_MSBC) && t->codec == HFP_AUDIO_CODEC_CVSD)) {
spa_bt_transport_free(t);
spa_bt_device_check_profiles(d, false);
spa_log_debug(backend->log, "Transport released for %s", endpoint->path);
spa_log_debug(backend->log, NAME": Transport released for %s", endpoint->path);
} else {
spa_log_debug(backend->log, "Transport already configured for %s", endpoint->path);
spa_log_debug(backend->log, NAME": Transport already configured for %s", endpoint->path);
return DBUS_HANDLER_RESULT_HANDLED;
}
}
@ -1106,7 +1108,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
char *t_path = strdup(endpoint->path);
t = spa_bt_transport_create(backend->monitor, t_path, sizeof(struct hsphfpd_transport_data));
if (t == NULL) {
spa_log_warn(backend->log, "can't create transport: %m");
spa_log_warn(backend->log, NAME": can't create transport: %m");
free(t_path);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
@ -1134,7 +1136,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend
spa_bt_device_connect_profile(t->device, t->profile);
spa_log_debug(backend->log, "Transport %s available for hsphfpd", endpoint->path);
spa_log_debug(backend->log, NAME": Transport %s available for hsphfpd", endpoint->path);
return DBUS_HANDLER_RESULT_HANDLED;
}
@ -1167,11 +1169,11 @@ static DBusHandlerResult hsphfpd_parse_interfaces(struct spa_bt_backend *backend
endpoint = calloc(1, sizeof(struct hsphfpd_endpoint));
endpoint->path = strdup(path);
spa_list_append(&backend->endpoint_list, &endpoint->link);
spa_log_debug(backend->log, "Found endpoint %s", path);
spa_log_debug(backend->log, NAME": Found endpoint %s", path);
}
hsphfpd_parse_endpoint_properties(backend, endpoint, &iface_i);
} else
spa_log_debug(backend->log, "Unknown interface %s found, skipping", interface);
spa_log_debug(backend->log, NAME": Unknown interface %s found, skipping", interface);
dbus_message_iter_next(&element_i);
}
@ -1190,18 +1192,18 @@ static void hsphfpd_get_endpoints_reply(DBusPendingCall *pending, void *user_dat
return;
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
spa_log_error(backend->log, "Failed to get a list of endpoints from hsphfpd: %s",
spa_log_error(backend->log, NAME": Failed to get a list of endpoints from hsphfpd: %s",
dbus_message_get_error_name(r));
goto finish;
}
if (strcmp(dbus_message_get_sender(r), backend->hsphfpd_service_id) != 0) {
spa_log_error(backend->log, "Reply for GetManagedObjects() from invalid sender");
spa_log_error(backend->log, NAME": Reply for GetManagedObjects() from invalid sender");
goto finish;
}
if (!dbus_message_iter_init(r, &i) || strcmp(dbus_message_get_signature(r), "a{oa{sa{sv}}}") != 0) {
spa_log_error(backend->log, "Invalid arguments in GetManagedObjects() reply");
spa_log_error(backend->log, NAME": Invalid arguments in GetManagedObjects() reply");
goto finish;
}
@ -1233,14 +1235,14 @@ static void hsphfpd_register_application_reply(DBusPendingCall *pending, void *u
return;
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
spa_log_error(backend->log, "RegisterApplication() failed: %s",
spa_log_error(backend->log, NAME": RegisterApplication() failed: %s",
dbus_message_get_error_name(r));
goto finish;
}
backend->hsphfpd_service_id = strdup(dbus_message_get_sender(r));
spa_log_debug(backend->log, "Registered to hsphfpd");
spa_log_debug(backend->log, NAME": Registered to hsphfpd");
m = dbus_message_new_method_call(HSPHFPD_SERVICE, "/",
DBUS_INTERFACE_OBJECTMANAGER, "GetManagedObjects");
@ -1262,7 +1264,7 @@ static int hsphfpd_register_application(struct spa_bt_backend *backend)
const char *path = APPLICATION_OBJECT_MANAGER_PATH;
DBusPendingCall *call;
spa_log_debug(backend->log, "Registering to hsphfpd");
spa_log_debug(backend->log, NAME": Registering to hsphfpd");
m = dbus_message_new_method_call(HSPHFPD_SERVICE, "/",
HSPHFPD_APPLICATION_MANAGER_INTERFACE, "RegisterApplication");
@ -1297,7 +1299,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
DBUS_TYPE_STRING, &old_owner,
DBUS_TYPE_STRING, &new_owner,
DBUS_TYPE_INVALID)) {
spa_log_error(backend->log, "Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
spa_log_error(backend->log, NAME": Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
goto finish;
}
@ -1305,7 +1307,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
if (old_owner && *old_owner) {
struct hsphfpd_endpoint *endpoint;
spa_log_debug(backend->log, "hsphfpd disappeared");
spa_log_debug(backend->log, NAME": hsphfpd disappeared");
if (backend->hsphfpd_service_id) {
free(backend->hsphfpd_service_id);
backend->hsphfpd_service_id = NULL;
@ -1316,24 +1318,24 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
}
if (new_owner && *new_owner) {
spa_log_debug(backend->log, "hsphfpd appeared");
spa_log_debug(backend->log, NAME": hsphfpd appeared");
hsphfpd_register_application(backend);
}
} else {
spa_log_debug(backend->log, "Name owner changed %s", dbus_message_get_path(m));
spa_log_debug(backend->log, NAME": Name owner changed %s", dbus_message_get_path(m));
}
}
} else if (backend->hsphfpd_service_id && strcmp(sender, backend->hsphfpd_service_id) == 0) {
if (dbus_message_is_signal(m, DBUS_INTERFACE_OBJECTMANAGER, "InterfacesAdded")) {
DBusMessageIter arg_i;
spa_log_warn(backend->log, "sender: %s", dbus_message_get_sender(m));
spa_log_warn(backend->log, NAME": sender: %s", dbus_message_get_sender(m));
if (!backend->endpoints_listed)
goto finish;
if (!dbus_message_iter_init(m, &arg_i) || strcmp(dbus_message_get_signature(m), "oa{sa{sv}}") != 0) {
spa_log_error(backend->log, "Invalid signature found in InterfacesAdded");
spa_log_error(backend->log, NAME": Invalid signature found in InterfacesAdded");
goto finish;
}
@ -1346,7 +1348,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
goto finish;
if (!dbus_message_iter_init(m, &arg_i) || strcmp(dbus_message_get_signature(m), "oas") != 0) {
spa_log_error(backend->log, "Invalid signature found in InterfacesRemoved");
spa_log_error(backend->log, NAME": Invalid signature found in InterfacesRemoved");
goto finish;
}
@ -1366,7 +1368,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
if (transport)
spa_bt_transport_free(transport);
spa_log_debug(backend->log, "Remove endpoint %s", path);
spa_log_debug(backend->log, NAME": Remove endpoint %s", path);
endpoint = endpoint_find(backend, path);
if (endpoint)
endpoint_free(endpoint);
@ -1383,7 +1385,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
goto finish;
if (!dbus_message_iter_init(m, &arg_i) || strcmp(dbus_message_get_signature(m), "sa{sv}as") != 0) {
spa_log_error(backend->log, "Invalid signature found in PropertiesChanged");
spa_log_error(backend->log, NAME": Invalid signature found in PropertiesChanged");
goto finish;
}
@ -1395,20 +1397,20 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
if (strcmp(iface, HSPHFPD_ENDPOINT_INTERFACE) == 0) {
struct hsphfpd_endpoint *endpoint = endpoint_find(backend, path);
if (!endpoint) {
spa_log_warn(backend->log, "Properties changed on unknown endpoint %s", path);
spa_log_warn(backend->log, NAME": Properties changed on unknown endpoint %s", path);
goto finish;
}
spa_log_debug(backend->log, "Properties changed on endpoint %s", path);
spa_log_debug(backend->log, NAME": Properties changed on endpoint %s", path);
hsphfpd_parse_endpoint_properties(backend, endpoint, &arg_i);
} else if (strcmp(iface, HSPHFPD_AUDIO_TRANSPORT_INTERFACE) == 0) {
struct spa_bt_transport *transport = spa_bt_transport_find_full(backend->monitor,
hsphfpd_cmp_transport_path,
(const void *)path);
if (!transport) {
spa_log_warn(backend->log, "Properties changed on unknown transport %s", path);
spa_log_warn(backend->log, NAME": Properties changed on unknown transport %s", path);
goto finish;
}
spa_log_debug(backend->log, "Properties changed on transport %s", path);
spa_log_debug(backend->log, NAME": Properties changed on transport %s", path);
hsphfpd_parse_transport_properties(backend, transport, &arg_i);
}
}
@ -1428,7 +1430,7 @@ void backend_hsphfpd_add_filters(struct spa_bt_backend *backend)
dbus_error_init(&err);
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, NAME": failed to add filter function");
goto fail;
}