summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2012-08-31 12:51:06 +0200
committerJaska Uimonen <jaska.uimonen@intel.com>2013-01-24 09:29:36 +0200
commit2f812240d6f1712fa52c3258d98721a433f5603a (patch)
treeea13ea4f0405e4bfb22605c6fd4ce5b5a995bf6f
parent35629b3abcd78ce335fa9827224a08941252e53b (diff)
downloadpulseaudio-panda-2f812240d6f1712fa52c3258d98721a433f5603a.tar.gz
pulseaudio-panda-2f812240d6f1712fa52c3258d98721a433f5603a.tar.bz2
pulseaudio-panda-2f812240d6f1712fa52c3258d98721a433f5603a.zip
bluetooth: Acquire transport when becomes available
Try to acquire the transport as soon as the audio stream is started, along with the availability flag update.
-rw-r--r--src/modules/bluetooth/module-bluetooth-device.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 100d9341..6d1768d4 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1242,6 +1242,7 @@ static pa_port_available_t audio_state_to_availability(pa_bt_audio_state_t state
static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *userdata) {
DBusError err;
struct userdata *u;
+ bool acquire = FALSE;
pa_assert(bus);
pa_assert(m);
@@ -1318,6 +1319,8 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
pa_assert_se(port = pa_hashmap_get(u->card->ports, "hfgw-input"));
pa_device_port_set_available(port, available);
+
+ acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HFGW);
}
} else if (dbus_message_is_signal(m, "org.bluez.Headset", "PropertyChanged")) {
pa_bt_audio_state_t state = parse_state_property_change(m);
@@ -1331,6 +1334,8 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-input"));
pa_device_port_set_available(port, available);
+
+ acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HSP);
}
} else if (dbus_message_is_signal(m, "org.bluez.AudioSource", "PropertyChanged")) {
pa_bt_audio_state_t state = parse_state_property_change(m);
@@ -1341,6 +1346,8 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
pa_assert_se(port = pa_hashmap_get(u->card->ports, "a2dp-input"));
pa_device_port_set_available(port, available);
+
+ acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP_SOURCE);
}
} else if (dbus_message_is_signal(m, "org.bluez.AudioSink", "PropertyChanged")) {
pa_bt_audio_state_t state = parse_state_property_change(m);
@@ -1351,9 +1358,20 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
pa_assert_se(port = pa_hashmap_get(u->card->ports, "a2dp-output"));
pa_device_port_set_available(port, available);
+
+ acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP);
}
}
+ if (acquire)
+ if (bt_transport_acquire(u, FALSE) >= 0) {
+ if (u->source)
+ pa_source_suspend(u->source, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
+
+ if (u->sink)
+ pa_sink_suspend(u->sink, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
+ }
+
fail:
dbus_error_free(&err);