mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
bluez5: require adapter before profile connect & after
All exposed bluez devices should have an adapter specified at all times. Adapter-less devices appear in some race conditions in BlueZ interface. Require device has non-null adapter, in all cases before adding any profiles (which exposes the device), and reject BlueZ profile connection attempts in that state. If an adapter gets removed by BlueZ, remove also all its devices, so that device->adapter pointers stay valid.
This commit is contained in:
parent
870cd0136a
commit
f2630ed6fc
4 changed files with 14 additions and 5 deletions
|
|
@ -1088,7 +1088,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
|
|||
}
|
||||
|
||||
d = spa_bt_device_find_by_address(backend->monitor, endpoint->remote_address, endpoint->local_address);
|
||||
if (!d) {
|
||||
if (!d || !d->adapter) {
|
||||
spa_log_debug(backend->log, "No device for %s", endpoint->path);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1729,7 +1729,7 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
|
|||
dbus_message_iter_get_basic(&it[0], &path);
|
||||
|
||||
d = spa_bt_device_find(backend->monitor, path);
|
||||
if (d == NULL) {
|
||||
if (d == NULL || d->adapter == NULL) {
|
||||
spa_log_warn(backend->log, "unknown device for path %s", path);
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
|
@ -1856,7 +1856,7 @@ static DBusHandlerResult profile_request_disconnection(DBusConnection *conn, DBu
|
|||
dbus_message_iter_get_basic(&it[0], &path);
|
||||
|
||||
d = spa_bt_device_find(backend->monitor, path);
|
||||
if (d == NULL) {
|
||||
if (d == NULL || d->adapter == NULL) {
|
||||
spa_log_warn(backend->log, "unknown device for path %s", path);
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ static DBusHandlerResult ofono_audio_card_found(struct impl *backend, char *path
|
|||
}
|
||||
|
||||
d = spa_bt_device_find_by_address(backend->monitor, remote_address, local_address);
|
||||
if (!d) {
|
||||
if (!d || !d->adapter) {
|
||||
spa_log_error(backend->log, "Device doesn’t exist for %s", path);
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -785,11 +785,20 @@ static struct spa_bt_adapter *adapter_create(struct spa_bt_monitor *monitor, con
|
|||
return d;
|
||||
}
|
||||
|
||||
static void device_free(struct spa_bt_device *device);
|
||||
|
||||
static void adapter_free(struct spa_bt_adapter *adapter)
|
||||
{
|
||||
struct spa_bt_monitor *monitor = adapter->monitor;
|
||||
struct spa_bt_device *d, *td;
|
||||
|
||||
spa_log_debug(monitor->log, "%p", adapter);
|
||||
|
||||
/* Devices should be destroyed before their assigned adapter */
|
||||
spa_list_for_each_safe(d, td, &monitor->device_list, link)
|
||||
if (d->adapter == adapter)
|
||||
device_free(d);
|
||||
|
||||
spa_bt_player_destroy(adapter->dummy_player);
|
||||
|
||||
spa_list_remove(&adapter->link);
|
||||
|
|
@ -2952,7 +2961,7 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn,
|
|||
transport->a2dp_codec = codec;
|
||||
transport_update_props(transport, &it[1], NULL);
|
||||
|
||||
if (transport->device == NULL) {
|
||||
if (transport->device == NULL || transport->device->adapter == NULL) {
|
||||
spa_log_warn(monitor->log, "no device found for transport");
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue