mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
bluez5: refcount transport acquire and release, let it manage fd
Backends don't necessarily allow for opening the same device multiple times, and it shouldn't be necessary. Since source and sink are not necessarily both running at the same time, refcount the transport acquire/release so that it knows to close the fd only when no source/sink is running. Let the transport manage the fd lifecycle, also closing it once it is not needed. Don't return the fd from acquire(), since each transport is associated with a single socket fd.
This commit is contained in:
parent
8942f6b402
commit
036c10717d
7 changed files with 85 additions and 51 deletions
|
|
@ -284,7 +284,7 @@ struct spa_bt_transport {
|
|||
void *configuration;
|
||||
int configuration_len;
|
||||
|
||||
bool acquired;
|
||||
int acquire_refcount;
|
||||
int fd;
|
||||
uint16_t read_mtu;
|
||||
uint16_t write_mtu;
|
||||
|
|
@ -302,6 +302,9 @@ struct spa_bt_transport *spa_bt_transport_find_full(struct spa_bt_monitor *monit
|
|||
bool (*callback) (struct spa_bt_transport *t, const void *data),
|
||||
const void *data);
|
||||
|
||||
int spa_bt_transport_acquire(struct spa_bt_transport *t, bool optional);
|
||||
int spa_bt_transport_release(struct spa_bt_transport *t);
|
||||
|
||||
#define spa_bt_transport_emit(t,m,v,...) spa_hook_list_call(&(t)->listener_list, \
|
||||
struct spa_bt_transport_events, \
|
||||
m, v, ##__VA_ARGS__)
|
||||
|
|
@ -323,8 +326,6 @@ struct spa_bt_transport *spa_bt_transport_find_full(struct spa_bt_monitor *monit
|
|||
res; \
|
||||
})
|
||||
|
||||
#define spa_bt_transport_acquire(t,o) spa_bt_transport_impl(t, acquire, 0, o)
|
||||
#define spa_bt_transport_release(t) spa_bt_transport_impl(t, release, 0)
|
||||
#define spa_bt_transport_destroy(t) spa_bt_transport_impl(t, destroy, 0)
|
||||
|
||||
static inline enum spa_bt_transport_state spa_bt_transport_state_from_string(const char *value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue