#define HAL_PROP_DEVICE_IS_ALIAS_SET 0x19
#define HAL_PROP_ADAPTER_LE_DISCOVERY_STARTED 0x1a
#define HAL_PROP_ADAPTER_LE_DISCOVERY_STOPPED 0x1b
+#define HAL_PROP_ADAPTER_A2DP_ROLE 0x1c
struct hal_prop_device_info {
uint8_t version;
DBG("+");
- if (_bt_hal_is_service_enabled(A2DP_SINK_UUID)) {
- ERR("Audio sink role already enabled, return");
- return BT_STATUS_SUCCESS;
- }
-
gconn = _bt_hal_get_system_gconn();
if (!gconn) {
ERR("_bt_hal_get_system_gconn returned NULL, return");
/* Add the exception case for Already Exists */
if (g_strrstr(error->message, "Already Exists")) {
g_clear_error(&error);
- return BT_STATUS_SUCCESS;
+ return BT_STATUS_DONE;
}
g_clear_error(&error);
{
DBG("");
+ int ret = BT_STATUS_SUCCESS;
+
if (interface_ready())
return BT_STATUS_DONE;
- if (BT_STATUS_SUCCESS != _bt_hal_dbus_handler_enable_a2dp_sink()) {
+ ret = _bt_hal_dbus_handler_enable_a2dp_sink();
+
+ if (ret != BT_STATUS_SUCCESS && ret != BT_STATUS_DONE) {
ERR("_bt_hal_dbus_handler_enable_a2dp_sink failed");
return BT_STATUS_FAIL;
}
DBG("+");
- if (_bt_hal_is_service_enabled(A2DP_SOURCE_UUID)) {
- ERR("Audio sink role already enabled, return");
- return BT_STATUS_SUCCESS;
- }
-
gconn = _bt_hal_get_system_gconn();
if (!gconn) {
ERR("_bt_hal_get_system_gconn returned NULL, return");
/* Add the exception case for Already Exists */
if (g_strrstr(error->message, "Already Exists")) {
g_clear_error(&error);
- return BT_STATUS_SUCCESS;
+ return BT_STATUS_DONE;
}
g_clear_error(&error);
{
DBG("");
+ int ret = BT_STATUS_SUCCESS;
+
if (interface_ready())
return BT_STATUS_DONE;
- if (BT_STATUS_SUCCESS != _bt_hal_dbus_handler_enable_a2dp_source()) {
+ ret = _bt_hal_dbus_handler_enable_a2dp_source();
+
+ if (ret != BT_STATUS_SUCCESS && ret != BT_STATUS_DONE) {
ERR("_bt_hal_dbus_handler_enable_a2dp_source failed");
return BT_STATUS_FAIL;
}
const gchar *address = NULL;
gchar *name = NULL;
unsigned int cod = 0;
+ unsigned int a2dp_role = 0;
gboolean discoverable;
gboolean connectable;
unsigned int scan_mode = BT_SCAN_MODE_NONE;
} else if (!g_strcmp0(key, "IpspInitStateChanged")) {
g_variant_get(value, "b" , &ipsp_initialized);
DBG("##IPSP Initialized = %d", ipsp_initialized);
+ } else if (!g_strcmp0(key, "A2dpRole")) {
+ a2dp_role = g_variant_get_uint32(value);
+ DBG("##A2dp Role [%d]", a2dp_role);
+ size += __bt_insert_hal_properties(buf + size,
+ HAL_PROP_ADAPTER_A2DP_ROLE, sizeof(unsigned int), &a2dp_role);
+ ev->num_props++;
} else {
ERR("Unhandled Property:[%s]", key);
}
*/
BT_PROPERTY_ADAPTER_LE_DISCOVERY_STOPPED,
+ /**
+ * Description - A2DP role of media endpoint
+ * Access mode - Only GET.
+ * Data type - uint32_t.
+ */
+ BT_PROPERTY_A2DP_ROLE = 0x1c,
+
BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
} bt_property_type_t;
EVENT(OAL_EVENT_ADAPTER_PROPERTY_NAME) /* char string */\
EVENT(OAL_EVENT_ADAPTER_PROPERTY_VERSION) /* char string */\
EVENT(OAL_EVENT_ADAPTER_PROPERTY_SERVICES) /* event_adapter_services_t */\
+ EVENT(OAL_EVENT_ADAPTER_PROPERTY_A2DP_ROLE) /* uint32_t */\
EVENT(OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE) \
EVENT(OAL_EVENT_ADAPTER_MODE_CONNECTABLE) \
EVENT(OAL_EVENT_ADAPTER_MODE_DISCOVERABLE) \
event_data, (sizeof(event_device_list_t) + num_bonded * sizeof(bt_bdaddr_t)));
break;
}
+ case BT_PROPERTY_A2DP_ROLE: {
+ unsigned int a2dp_role;
+
+ a2dp_role = *((uint32_t*)properties[i].val);
+
+ BT_INFO("A2DP role: %u", a2dp_role);
+
+ send_event(OAL_EVENT_ADAPTER_PROPERTY_A2DP_ROLE,
+ g_memdup(properties[i].val, sizeof(uint32_t)),
+ sizeof(uint32_t));
+ break;
+ }
case BT_PROPERTY_LOCAL_LE_FEATURES: {
event_adapter_le_features_t *le_features;
return BLUETOOTH_ERROR_NONE;
}
-static void __bt_handle_pending_a2dp_init(service_uuid_t *service_list, unsigned int count)
+static void __bt_handle_pending_a2dp_init(unsigned int a2dp_role)
{
int ret;
- unsigned int i;
- unsigned char *uuid;
- char uuid_str[BT_UUID_STRING_SIZE];
if (!a2dp_init_pending)
return;
BT_DBG("+");
a2dp_init_pending = FALSE;
- for (i = 0; i < count; i++) {
- uuid = service_list[i].uuid;
- _bt_service_convert_uuid_type_to_string(uuid_str, uuid);
- BT_INFO("Adapter Service: [%s]", uuid_str);
- if (!strcasecmp(uuid_str, A2DP_SINK_UUID)) {
- BT_INFO("Enable A2DP Sink role");
- /* Initialize A2DP Sink */
- ret = _bt_audio_initialize(BT_A2DP_SINK_MODULE);
- if (ret != BLUETOOTH_ERROR_NONE)
- BT_ERR("_bt_audio_initialize(BT_A2DP_SINK_MODULE) Failed");
-
- /* Initialize AVRCP Controller */
- ret = _bt_audio_initialize(BT_AVRCP_CTRL_MODULE);
- if (ret != BLUETOOTH_ERROR_NONE)
- BT_ERR("_bt_audio_initialize(BT_AVRCP_CTRL_MODULE) Failed");
-
- _bt_audio_set_current_role(BLUETOOTH_A2DP_SINK);
- return;
- }
+
+ if (a2dp_role == BT_A2DP_SINK_ROLE) {
+ BT_INFO("Enable A2DP Sink role");
+ /* Initialize A2DP Sink */
+ ret = _bt_audio_initialize(BT_A2DP_SINK_MODULE);
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("_bt_audio_initialize(BT_A2DP_SINK_MODULE) Failed");
+
+ /* Initialize AVRCP Controller */
+ ret = _bt_audio_initialize(BT_AVRCP_CTRL_MODULE);
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("_bt_audio_initialize(BT_AVRCP_CTRL_MODULE) Failed");
+
+ _bt_audio_set_current_role(BLUETOOTH_A2DP_SINK);
+ return;
}
- BT_INFO("Enable A2DP Source role by default");
+ BT_INFO("Enable A2DP Source role");
/* Initialize A2DP Source */
ret = _bt_audio_initialize(BT_A2DP_SOURCE_MODULE);
if (ret != BLUETOOTH_ERROR_NONE)
count = list->num;
service_list = list->service_list;
- __bt_handle_pending_a2dp_init(service_list, count);
__bt_adapter_handle_pending_requests(BT_IS_SERVICE_USED, service_list, count);
break;
}
g_free(addr_list);
break;
}
+ case OAL_EVENT_ADAPTER_PROPERTY_A2DP_ROLE: {
+ unsigned int *a2dp_role = event_data;
+
+ BT_INFO("a2dp role: [%u]", *a2dp_role);
+
+ __bt_handle_pending_a2dp_init(*a2dp_role);
+
+ break;
+ }
default:
BT_ERR("Unhandled event..");
break;
case OAL_EVENT_ADAPTER_PROPERTY_NAME:
case OAL_EVENT_ADAPTER_PROPERTY_VERSION:
case OAL_EVENT_ADAPTER_PROPERTY_SERVICES:
+ case OAL_EVENT_ADAPTER_PROPERTY_A2DP_ROLE:
case OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST:
case OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE:
case OAL_EVENT_ADAPTER_MODE_CONNECTABLE:
} bt_audio_type_t;
typedef enum {
+ BT_A2DP_SOURCE_ROLE = 0,
+ BT_A2DP_SINK_ROLE,
+} bt_a2dp_role_t;
+
+typedef enum {
SERVICE_SEARCH_NOT_STARTED,
SERVICE_SEARCH_STARTED,
SERVICE_SEARCH_DONE,