Fix : connection replace failure
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / audio / bt-service-audio.c
index ef7aac7..49a59c3 100644 (file)
@@ -429,6 +429,7 @@ static int __bt_process_audio_profile_connect(bt_audio_type_t type, bluetooth_de
                //_bt_headset_set_local_connection(TRUE);
                /* Add data to the connected list */
                _bt_add_headset_to_list(type, BT_STATE_CONNECTING, addr);
+               BT_PERMANENT_LOG("Connect %d", type);
        } else {
                BT_ERR("Profile [%d] connect failed!!", type);
        }
@@ -485,6 +486,7 @@ static int __bt_process_audio_profile_disconnect(bt_audio_type_t type, bluetooth
 
                /* Update device status in connected list */
                _bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, addr);
+               BT_PERMANENT_LOG("Disconnect %d", type);
        } else {
                BT_ERR("Profile [%d] connect failed!!", type);
        }
@@ -846,6 +848,7 @@ int __bt_handle_audio_all_connect(bt_pending_audio_conn_t *info)
                        goto fail;
                }
 
+               BT_PERMANENT_LOG("Connect %d", info->type);
                /* If multiple profiles are supported, queue pending connection info */
                if ((info->is_hfp_supported && info->is_a2dp_sink_supported) ||
                                (info->is_hfp_supported && info->is_a2dp_src_supported)) {
@@ -862,12 +865,20 @@ int __bt_handle_audio_all_connect(bt_pending_audio_conn_t *info)
                }
        } else if (ret == BLUETOOTH_ERROR_NONE) {
                BT_INFO("Waiting for disconnection...");
-               /*
-                * It means, we dont need pending connect info as only A2DP (Src/Snk) or
-                * HFP will be connected for present device, so lets free pending info.
-                */
-               g_free(info->address);
-               g_free(info);
+
+               if ((info->is_hfp_supported && info->is_a2dp_sink_supported) ||
+                               (info->is_hfp_supported && info->is_a2dp_src_supported)) {
+                       BT_INFO("[%s] Supports HFP and (A2DP_Src or, A2DP_Snk)", info->address);
+                       pending_audio_conn_list = g_slist_append(pending_audio_conn_list, (gpointer)info);
+               } else {
+                       BT_INFO("[%s] Supports one profile only", info->address);
+                       /*
+                        * It means, we dont need pending connect info as only A2DP (Src/Snk) or
+                        * HFP will be connected for present device, so lets free pending info.
+                        */
+                       g_free(info->address);
+                       g_free(info);
+               }
        }
 
        BT_DBG("-");
@@ -1283,6 +1294,8 @@ int _bt_hf_connect(bluetooth_device_address_t *device_address)
        result = _bt_connect_remote_ag(device_address);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("HF Client connect to remote AG failed");
+       else
+               BT_PERMANENT_LOG("Connect AG");
 
        return result;
 }
@@ -1295,6 +1308,8 @@ int _bt_hf_disconnect(bluetooth_device_address_t *device_address)
        result = _bt_disconnect_remote_ag(device_address);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("HF Client disconnect to remote AG failed");
+       else
+               BT_PERMANENT_LOG("Disconnect AG");
 
        return result;
 }