}
check_req_info:
- req_info = _bt_get_request_info(func_data->req_id);
- if (req_info == NULL) {
- BT_ERR("req_info == NULL");
- goto done;
- }
-
if (g_error == NULL)
goto dbus_return;
/* Event will be sent by the event reciever */
dbus_return:
- if (req_info->context == NULL) {
- BT_DBG("req_info->context is NULL");
+ req_info = _bt_get_request_info(func_data->req_id);
+ if (req_info == NULL) {
+ BT_ERR("req_info == NULL");
+ goto done;
+ } else if (req_info->context == NULL) {
+ BT_ERR("req_info->context is NULL");
goto done;
}
node = g_list_next(node);
}
- if (!connected)
+ if (!connected) {
+ __bt_free_wait_data();
return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
BT_DBG("connected headset %s", connected_address);
goto fail;
}
BT_INFO("Connecting to service %s", uuid);
+ /* First Check if device is in connecting state if it than return error */
+ value = __bt_is_headset_connecting(type);
+ if (value != BLUETOOTH_ERROR_NONE) {
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ goto fail;
+ }
value = __bt_is_headset_connected(type, request_id, address);
result = BLUETOOTH_ERROR_ALREADY_CONNECT;
goto fail;
} else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
- value = __bt_is_headset_connecting(type);
- if (value != BLUETOOTH_ERROR_NONE) {
- result = BLUETOOTH_ERROR_IN_PROGRESS;
- goto fail;
- }
_bt_headset_set_local_connection(TRUE);
ret = _bt_connect_profile(address, uuid,
__bt_audio_request_cb, func_data);
vconf_set_str(BT_LAST_CONNECTED_DEVICE, address);
}
#endif /*TIZEN_BT_A2DP_SINK_AUTO_CONNECT */
+
+int _bt_audio_select_role(bluetooth_audio_role_t role)
+{
+
+ GDBusProxy *proxy;
+ GVariant *ret;
+ GError *error = NULL;
+ GDBusConnection *g_conn = _bt_gdbus_get_system_gconn();
+ gchar *adapter_path = _bt_get_adapter_path();
+
+ BT_INFO("_bt_audio_select_role called [%d]", role);
+
+ retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+ BT_INFO("Adapter Path = %s", adapter_path);
+
+ proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_BLUEZ_NAME, adapter_path, BT_MEDIA_INTERFACE, NULL, &error);
+
+ g_free(adapter_path);
+
+ if (proxy == NULL) {
+ BT_ERR("Unable to create proxy");
+
+ if (error) {
+ BT_ERR("Error: %s", error->message);
+ g_clear_error(&error);
+ }
+
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ if (role == BLUETOOTH_A2DP_SOURCE)
+ ret = g_dbus_proxy_call_sync(proxy, "SelectRole", g_variant_new("(s)", "source"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ else
+ ret = g_dbus_proxy_call_sync(proxy, "SelectRole", g_variant_new("(s)", "sink"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+ g_object_unref(proxy);
+
+ if (ret == NULL) {
+ BT_ERR("Call SelectRole Failed");
+ if (error) {
+ BT_ERR("errCode[%x], message[%s]", error->code, error->message);
+ g_clear_error(&error);
+ }
+
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_variant_unref(ret);
+ return BLUETOOTH_ERROR_NONE;
+}