bluez5: keepalive A2DP source / SCO AG dynamic node transports

When acting as SCO AG / A2DP sink, the remote end should decide when to
close the connection.  This does not work currently properly, because
stopping sources/sinks releases the transport, which causes it to go
idle, and which then destroys dynamic nodes.  The sources/sinks should
not cause the transport to be released.

Implement keepalive flag for spa_bt_transport, such that
spa_bt_transport_release does not actually release the transport when
the refcount reaches zero. Set the flag for dynamic nodes when the
transport becomes pending (remote end connects) and unset the flag when
idle (remote end disconnected, or dynamic node removed).
This commit is contained in:
Pauli Virtanen 2022-01-31 00:08:26 +02:00
parent 24c97b1c7e
commit 4bb3ff739a
3 changed files with 52 additions and 6 deletions

View file

@ -519,11 +519,13 @@ static void dynamic_node_transport_state_changed(void *data,
if (state >= SPA_BT_TRANSPORT_STATE_PENDING && old < SPA_BT_TRANSPORT_STATE_PENDING) {
if (!SPA_FLAG_IS_SET(this->id, DYNAMIC_NODE_ID_FLAG)) {
SPA_FLAG_SET(this->id, DYNAMIC_NODE_ID_FLAG);
spa_bt_transport_keepalive(t, true);
emit_node(impl, t, this->id, this->factory_name, this->a2dp_duplex);
}
} else if (state < SPA_BT_TRANSPORT_STATE_PENDING && old >= SPA_BT_TRANSPORT_STATE_PENDING) {
if (SPA_FLAG_IS_SET(this->id, DYNAMIC_NODE_ID_FLAG)) {
SPA_FLAG_CLEAR(this->id, DYNAMIC_NODE_ID_FLAG);
spa_bt_transport_keepalive(t, false);
spa_device_emit_object_info(&impl->hooks, this->id, NULL);
}
}