if (prev_active_profile != device_item->active_profile) {
pa_log_debug("%s's active profile : %u", device_item->name, device_item->active_profile);
- notify_device_info_changed(device_item, DM_DEVICE_CHANGED_INFO_SUBTYPE, device_item->dm);
+ notify_device_info_changed(device_item, DM_DEVICE_CHANGED_INFO_IO_DIRECTION, device_item->dm);
}
return device_item;
static int get_profile_priority(const char *device_profile) {
if (!device_profile) {
return 0;
- } else if (pa_streq(device_profile, DEVICE_PROFILE_BT_SCO)) {
- return 1;
} else if (pa_streq(device_profile, DEVICE_PROFILE_BT_A2DP)) {
+ return 1;
+ } else if (pa_streq(device_profile, DEVICE_PROFILE_BT_SCO)) {
return 2;
} else {
return -1;
}
}
- if (prev_active_profile != device_item->active_profile) {
+ /* notify direction changed, if only new added profile is active */
+ if ((prev_active_profile != PA_INVALID_INDEX) && (prev_active_profile != device_item->active_profile)) {
pa_log_debug("%s's active profile : %u", device_item->name, device_item->active_profile);
- notify_device_info_changed(device_item, DM_DEVICE_CHANGED_INFO_SUBTYPE, device_item->dm);
+ notify_device_info_changed(device_item, DM_DEVICE_CHANGED_INFO_IO_DIRECTION, device_item->dm);
}
return device_item;
} else if (pa_streq(device_type, DEVICE_TYPE_BT) && device_profile && pa_streq(device_profile, DEVICE_PROFILE_BT_SCO)) {
if (detected_status == BT_SCO_DISCONNECTED) {
dm->bt_sco_status = DM_DEVICE_BT_SCO_STATUS_DISCONNECTED;
- handle_device_disconnected(dm, device_type, device_profile, identifier);
} else if (detected_status == BT_SCO_CONNECTED) {
dm->bt_sco_status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
- handle_device_connected(dm, device_type, device_profile, name, identifier, DEVICE_DETECTED_BT_SCO);
} else {
pa_log_warn("Got invalid bt-sco detected value");
return -1;
pa_assert(dm);
pa_assert(dm->dbus_conn);
- if (!(status_info = _device_manager_get_status_info(dm->device_status, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, NULL))) {
- pa_log_error("No status info for bt-sco");
- return -1;
- }
- if (!status_info->detected) {
- pa_log_error("bt-sco not detected");
+ if (dm->bt_sco_status != DM_DEVICE_BT_SCO_STATUS_CONNECTED) {
+ pa_log_error("bt-sco not connected");
return -1;
}
}
pa_log_debug("bt sco open end");
-
- if (_device_item_set_active_profile(bt_device, DEVICE_PROFILE_BT_SCO) == NULL) {
- pa_log_error("set bt sco as active profile failed");
- }
dm->bt_sco_status = DM_DEVICE_BT_SCO_STATUS_OPENED;
+ handle_device_connected(dm, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, NULL, NULL, DEVICE_DETECTED_BT_SCO);
return 0;
}
pa_assert(dm);
pa_assert(dm->dbus_conn);
- if (!(status_info = _device_manager_get_status_info(dm->device_status, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, NULL))) {
- pa_log_error("No status info for bt-sco");
- return -1;
- }
- if (!status_info->detected) {
- pa_log_error("bt-sco not detected");
+ if (dm->bt_sco_status != DM_DEVICE_BT_SCO_STATUS_OPENED) {
+ pa_log_error("bt-sco not opened");
return -1;
}
pa_log_error("Failed to bt sco close");
return -1;
}
- pa_log_debug("bt sco close end");
- if (_device_item_set_active_profile_auto(bt_device) == NULL) {
- pa_log_error("set active profile auto failed");
- }
+
dm->bt_sco_status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
+ handle_device_disconnected(dm, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, NULL);
+
+ pa_log_debug("bt sco close end");
return 0;
}