device-manager : modify to create sco profile item when sco open 08/52208/5
authorMok Jeongho <jho.mok@samsung.com>
Fri, 20 Nov 2015 00:34:33 +0000 (09:34 +0900)
committerJeongho Mok <jho.mok@samsung.com>
Fri, 20 Nov 2015 05:45:16 +0000 (21:45 -0800)
Previously, bt-sco profile_item is created and notified
when HFP connection dbus signal comes, but it is little confused
because bt-a2dp is created right after that and notify 'direction-changed'.
So, we just create bt-sco profile item when we sco open internally,
and then it will be notified.

[Version] 5.0.16
[Profile] Common
[Issue Type] Change logic

Change-Id: I78f5f9652b4dbb4e0e8bc73edd547a415f49363e

packaging/pulseaudio-modules-tizen.spec
src/device-manager.c

index bbb70e549ff5ed6bd65d15ef6221f8311c8ad7ed..81d9364ffa0e2c602893ead24b07d491d09587a9 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.14
+Version:          5.0.16
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 0d3a792ad7f2038b3f1e39d84e9678a77b8bbf11..3165ad835ad88fbd0d79ffbacd084eefefbc5fe4 100644 (file)
@@ -1321,7 +1321,7 @@ static dm_device* _device_item_set_active_profile(dm_device *device_item, const
 
     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;
@@ -1330,9 +1330,9 @@ static dm_device* _device_item_set_active_profile(dm_device *device_item, const
 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;
@@ -1384,9 +1384,10 @@ static dm_device* _device_item_set_active_profile_auto(dm_device *device_item) {
         }
     }
 
-    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;
@@ -3196,10 +3197,8 @@ static int handle_device_status_changed(pa_device_manager *dm, const char *devic
     } 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;
@@ -4144,12 +4143,8 @@ int pa_device_manager_bt_sco_open(pa_device_manager *dm) {
     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;
     }
 
@@ -4165,11 +4160,8 @@ int pa_device_manager_bt_sco_open(pa_device_manager *dm) {
     }
 
     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;
 }
@@ -4190,12 +4182,8 @@ int pa_device_manager_bt_sco_close(pa_device_manager *dm) {
     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;
     }
 
@@ -4209,11 +4197,11 @@ int pa_device_manager_bt_sco_close(pa_device_manager *dm) {
         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;
 }