summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2013-02-14 14:03:21 +0100
committerTanu Kaskinen <tanuk@iki.fi>2013-02-16 16:53:42 +0200
commit5d4b7c4a89652d70a924d1c6091398c5b2d84bd3 (patch)
tree29032bbb5c284010322dacedaad60eef499b5b8c
parent2c666e3e166b2992f114325e3ec53f28f98738df (diff)
bluetooth: Fix premature acquire attempts
A transport should be considered connected only after the connection procedure is complete, as expressed in audio_state_to_transport_state(). module-bluetooth-device should be loaded only after at least one transport is not only created (during configuration), but also connected. This fixes the issue of premature acquire attempts sometimes experienced when a headset is connected (issue not present in v3.0 though).
-rw-r--r--src/modules/bluetooth/bluetooth-util.c2
-rw-r--r--src/modules/bluetooth/module-bluetooth-device.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 7a9f7e9fe..33fa6898a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1101,7 +1101,7 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
return false;
for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
- if (d->transports[i])
+ if (d->transports[i] && d->transports[i]->state != PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
return true;
return false;
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index f6f6da616..25a21821e 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1888,7 +1888,7 @@ static int setup_transport(struct userdata *u) {
/* check if profile has a transport */
t = u->device->transports[u->profile];
- if (t == NULL) {
+ if (!t || t->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
pa_log_warn("Profile has no transport");
return -1;
}
@@ -2085,7 +2085,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
if (*d != PROFILE_OFF) {
const pa_bluetooth_device *device = u->device;
- if (!device->transports[*d]) {
+ if (!device->transports[*d] || device->transports[*d]->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
pa_log_warn("Profile not connected, refused to switch profile to %s", new_profile->name);
return -PA_ERR_IO;
}
@@ -2348,7 +2348,8 @@ static int add_card(struct userdata *u) {
d = PA_CARD_PROFILE_DATA(u->card->active_profile);
- if (*d != PROFILE_OFF && !device->transports[*d]) {
+ if (*d != PROFILE_OFF && (!device->transports[*d] ||
+ device->transports[*d]->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)) {
pa_log_warn("Default profile not connected, selecting off profile");
u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
u->card->save_profile = false;