From: Jo?o Paulo Rechi Vita <jprvita@xxxxxxxxxxxxx> Create a new function pa_bluetooth_device_any_transport_connected() to check if there is any audio connection between the host and a remote device. --- src/modules/bluetooth/bluez5-util.c | 15 +++++++++++++++ src/modules/bluetooth/bluez5-util.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c index ab4f0bd..3e6eb1c 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -186,6 +186,21 @@ static void bluez5_transport_release(pa_bluetooth_transport *t) { pa_log_info("Transport %s released", t->path); } +bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d) { + unsigned i; + + pa_assert(d); + + if (d->dead || d->device_info_valid != 1) + return false; + + for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++) + if (d->transports[i] && d->transports[i]->state != PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) + return true; + + return false; +} + static pa_bluetooth_device* pa_bluetooth_discovery_create_device(pa_bluetooth_discovery *y, const char *path) { pa_bluetooth_device *d; diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h index 82953a7..3075af6 100644 --- a/src/modules/bluetooth/bluez5-util.h +++ b/src/modules/bluetooth/bluez5-util.h @@ -89,6 +89,8 @@ pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const pa_bluetooth_transport_release_cb release, void *userdata); void pa_bluetooth_transport_free(pa_bluetooth_transport *t); +bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d); + pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path); pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *address); -- 1.7.11.7