]> code.delx.au - pulseaudio/commitdiff
bluetooth: Fix missing state checks for a2dp_source
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Thu, 16 Aug 2012 11:08:29 +0000 (13:08 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Tue, 21 Aug 2012 16:50:29 +0000 (19:50 +0300)
Profile a2dp_source, just like any other card profile, should have
state guards when the profile is being changed. If the BlueZ interface
is not connected, the profile should be set to "off".

src/modules/bluetooth/module-bluetooth-device.c

index 60881fc5f50a0ed168df82fcb8cac9a5bf873c4e..5ef54870491a115706210fea7bfbbfd49be55e33 100644 (file)
@@ -1969,7 +1969,10 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
         pa_log_warn("HSP is not connected, refused to switch profile");
         return -PA_ERR_IO;
     } else if (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) {
-        pa_log_warn("A2DP is not connected, refused to switch profile");
+        pa_log_warn("A2DP Sink is not connected, refused to switch profile");
+        return -PA_ERR_IO;
+    } else if (device->audio_source_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP_SOURCE) {
+        pa_log_warn("A2DP Source is not connected, refused to switch profile");
         return -PA_ERR_IO;
     } else if (device->hfgw_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW) {
         pa_log_warn("HandsfreeGateway is not connected, refused to switch profile");
@@ -2225,6 +2228,7 @@ static int add_card(struct userdata *u, const pa_bluetooth_device *device) {
 
     if ((device->headset_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) ||
         (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) ||
+        (device->audio_source_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP_SOURCE) ||
         (device->hfgw_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW)) {
         pa_log_warn("Default profile not connected, selecting off profile");
         u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");