X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-service-adaptation%2Fservices%2Faudio%2Fbt-service-audio.c;h=49a59c37a72616a9af0bc3e0b11be87a33a3c88c;hb=refs%2Fchanges%2F37%2F230237%2F1;hp=6d5922e4a98c3a48dc0439ed6541894ca18cbb1e;hpb=965b019b6e7ee4ad9d90602185b267a3ecb1b674;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-service-adaptation/services/audio/bt-service-audio.c b/bt-service-adaptation/services/audio/bt-service-audio.c index 6d5922e..49a59c3 100644 --- a/bt-service-adaptation/services/audio/bt-service-audio.c +++ b/bt-service-adaptation/services/audio/bt-service-audio.c @@ -40,6 +40,8 @@ #include "bt-service-avrcp-tg.h" #include "bt-service-avrcp-ctrl.h" #include "bt-service-hf.h" +#include "bt-service-hf-client.h" +#include "oal-hf-client.h" #ifdef TIZEN_SUPPORT_DUAL_HF #define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac" @@ -179,6 +181,25 @@ gboolean _bt_is_headset_type_connected(int type, char *address) return FALSE; } + +gboolean _bt_is_headset_address_type_connected(int type, const char *address) +{ + GList *node; + + node = g_list_first(g_connected_list); + while (node != NULL) { + bt_connected_headset_data_t *connected_device = node->data; + + if (connected_device && (connected_device->type & type)) { + if (memcmp(connected_device->device_address, address, 19) == 0) + return TRUE; + } + + node = g_list_next(node); + } + return FALSE; +} + static void __bt_set_headset_disconnection_type(const char *address) { bt_connected_headset_data_t *connected_device; @@ -397,6 +418,8 @@ static int __bt_process_audio_profile_connect(bt_audio_type_t type, bluetooth_de case BT_AUDIO_A2DP_SOURCE: return _bt_a2dp_connect_remote_source(address); break; + case BT_AUDIO_AG: + return _bt_connect_remote_ag(address); default: BT_ERR("Unknown role"); return BLUETOOTH_ERROR_INTERNAL; @@ -406,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); } @@ -462,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); } @@ -498,7 +523,14 @@ int _bt_audio_initialize(bt_service_module_t module) break; } case BT_HFP_MODULE: { - return BLUETOOTH_ERROR_NOT_SUPPORT; + status = hf_client_enable(); + if (OAL_STATUS_SUCCESS != status) { + BT_ERR("Failed to initialize Bluetooth HFP client Profile, status: %d", status); + return BLUETOOTH_ERROR_INTERNAL; + } + /* Register Audio module event handler */ + _bt_service_register_event_handler_callback(module, _bt_hf_client_event_handler); + break; } case BT_AG_MODULE: { status = hfp_enable(1); @@ -816,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)) { @@ -832,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("-"); @@ -1087,8 +1128,9 @@ static void __handle_pending_requests(int result, int service_function, void *us BT_DBG("+"); /* Get method invocation context */ - for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) { + for (l = _bt_get_invocation_list(); l != NULL; ) { req_info = l->data; + l = g_slist_next(l); if (req_info == NULL || req_info->service_function != service_function) continue; @@ -1243,3 +1285,31 @@ void _bt_audio_set_current_role(bluetooth_audio_role_t role) BT_INFO("role: %s", (role == BLUETOOTH_A2DP_SINK) ? "AUDIO_SINK" : "AUDIO_SOURCE"); curr_audio_role = role; } + +int _bt_hf_connect(bluetooth_device_address_t *device_address) +{ + int result = BLUETOOTH_ERROR_NONE; + BT_INFO("+"); + + 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; +} + +int _bt_hf_disconnect(bluetooth_device_address_t *device_address) +{ + int result = BLUETOOTH_ERROR_NONE; + BT_INFO("+"); + + 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; +}