[pulseaudio-discuss] [PATCHv2 29/60] bluetooth: Check if any transport is connected
jprvita at gmail.com
jprvita at gmail.com
Mon Aug 12 21:54:07 PDT 2013
From: João Paulo Rechi Vita <jprvita at openbossa.org>
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 eec16c9..9687997 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -200,6 +200,21 @@ static void bluez5_transport_release_cb(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->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* device_create(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 c3f2f2f..895e2f1 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -88,6 +88,8 @@ pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const
void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
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 *remote, const char *local);
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list