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

@ -583,6 +583,8 @@ struct spa_bt_transport {
struct spa_bt_transport_volume volumes[SPA_BT_VOLUME_ID_TERM];
int acquire_refcount;
bool acquired;
bool keepalive;
int fd;
uint16_t read_mtu;
uint16_t write_mtu;
@ -612,6 +614,7 @@ bool spa_bt_transport_volume_enabled(struct spa_bt_transport *transport);
int spa_bt_transport_acquire(struct spa_bt_transport *t, bool optional);
int spa_bt_transport_release(struct spa_bt_transport *t);
int spa_bt_transport_keepalive(struct spa_bt_transport *t, bool keepalive);
int spa_bt_transport_ensure_sco_io(struct spa_bt_transport *t, struct spa_loop *data_loop);
#define spa_bt_transport_emit(t,m,v,...) spa_hook_list_call(&(t)->listener_list, \