Remove device profile concept 68/101168/4
authorJeongho Mok <jho.mok@samsung.com>
Mon, 28 Nov 2016 13:44:33 +0000 (22:44 +0900)
committerJeongho Mok <jho.mok@samsung.com>
Mon, 5 Dec 2016 09:16:19 +0000 (01:16 -0800)
[Version] 5.0.98
[Profile] Common
[Issue Type] Enhancement

Change-Id: I5fbde486cb79056d3b25a4a4ee3690f35d32338d

packaging/pulseaudio-modules-tizen.spec
src/communicator.h
src/device-manager.c
src/device-manager.h
src/module-tizenaudio-policy.c
src/stream-manager-priv.h
src/stream-manager.c
src/tizen-device-def.c
src/tizen-device-def.h
src/tizen-device.c
src/tizen-device.h

index 6dcdb0a..6ee1474 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.97
+Version:          5.0.98
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 985f959..79d5df9 100644 (file)
@@ -28,7 +28,6 @@ typedef enum pa_communicator_hook {
     PA_COMMUNICATOR_HOOK_SELECT_INIT_SINK_OR_SOURCE, /* It is fired when a stream is created and needs to be set to sink or source */
     PA_COMMUNICATOR_HOOK_CHANGE_ROUTE,               /* It is fired when routing using internal codec should be processed */
     PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED,  /* It is fired when a device is connected or disconnected */
-    PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED,     /* It is fired when a device's profile is changed */
     PA_COMMUNICATOR_HOOK_DEVICE_STATE_CHANGED,       /* It is fired when a device's state is changed */
     PA_COMMUNICATOR_HOOK_EVENT_FULLY_HANDLED,        /* It is fired when a event is handled by all subscribers */
     PA_COMMUNICATOR_HOOK_UPDATE_INFORMATION,         /* It is fired when information should be updated */
index 319d098..ed07c80 100644 (file)
@@ -54,7 +54,6 @@
 #define SHARED_DEVICE_MANAGER "tizen-device-manager"
 
 #define DEVICE_MAP_FILE                    "/etc/pulse/device-map.json"
-#define DEVICE_PROFILE_MAX                  2
 #define DEVICE_STR_MAX                      30
 #define DEVICE_DIRECTION_MAX                3
 #define DEVICE_PARAM_STRING_MAX             150
@@ -63,7 +62,6 @@
 #define DEVICE_FILE_PER_TYPE_MAX            4
 #define DEVICE_FILE_STRING_MAX              4
 #define DEVICE_TYPE_STR_MAX                 20
-#define DEVICE_PROFILE_STR_MAX              5
 #define DEVICE_ROLE_STR_MAX                 15
 
 #define DEVICE_TYPE_OBJECT                  "device-types"
     " <interface name=\"" DBUS_INTERFACE_DEVICE_MANAGER "\">\n"                             \
     "  <method name=\"GetConnectedDeviceList\">\n"                                          \
     "   <arg name=\"mask_flags\" direction=\"in\" type=\"i\"/>\n"                           \
-    "   <arg name=\"ConnectedDeviceList\" direction=\"out\" type=\"a(isiiis)\"/>\n"          \
+    "   <arg name=\"ConnectedDeviceList\" direction=\"out\" type=\"a(isiis)\"/>\n"          \
     "  </method>\n"                                                                         \
     "  <method name='GetBTA2DPStatus'>"                                                     \
     "    <arg type='b' name='is_bt_on' direction='out'/>"                                   \
     "  </method>"                                                                           \
     "  <method name=\"LoadSink\">\n"                                                        \
     "   <arg name=\"device_type\" direction=\"in\" type=\"s\"/>\n"                          \
-    "   <arg name=\"device_profile\" direction=\"in\" type=\"s\"/>\n"                       \
     "   <arg name=\"role\" direction=\"in\" type=\"s\"/>\n"                                 \
     "  </method>\n"                                                                         \
     "  <method name=\"TestStatusChange\">\n"                                                \
     "   <arg name=\"device_type\" direction=\"in\" type=\"s\"/>\n"                          \
-    "   <arg name=\"device_profile\" direction=\"in\" type=\"s\"/>\n"                       \
     "   <arg name=\"status\" direction=\"in\" type=\"i\"/>\n"                               \
     "  </method>\n"                                                                         \
     "  <property name=\"PropertyTest1\" type=\"i\" access=\"readwrite\"/>\n"                \
@@ -293,7 +289,6 @@ typedef enum dm_device_bt_mode_type {
 typedef enum dm_device_changed_into_type {
     DM_DEVICE_CHANGED_INFO_STATE,
     DM_DEVICE_CHANGED_INFO_IO_DIRECTION,
-    DM_DEVICE_CHANGED_INFO_BT_AVAIL_MODE,
     DM_DEVICE_CHANGED_INFO_MAX
 } dm_device_changed_info_t;
 
@@ -334,7 +329,6 @@ struct device_file_info {
 /* structure for represent device-types(ex. builtin-speaker) properties*/
 struct device_type_info {
     const char *type;
-    const char *profile;
     /*
         For save supported roles and related device-file.
         { key:role -> value:device_string ]
@@ -345,7 +339,6 @@ struct device_type_info {
 
 struct device_status_info {
     char *type;
-    char *profile;
     char *name;
     /* Identify devices among same device-types (for multi-device), currently not works*/
     char *system_id;
@@ -365,7 +358,7 @@ struct pa_device_manager {
     pa_core *core;
     pa_hook_slot *sink_put_hook_slot, *sink_state_changed_slot, *sink_unlink_hook_slot;
     pa_hook_slot *source_put_hook_slot, *source_state_changed_slot, *source_unlink_hook_slot;
-    pa_hook_slot *comm_hook_device_connection_changed_slot, *comm_hook_device_profile_changed_slot;
+    pa_hook_slot *comm_hook_device_connection_changed_slot;
     pa_hook_slot *comm_hook_device_state_changed_slot;
     pa_communicator *comm;
 
@@ -390,7 +383,6 @@ struct pa_device_manager {
 
 struct composite_type {
     const char *type;
-    const char *profile;
     const char *role;
 };
 
@@ -430,9 +422,9 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = {
 
 #endif
 
-static inline void simple_device_dump(pa_log_level_t level, const char *prefix, int id, const char *type, const char *name, int direction, int state, int avail_mode) {
-    pa_logl(level, "%s device id(%d) type(%s) name (%s) direction(%d) state(%d) avail-mode(%d)",
-            pa_strempty(prefix), id, pa_strnull(type), pa_strnull(name), direction, state, avail_mode);
+static inline void simple_device_dump(pa_log_level_t level, const char *prefix, int id, const char *type, const char *name, int direction, int state) {
+    pa_logl(level, "%s device id(%d) type(%s) name (%s) direction(%d) state(%d)",
+            pa_strempty(prefix), id, pa_strnull(type), pa_strnull(name), direction, state);
 }
 
 static void type_info_free_func(struct device_type_info *type_info) {
@@ -715,12 +707,12 @@ static const char* device_class_get_module_name(dm_device_class_t device_class,
     }
 }
 
-static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type, const char *device_profile) {
+static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type) {
     struct device_type_info *type_info;
     uint32_t type_idx;
 
     PA_IDXSET_FOREACH(type_info, type_infos, type_idx) {
-        if (device_type_is_equal(type_info->type, type_info->profile, type, device_profile)) {
+        if (device_type_is_equal(type_info->type, type)) {
             return type_info;
         }
     }
@@ -745,13 +737,12 @@ static struct device_file_info* _device_manager_get_file_info(pa_idxset *file_in
     return NULL;
 }
 
-static struct device_status_info* _device_status_new(const char *type, const char *profile,
+static struct device_status_info* _device_status_new(const char *type,
         const char *name, const char *system_id) {
     struct device_status_info *status_info;
 
     status_info = (struct device_status_info *) pa_xmalloc0(sizeof(struct device_status_info));
     status_info->type = pa_xstrdup(type);
-    status_info->profile = pa_xstrdup(profile);
     status_info->name = pa_xstrdup(name);
     status_info->system_id = pa_xstrdup(system_id);
     status_info->detected = DEVICE_DISCONNECTED;
@@ -764,14 +755,13 @@ static void _device_status_free(struct device_status_info *status_info) {
         return ;
 
     pa_xfree(status_info->type);
-    pa_xfree(status_info->profile);
     pa_xfree(status_info->name);
     pa_xfree(status_info->system_id);
     pa_xfree(status_info);
 }
 
 static struct device_status_info* _get_device_status(pa_device_manager *manager, const char *type,
-        const char *device_profile, const char *system_id) {
+        const char *system_id) {
     struct device_status_info *status_info = NULL;
     uint32_t status_idx;
 
@@ -779,7 +769,7 @@ static struct device_status_info* _get_device_status(pa_device_manager *manager,
     pa_assert(manager->device_status);
 
     PA_IDXSET_FOREACH(status_info, manager->device_status, status_idx) {
-        if (device_type_is_equal(status_info->type, status_info->profile, type, device_profile)) {
+        if (device_type_is_equal(status_info->type, type)) {
             if (device_type_is_avail_multi_device(type)) {
                 /* if system_id is null, just compare type */
                 if (system_id == NULL)
@@ -814,7 +804,7 @@ static const char* _file_infos_get_param(pa_idxset *file_infos, const char *devi
     return params;
 }
 
-static device_detected_type_t _device_get_detected(pa_device_manager *manager, const char *type, const char *device_profile,
+static device_detected_type_t _device_get_detected(pa_device_manager *manager, const char *type,
         const char *system_id) {
     struct device_status_info *status_info;
 
@@ -822,24 +812,24 @@ static device_detected_type_t _device_get_detected(pa_device_manager *manager, c
     pa_assert(manager->device_status);
     pa_assert(type);
 
-    if (!device_type_is_need_detect(type, device_profile))
+    if (!device_type_is_need_detect(type))
         return DEVICE_CONNECTED;
 
-    status_info = _get_device_status(manager, type, device_profile, system_id);
+    status_info = _get_device_status(manager, type, system_id);
     if (!status_info) {
-        pa_log_info("No status info for type(%s) profile(%s) system_id(%s)",
-                type, pa_strempty(device_profile), pa_strempty(system_id));
+        pa_log_info("No status info for type(%s) system_id(%s)",
+                type, pa_strempty(system_id));
         return DEVICE_DISCONNECTED;
     }
 
-    pa_log_debug("Get device detected, type(%s) profile(%s) system_id(%s) : %s(%d)",
-            type, pa_strempty(device_profile), pa_strempty(system_id),
+    pa_log_debug("Get device detected, type(%s) system_id(%s) : %s(%d)",
+            type, pa_strempty(system_id),
              (status_info->detected & DEVICE_CONNECTED) ? "Connected" : "Disconnected", status_info->detected);
 
     return status_info->detected;
 }
 
-static void _device_set_detected(pa_device_manager *manager, const char *type, const char *device_profile,
+static void _device_set_detected(pa_device_manager *manager, const char *type,
         const char *name, const char *system_id, device_detected_type_t detected_type) {
     struct device_status_info *status_info;
 
@@ -847,22 +837,22 @@ static void _device_set_detected(pa_device_manager *manager, const char *type, c
     pa_assert(manager->device_status);
     pa_assert(type);
 
-    if (!device_type_is_need_detect(type, device_profile))
+    if (!device_type_is_need_detect(type))
         return ;
 
-    pa_log_info("Set device detected, type(%s) profile(%s) system_id(%s) -> %s(%d)",
-            type, pa_strempty(device_profile), pa_strempty(system_id),
+    pa_log_info("Set device detected, type(%s) system_id(%s) -> %s(%d)",
+            type, pa_strempty(system_id),
             (detected_type & DEVICE_CONNECTED) ? "Connected" : "Disconnected", detected_type);
 
     if (detected_type & DEVICE_CONNECTED) {
-        status_info = _get_device_status(manager, type, device_profile, system_id);
+        status_info = _get_device_status(manager, type, system_id);
         if (!status_info) {
-            status_info = _device_status_new(type, device_profile, name, system_id);
+            status_info = _device_status_new(type, name, system_id);
             pa_idxset_put(manager->device_status, status_info, NULL);
         }
         status_info->detected = detected_type;
     } else {
-        status_info = _get_device_status(manager, type, device_profile, system_id);
+        status_info = _get_device_status(manager, type, system_id);
         if (status_info) {
             pa_idxset_remove_by_data(manager->device_status, status_info, NULL);
             _device_status_free(status_info);
@@ -1070,7 +1060,7 @@ static const char* device_type_info_get_role(struct device_type_info *type_info,
     pa_assert(type_info);
     pa_assert(device_string);
 
-    direction = device_type_get_static_direction(type_info->type, type_info->profile);
+    direction = device_type_get_static_direction(type_info->type);
     if (direction == DM_DEVICE_DIRECTION_NONE) {
         pa_log_debug("Not static direction");
         return NULL;
@@ -1091,8 +1081,7 @@ static const char* device_type_info_get_role(struct device_type_info *type_info,
     }
 
     if (!pcm_devices) {
-        pa_log_warn("No %s pcm devices for %s %s", is_playback ? "playback" : "capture",
-                type_info->type, pa_strempty(type_info->profile));
+        pa_log_warn("No %s pcm devices for %s", is_playback ? "playback" : "capture", type_info->type);
         return NULL;
     }
 
@@ -1136,7 +1125,6 @@ pa_dynarray* pulse_device_get_belongs_type(pa_object *pdevice, pa_device_manager
         if (role) {
             ctype = pa_xmalloc0(sizeof(struct composite_type));
             ctype->type = type_info->type;
-            ctype->profile = type_info->profile;
             ctype->role = role;
             pa_dynarray_append(ctypes, ctype);
         }
@@ -1160,7 +1148,7 @@ static const char* pulse_device_get_device_name(pa_object *pdevice, const char *
 
     if (pa_streq(type, DEVICE_TYPE_USB_AUDIO))
         return pa_proplist_gets(prop, "udev.id");
-    else if (pa_streq(type, DEVICE_TYPE_BT))
+    else if (pa_streq(type, DEVICE_TYPE_BT_A2DP))
         return pa_proplist_gets(prop, "bluez.alias");
     else
         return NULL;
@@ -1191,7 +1179,107 @@ static const char* pulse_device_get_system_id(pa_object *pdevice) {
         return NULL;
 }
 
-static pa_sink* _device_manager_set_default_sink(pa_device_manager *dm,  const char *type,  const char *device_profile,  const char *role) {
+static pa_sink* _core_get_sink(pa_core *core, const char *device_string, const char *params) {
+    uint32_t device_idx;
+    pa_sink *sink;
+
+    pa_assert(core);
+    pa_assert(device_string);
+
+    PA_IDXSET_FOREACH(sink, core->sinks, device_idx) {
+        if (pulse_device_is_monitor(PA_OBJECT(sink)))
+            continue;
+        if (pulse_device_same_device_string(PA_OBJECT(sink), device_string)) {
+            if (params == NULL)
+                return sink;
+            else if (pulse_device_params_is_equal(PA_OBJECT(sink), params))
+                return sink;
+        }
+    }
+
+    return NULL;
+}
+
+static pa_source* _core_get_source(pa_core *core, const char *device_string, const char *params) {
+    uint32_t device_idx;
+    pa_source *source;
+
+    pa_assert(core);
+    pa_assert(device_string);
+
+    PA_IDXSET_FOREACH(source, core->sources, device_idx) {
+        if (pulse_device_is_monitor(PA_OBJECT(source)))
+            continue;
+        if (pulse_device_same_device_string(PA_OBJECT(source), device_string)) {
+            if (params == NULL)
+                return source;
+            else if (pulse_device_params_is_equal(PA_OBJECT(source), params))
+                return source;
+        }
+    }
+
+    return NULL;
+}
+
+
+static void _fill_new_data_basic(pa_tz_device_new_data *data, const char *type,
+        dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
+    pa_assert(data);
+
+    pa_tz_device_new_data_set_type(data, type);
+    pa_tz_device_new_data_set_direction(data, direction);
+    pa_tz_device_new_data_set_use_internal_codec(data, use_internal_codec);
+}
+
+static int _fill_new_data_sinks(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
+    pa_sink *sink;
+    char *device_string, *role;
+    void *state;
+
+    pa_assert(data);
+    pa_assert(type_info);
+
+    if (type_info->playback_devices == NULL) {
+        pa_log_error("No playback devices for %s", type_info->type);
+        return -1;
+    }
+
+    PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
+        sink = _core_get_sink(dm->core, device_string, NULL);
+        if (sink)
+            pa_tz_device_new_data_add_sink(data, role, sink);
+        else
+            pa_log_error("Failed to get matching sink for %s %s", role, device_string);
+    }
+
+    return 0;
+}
+
+static int _fill_new_data_sources(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
+    pa_source *source;
+    char *device_string, *role;
+    void *state;
+
+    pa_assert(data);
+    pa_assert(type_info);
+
+    if (type_info->capture_devices == NULL) {
+        pa_log_error("No capture devices for %s", type_info->type);
+        return -1;
+    }
+
+    PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
+        source = _core_get_source(dm->core, device_string, NULL);
+        if (source)
+            pa_tz_device_new_data_add_source(data, role, source);
+        else
+            pa_log_error("Failed to get matching source for %s %s", role, device_string);
+    }
+
+    return 0;
+}
+
+static pa_sink* _device_manager_set_default_sink(pa_device_manager *dm,  const char *type, const char *role) {
     pa_tz_device *device;
     pa_sink *sink;
 
@@ -1214,7 +1302,7 @@ static pa_sink* _device_manager_set_default_sink(pa_device_manager *dm,  const c
     return sink;
 }
 
-static pa_source* _device_manager_set_default_source(pa_device_manager *dm,  const char *type,  const char *device_profile,  const char *role) {
+static pa_source* _device_manager_set_default_source(pa_device_manager *dm,  const char *type, const char *role) {
     pa_tz_device *device;
     pa_source *source;
 
@@ -1291,55 +1379,27 @@ static void handle_bt_pulse_device(pa_object *pdevice, bool is_loaded, pa_device
 
     if (is_loaded) {
         pa_tz_device_new_data data;
-        pa_tz_profile_new_data profile_data;
 
-        /* Use profile_new_data, because BT is multi profile type */
-        pa_tz_profile_new_data_init(&profile_data);
-        pa_tz_profile_new_data_set_profile(&profile_data, DEVICE_PROFILE_BT_A2DP);
-        pa_tz_profile_new_data_set_direction(&profile_data, direction);
-        pa_tz_profile_new_data_set_use_internal_codec(&profile_data, false);
+        const char *name;
+        name = pulse_device_get_device_name(pdevice, DEVICE_TYPE_BT_A2DP);
+
+        pa_tz_device_new_data_init(&data, manager->device_list, manager->comm, manager->dbus_conn);
+        _fill_new_data_basic(&data, DEVICE_TYPE_BT_A2DP, direction, false, manager);
+        pa_tz_device_new_data_set_name(&data, name);
+        pa_tz_device_new_data_set_system_id(&data, system_id);
         if (direction == DM_DEVICE_DIRECTION_OUT)
-            pa_tz_profile_new_data_add_sink(&profile_data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice));
+            pa_tz_device_new_data_add_sink(&data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice));
         else
-            pa_tz_profile_new_data_add_source(&profile_data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice));
-
-        device = _device_list_get_device(manager, DEVICE_TYPE_BT, system_id);
-        /* Just add profile, if already exists */
-        if (device) {
-            dm_device_bt_sco_status_t sco_status;
-            if (pa_tz_device_sco_get_status(device, &sco_status) < 0) {
-                pa_log_error("Failed to get sco status");
-                return ;
-            }
-            if (sco_status == DM_DEVICE_BT_SCO_STATUS_OPENED)
-                pa_tz_device_add_profile(device, &profile_data, false);
-            else
-                pa_tz_device_add_profile(device, &profile_data, true);
-        } else {
-            /* Create new device with profile */
-            const char *name;
-            name = pulse_device_get_device_name(pdevice, DEVICE_TYPE_BT);
-
-            pa_tz_device_new_data_init(&data, manager->device_list, manager->comm, manager->dbus_conn);
-            pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_BT);
-            pa_tz_device_new_data_set_name(&data, name);
-            pa_tz_device_new_data_set_system_id(&data, system_id);
-            pa_tz_device_new_data_add_profile(&data, &profile_data, true);
+            pa_tz_device_new_data_add_source(&data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice));
 
-            pa_tz_device_new(&data);
-            pa_tz_device_new_data_done(&data);
-        }
-        pa_tz_profile_new_data_done(&profile_data);
+        pa_tz_device_new(&data);
+        pa_tz_device_new_data_done(&data);
     } else {
 
-        if (!(device = _device_list_get_device(manager, DEVICE_TYPE_BT, system_id)))
+        if (!(device = _device_list_get_device(manager, DEVICE_TYPE_BT_A2DP, system_id)))
             pa_log_warn("Can't get bt device for %s", system_id);
-        else {
-            if (pa_tz_device_get_profile_num(device) > 1)
-                pa_tz_device_remove_profile(device, DEVICE_PROFILE_BT_A2DP);
-            else
-                pa_tz_device_free(device);
-        }
+        else
+            pa_tz_device_free(device);
     }
 }
 
@@ -1365,13 +1425,13 @@ static void handle_internal_pulse_device(pa_object *pdevice, bool is_loaded, pa_
         /* Put this pulse_device to already loaded devices */
         for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
             ctype = pa_dynarray_get(ctypes, i);
-            pa_log_info("Found belongs type %s %s %s", ctype->type, pa_strempty(ctype->profile), ctype->role);
+            pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
             if ((device = _device_list_get_device(manager, ctype->type, NULL))) {
                 pa_log_info("Add this pulse_device to device(%u)", pa_tz_device_get_id(device));
                 if (direction == DM_DEVICE_DIRECTION_OUT)
-                    pa_tz_device_profile_add_sink(device, ctype->profile, ctype->role, PA_SINK(pdevice));
+                    pa_tz_device_add_sink(device, ctype->role, PA_SINK(pdevice));
                 else
-                    pa_tz_device_profile_add_source(device, ctype->profile, ctype->role, PA_SOURCE(pdevice));
+                    pa_tz_device_add_source(device, ctype->role, PA_SOURCE(pdevice));
             } else {
                 pa_log_info("No device for %s", ctype->type);
             }
@@ -1380,7 +1440,7 @@ static void handle_internal_pulse_device(pa_object *pdevice, bool is_loaded, pa_
         /* Remove this pulse_device from already loaded devices */
         for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
             ctype = pa_dynarray_get(ctypes, i);
-            pa_log_info("Found belongs type %s %s %s", ctype->type, ctype->profile, ctype->role);
+            pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
             if ((device = _device_list_get_device(manager, ctype->type, NULL))) {
                 pa_log_info("Remove this pulse_device from device(%u)", pa_tz_device_get_id(device));
                 if (direction == DM_DEVICE_DIRECTION_OUT)
@@ -1619,163 +1679,6 @@ static void* load_device(pa_core *c, bool is_sink, const char *device_string, co
     return NULL;
 }
 
-static pa_sink* _core_get_sink(pa_core *core, const char *device_string, const char *params) {
-    uint32_t device_idx;
-    pa_sink *sink;
-
-    pa_assert(core);
-    pa_assert(device_string);
-
-    PA_IDXSET_FOREACH(sink, core->sinks, device_idx) {
-        if (pulse_device_is_monitor(PA_OBJECT(sink)))
-            continue;
-        if (pulse_device_same_device_string(PA_OBJECT(sink), device_string)) {
-            if (params == NULL)
-                return sink;
-            else if (pulse_device_params_is_equal(PA_OBJECT(sink), params))
-                return sink;
-        }
-    }
-
-    return NULL;
-}
-
-static pa_source* _core_get_source(pa_core *core, const char *device_string, const char *params) {
-    uint32_t device_idx;
-    pa_source *source;
-
-    pa_assert(core);
-    pa_assert(device_string);
-
-    PA_IDXSET_FOREACH(source, core->sources, device_idx) {
-        if (pulse_device_is_monitor(PA_OBJECT(source)))
-            continue;
-        if (pulse_device_same_device_string(PA_OBJECT(source), device_string)) {
-            if (params == NULL)
-                return source;
-            else if (pulse_device_params_is_equal(PA_OBJECT(source), params))
-                return source;
-        }
-    }
-
-    return NULL;
-}
-
-
-static void _fill_new_data_basic(pa_tz_device_new_data *data, const char *type,
-        dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
-    pa_assert(data);
-
-    pa_tz_device_new_data_set_type(data, type);
-    pa_tz_device_new_data_set_direction(data, direction);
-    pa_tz_device_new_data_set_use_internal_codec(data, use_internal_codec);
-}
-
-static void _fill_profile_new_data_basic(pa_tz_profile_new_data *profile_data,
-        const char *profile, dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
-    pa_assert(profile_data);
-
-    pa_tz_profile_new_data_set_profile(profile_data, profile);
-    pa_tz_profile_new_data_set_direction(profile_data, direction);
-    pa_tz_profile_new_data_set_use_internal_codec(profile_data, use_internal_codec);
-}
-
-static int _fill_new_data_sinks(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
-    pa_sink *sink;
-    char *device_string, *role;
-    void *state;
-
-    pa_assert(data);
-    pa_assert(type_info);
-
-    if (type_info->playback_devices == NULL) {
-        pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
-        return -1;
-    }
-
-    PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
-        sink = _core_get_sink(dm->core, device_string, NULL);
-        if (sink)
-            pa_tz_device_new_data_add_sink(data, role, sink);
-        else
-            pa_log_error("Failed to get matching sink for %s %s", role, device_string);
-    }
-
-    return 0;
-}
-
-static int _fill_new_data_sources(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
-    pa_source *source;
-    char *device_string, *role;
-    void *state;
-
-    pa_assert(data);
-    pa_assert(type_info);
-
-    if (type_info->capture_devices == NULL) {
-        pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
-        return -1;
-    }
-
-    PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
-        source = _core_get_source(dm->core, device_string, NULL);
-        if (source)
-            pa_tz_device_new_data_add_source(data, role, source);
-        else
-            pa_log_error("Failed to get matching source for %s %s", role, device_string);
-    }
-
-    return 0;
-}
-
-static int _fill_profile_new_data_sinks(pa_tz_profile_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
-    pa_sink *sink;
-    char *device_string, *role;
-    void *state;
-
-    pa_assert(data);
-    pa_assert(type_info);
-
-    if (type_info->playback_devices == NULL) {
-        pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
-        return -1;
-    }
-
-    PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
-        sink = _core_get_sink(dm->core, device_string, NULL);
-        if (sink)
-            pa_tz_profile_new_data_add_sink(data, role, sink);
-        else
-            pa_log_error("Failed to get matching sink for %s %s", role, device_string);
-    }
-
-    return 0;
-}
-
-static int _fill_profile_new_data_sources(pa_tz_profile_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
-    pa_source *source;
-    char *device_string, *role;
-    void *state;
-
-    pa_assert(data);
-    pa_assert(type_info);
-
-    if (type_info->capture_devices == NULL) {
-        pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
-        return -1;
-    }
-
-    PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
-        source = _core_get_source(dm->core, device_string, NULL);
-        if (source)
-            pa_tz_profile_new_data_add_source(data, role, source);
-        else
-            pa_log_error("Failed to get matching source for %s %s", role, device_string);
-    }
-
-    return 0;
-}
-
 static int _load_type_devices(struct device_type_info *type_info, bool is_playback, pa_device_manager *dm) {
     pa_hashmap *pcm_devices;
     pa_idxset *file_infos;
@@ -1786,8 +1689,7 @@ static int _load_type_devices(struct device_type_info *type_info, bool is_playba
     pa_assert(dm);
     pa_assert(type_info);
 
-    pa_log_info("Load type devices : %s %s %s", type_info->type, pa_strempty(type_info->profile),
-            is_playback ? "playback" : "capture");
+    pa_log_info("Load type devices : %s %s", type_info->type, is_playback ? "playback" : "capture");
 
     if (is_playback) {
         pcm_devices = type_info->playback_devices;
@@ -1868,50 +1770,30 @@ static pa_tz_device* _load_forwarding_device(pa_device_manager *dm) {
     And if correnspondent sink/sources for device_type exist, should make device and notify it.
     Use [device_type->roles] mappings in sink/source for find proper sink/source.
 */
-static void handle_device_connected(pa_device_manager *dm, const char *type, const char *device_profile,
+static void handle_device_connected(pa_device_manager *dm, const char *type,
         const char *name, const char *system_id, device_detected_type_t detected_type) {
     struct device_type_info *type_info;
-    pa_tz_device *device;
     pa_tz_device_new_data data;
 
     pa_assert(dm);
     pa_assert(dm->device_status);
     pa_assert(dm->device_list);
 
-    pa_log_info("Device connected, type(%s) profile(%s) name(%s) system_id(%s) detected_type(%d)",
-            type, pa_strempty(device_profile), pa_strempty(name), pa_strempty(system_id), detected_type);
-
-    type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile);
-
-    if (device_type_is_equal(type, device_profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
-        pa_tz_profile_new_data profile_data;
-
-        /* Use profile_new_data, because BT is multi profile type */
-        pa_tz_profile_new_data_init(&profile_data);
-        _fill_profile_new_data_basic(&profile_data, DEVICE_PROFILE_BT_SCO,
-                DM_DEVICE_DIRECTION_BOTH, true, dm);
-
-        _fill_profile_new_data_sinks(&profile_data, type_info, dm);
-        _fill_profile_new_data_sources(&profile_data, type_info, dm);
+    pa_log_info("Device connected, type(%s) name(%s) system_id(%s) detected_type(%d)",
+            type, pa_strempty(name), pa_strempty(system_id), detected_type);
 
-        device = _device_list_get_device(dm, DEVICE_TYPE_BT, system_id);
-        if (device) {
-            /* Just add profile, if already exists */
-            pa_tz_device_add_profile(device, &profile_data, false);
-        } else {
-            /* Create new device with profile */
-
-            pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn);
-            pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_BT);
-            pa_tz_device_new_data_set_name(&data, name);
-            pa_tz_device_new_data_set_system_id(&data, system_id);
-            pa_tz_device_new_data_add_profile(&data, &profile_data, true);
+    type_info = _device_manager_get_type_info(dm->type_infos, type);
 
-            pa_tz_device_new(&data);
-            pa_tz_device_new_data_done(&data);
-        }
-        pa_tz_profile_new_data_done(&profile_data);
-    } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+    if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+        pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn);
+        _fill_new_data_basic(&data, DEVICE_TYPE_BT_SCO, DM_DEVICE_DIRECTION_BOTH, true, dm);
+        _fill_new_data_sinks(&data, type_info, dm);
+        _fill_new_data_sources(&data, type_info, dm);
+        pa_tz_device_new_data_set_name(&data, name);
+        pa_tz_device_new_data_set_system_id(&data, system_id);
+        pa_tz_device_new(&data);
+        pa_tz_device_new_data_done(&data);
+    } else if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
         dm_device_direction_t direction;
 
         if (detected_type == DEVICE_CONNECTED_AUDIO_JACK_4P)
@@ -1925,19 +1807,19 @@ static void handle_device_connected(pa_device_manager *dm, const char *type, con
 
         pa_tz_device_new(&data);
         pa_tz_device_new_data_done(&data);
-    } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_HDMI, NULL)) {
+    } else if (device_type_is_equal(type, DEVICE_TYPE_HDMI)) {
         pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL);
         _fill_new_data_basic(&data, DEVICE_TYPE_HDMI, DM_DEVICE_DIRECTION_OUT, true, dm);
         _fill_new_data_sinks(&data, type_info, dm);
 
         pa_tz_device_new(&data);
         pa_tz_device_new_data_done(&data);
-    } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_FORWARDING, NULL)) {
+    } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) {
         _load_forwarding_device(dm);
     } else {
         dm_device_direction_t direction;
 
-        direction = device_type_get_static_direction(type, device_profile);
+        direction = device_type_get_static_direction(type);
         if (direction != DM_DEVICE_DIRECTION_NONE) {
             pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL);
             _fill_new_data_basic(&data, type, direction, true, dm);
@@ -1962,15 +1844,14 @@ static void handle_device_connected(pa_device_manager *dm, const char *type, con
     First, update device-status hashmap.
     And if there is device which has the device_type, remove it.
 */
-static int handle_device_disconnected(pa_device_manager *dm, const char *type, const char *device_profile, const char *system_id) {
+static int handle_device_disconnected(pa_device_manager *dm, const char *type, const char *system_id) {
     pa_tz_device *device;
-    uint32_t n_profile;
 
     pa_assert(dm);
     pa_assert(dm->device_status);
 
-    pa_log_info("Device type(%s) profile(%s) system_id(%s) disconnected",
-            type, pa_strempty(device_profile), pa_strempty(system_id));
+    pa_log_info("Device type(%s) system_id(%s) disconnected",
+            type, pa_strempty(system_id));
 
     device = _device_list_get_device(dm, type, system_id);
     if (!device) {
@@ -1978,10 +1859,7 @@ static int handle_device_disconnected(pa_device_manager *dm, const char *type, c
         return -1;
     }
 
-    if ((n_profile = pa_tz_device_get_profile_num(device)) > 1)
-        pa_tz_device_remove_profile(device, device_profile);
-    else
-        pa_tz_device_free(device);
+    pa_tz_device_free(device);
 
     return 0;
 }
@@ -1990,7 +1868,7 @@ static int load_builtin_devices(pa_device_manager *dm) {
     struct device_type_info *type_info;
     uint32_t type_idx;
     device_detected_type_t detected_type = DEVICE_CONNECTED;
-    const char *type, *profile;
+    const char *type;
 
     pa_assert(dm);
 
@@ -1999,26 +1877,25 @@ static int load_builtin_devices(pa_device_manager *dm) {
     PA_IDXSET_FOREACH(type_info, dm->type_infos, type_idx) {
 
         type = type_info->type;
-        profile = type_info->profile;
 
-        pa_log_info("type_info : %s %s", type, pa_strempty(profile));
-        detected_type = _device_get_detected(dm, type, profile, NULL);
+        pa_log_info("type_info : %s", type);
+        detected_type = _device_get_detected(dm, type, NULL);
         if (detected_type == DEVICE_DISCONNECTED) {
             pa_log_info("Not detected yet");
             continue;
         }
 
-        if (device_type_is_equal(type, profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+        if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
             if (detected_type == DEVICE_CONNECTED_AUDIO_JACK_4P) {
                 _load_type_devices(type_info, true, dm);
                 _load_type_devices(type_info, false, dm);
             } else {
                 _load_type_devices(type_info, true, dm);
             }
-            handle_device_connected(dm, type, profile, NULL, NULL, detected_type);
-        } else if (device_type_is_use_external_card(type, profile) == false) {
+            handle_device_connected(dm, type, NULL, NULL, detected_type);
+        } else if (device_type_is_use_external_card(type) == false) {
             dm_device_direction_t direction;
-            direction = device_type_get_static_direction(type, profile);
+            direction = device_type_get_static_direction(type);
             if (direction == DM_DEVICE_DIRECTION_NONE) {
                 pa_log_warn("Wrong direction");
                 continue;
@@ -2027,7 +1904,7 @@ static int load_builtin_devices(pa_device_manager *dm) {
                 _load_type_devices(type_info, true, dm);
             if (direction & DM_DEVICE_DIRECTION_IN)
                 _load_type_devices(type_info, false, dm);
-            handle_device_connected(dm, type, profile, NULL, NULL, detected_type);
+            handle_device_connected(dm, type, NULL, NULL, detected_type);
         } else {
             pa_log_warn("Invalid case");
         }
@@ -2279,7 +2156,7 @@ static pa_idxset* parse_device_type_infos() {
 
             if ((device_o = json_object_array_get_idx(device_array_o, device_type_idx)) && json_object_is_type(device_o, json_type_object)) {
                 json_object *device_prop_o;
-                const char *type = NULL, *device_profile = NULL;
+                const char *type = NULL;
                 type_info = pa_xmalloc0(sizeof(struct device_type_info));
 
                 if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_DEVICE_TYPE, &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
@@ -2290,13 +2167,6 @@ static pa_idxset* parse_device_type_infos() {
                     pa_log_error("Get device type failed");
                     goto fail;
                 }
-                if (json_object_object_get_ex(device_o, "profile", &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
-                    device_profile = json_object_get_string(device_prop_o);
-                    pa_log_info("Profile - %s", device_profile);
-                    type_info->profile = device_profile;
-                } else {
-                    pa_log_debug("no device-profile");
-                }
 
                 if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_PLAYBACK_DEVICES, &device_prop_o) && json_object_is_type(device_prop_o, json_type_object)) {
                     pa_log_info("Playback Devices");
@@ -2327,31 +2197,31 @@ fail:
 
 /*
    look detected status which is external value, make conversion to internal consistent value, and handle it
-   device_type, device_profile : which type of device is detected
+   device_type, which type of device is detected
    system_id : system_id among same device types for support multi-device
 */
 static int handle_device_status_changed(pa_device_manager *dm, const char *type,
-        const char *profile, const char *name, const char *system_id, device_detected_type_t detected) {
+        const char *name, const char *system_id, device_detected_type_t detected) {
     pa_assert(dm);
     pa_assert(device_type_is_valid(type));
 
-    pa_log_info("Device Status Changed, type(%s) profile(%s) system_id(%s), detected_type(%d)",
-            type, pa_strempty(profile), pa_strempty(system_id), detected);
+    pa_log_info("Device Status Changed, type(%s) system_id(%s), detected_type(%d)",
+            type, pa_strempty(system_id), detected);
 
-    if (device_type_is_equal(type, profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
-        _device_set_detected(dm, type, profile, name, system_id, detected);
+    if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+        _device_set_detected(dm, type, name, system_id, detected);
         if (detected == DEVICE_DISCONNECTED)
-            handle_device_disconnected(dm, type, profile, system_id);
+            handle_device_disconnected(dm, type, system_id);
         else
-            handle_device_connected(dm, type, profile, name, system_id, detected);
-    } else if (device_type_is_need_detect(type, profile)) {
-        _device_set_detected(dm, type, profile, name, system_id, detected);
+            handle_device_connected(dm, type, name, system_id, detected);
+    } else if (device_type_is_need_detect(type)) {
+        _device_set_detected(dm, type, name, system_id, detected);
         if (detected == DEVICE_DISCONNECTED)
-            handle_device_disconnected(dm, type, profile, system_id);
+            handle_device_disconnected(dm, type, system_id);
         else
-            handle_device_connected(dm, type, profile, name, system_id, detected);
+            handle_device_connected(dm, type, name, system_id, detected);
     } else {
-        pa_log_debug("No need to detect type %s %s", type, pa_strempty(profile));
+        pa_log_debug("No need to detect type %s", type);
     }
 
     return 0;
@@ -2366,7 +2236,7 @@ static int handle_device_status_changed(pa_device_manager *dm, const char *type,
 static void device_type_status_init(pa_device_manager *manager) {
     struct device_type_info *type_info;
     uint32_t type_idx;
-    const char *type, *profile;
+    const char *type;
 
     pa_assert(manager);
     pa_assert(manager->type_infos);
@@ -2375,35 +2245,34 @@ static void device_type_status_init(pa_device_manager *manager) {
 
     PA_IDXSET_FOREACH(type_info, manager->type_infos, type_idx) {
         type = type_info->type;
-        profile = type_info->profile;
-        if (device_type_is_equal(type, profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+        if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
             int earjack_status = 0;
             if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status) < 0) {
                 pa_log_error("Get earjack status failed");
                 continue;
             }
             if (earjack_status == EARJACK_TYPE_SPK_ONLY)
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_3P);
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_3P);
             else if (earjack_status == EARJACK_TYPE_SPK_WITH_MIC)
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_4P);
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_4P);
             else if (earjack_status == EARJACK_DISCONNECTED)
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
             else
                 pa_log_warn("Unknown earjack status : %d", earjack_status);
-        } else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
-        } else if (device_type_is_equal(type, profile, DEVICE_TYPE_HDMI, NULL)) {
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
-        } else if (device_type_is_equal(type, profile, DEVICE_TYPE_FORWARDING, NULL)) {
+        } else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
+        } else if (device_type_is_equal(type, DEVICE_TYPE_HDMI)) {
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
+        } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) {
             int miracast_wfd_status = 0;
             if (vconf_get_bool(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &miracast_wfd_status) < 0) {
                 pa_log_error("Get mirroring status failed");
                 continue;
             }
             if (miracast_wfd_status == FORWARDING_CONNECTED)
-                _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED);
+                _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
         } else {
-            _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED);
+            _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
         }
     }
     return ;
@@ -2411,14 +2280,14 @@ static void device_type_status_init(pa_device_manager *manager) {
 
 #ifdef HAVE_DBUS
 
-static int _translate_external_value(const char *type, const char *profile, int value, device_detected_type_t *detected) {
+static int _translate_external_value(const char *type, int value, device_detected_type_t *detected) {
 
     if (!type || !detected) {
         pa_log_error("Invalid Parameter for translate");
         return -1;
     }
 
-    if (device_type_is_equal(DEVICE_TYPE_AUDIO_JACK, NULL, type, profile)) {
+    if (device_type_is_equal(DEVICE_TYPE_AUDIO_JACK, type)) {
         if (value == EARJACK_DISCONNECTED)
             *detected = DEVICE_DISCONNECTED;
         else if (value == EARJACK_TYPE_SPK_ONLY)
@@ -2427,21 +2296,21 @@ static int _translate_external_value(const char *type, const char *profile, int
             *detected = DEVICE_CONNECTED_AUDIO_JACK_4P;
         else
             return -1;
-    } else if (device_type_is_equal(DEVICE_TYPE_HDMI, NULL, type, profile)) {
+    } else if (device_type_is_equal(DEVICE_TYPE_HDMI, type)) {
         if (value == HDMI_AUDIO_DISCONNECTED)
             *detected = DEVICE_DISCONNECTED;
         else if (value == HDMI_AUDIO_AVAILABLE)
             *detected = DEVICE_CONNECTED;
         else
             return -1;
-    } else if (device_type_is_equal(DEVICE_TYPE_FORWARDING, NULL, type, profile)) {
+    } else if (device_type_is_equal(DEVICE_TYPE_FORWARDING, type)) {
         if (value == FORWARDING_DISCONNECTED)
             *detected = DEVICE_DISCONNECTED;
         else if (value == FORWARDING_CONNECTED)
             *detected = DEVICE_CONNECTED;
         else
             return -1;
-    } else if (device_type_is_equal(DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, type, profile)) {
+    } else if (device_type_is_equal(DEVICE_TYPE_BT_SCO, type)) {
         if (value == BT_SCO_DISCONNECTED)
             *detected = DEVICE_DISCONNECTED;
         else if (value == BT_SCO_CONNECTED)
@@ -2473,31 +2342,31 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB
         if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
             goto fail;
         } else {
-            if (_translate_external_value(DEVICE_TYPE_AUDIO_JACK, NULL, status, &detected) < 0) {
+            if (_translate_external_value(DEVICE_TYPE_AUDIO_JACK, status, &detected) < 0) {
                 pa_log_warn("failed to translate audio-jack detected value");
                 goto fail;
             }
-            handle_device_status_changed(dm, DEVICE_TYPE_AUDIO_JACK, NULL, NULL, NULL, detected);
+            handle_device_status_changed(dm, DEVICE_TYPE_AUDIO_JACK, NULL, NULL, detected);
         }
     } else if (dbus_message_is_signal(s, DBUS_INTERFACE_DEVICED_SYSNOTI, "ChangedHDMIAudio")) {
         if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
             goto fail;
         } else {
-            if (_translate_external_value(DEVICE_TYPE_HDMI, NULL, status, &detected) < 0) {
+            if (_translate_external_value(DEVICE_TYPE_HDMI, status, &detected) < 0) {
                 pa_log_warn("failed to translate HDMI detected value");
                 goto fail;
             }
-            handle_device_status_changed(dm, DEVICE_TYPE_HDMI, NULL, NULL, NULL, detected);
+            handle_device_status_changed(dm, DEVICE_TYPE_HDMI, NULL, NULL, detected);
         }
     } else if (dbus_message_is_signal(s, DBUS_INTERFACE_MIRRORING_SERVER, "miracast_wfd_source_status_changed")) {
         if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
             goto fail;
         } else {
-            if (_translate_external_value(DEVICE_TYPE_FORWARDING, NULL, status, &detected) < 0) {
+            if (_translate_external_value(DEVICE_TYPE_FORWARDING, status, &detected) < 0) {
                 pa_log_warn("failed to translate forwarding detected value");
                 goto fail;
             }
-            handle_device_status_changed(dm, DEVICE_TYPE_FORWARDING, NULL, NULL, NULL, detected);
+            handle_device_status_changed(dm, DEVICE_TYPE_FORWARDING, NULL, NULL, detected);
         }
     } else if (dbus_message_is_signal(s, DBUS_INTERFACE_BLUEZ_HEADSET, "PropertyChanged")) {
         DBusMessageIter msg_iter, variant_iter;
@@ -2536,11 +2405,11 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB
                 } else {
                     status = BT_SCO_DISCONNECTED;
                 }
-                if (_translate_external_value(DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, status, &detected) < 0) {
+                if (_translate_external_value(DEVICE_TYPE_BT_SCO, status, &detected) < 0) {
                     pa_log_warn("failed to translate bt-sco detected value");
                     goto fail;
                 }
-                handle_device_status_changed(dm, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO,
+                handle_device_status_changed(dm, DEVICE_TYPE_BT_SCO,
                         name, dbus_message_get_path(s),  detected);
             }
         }
@@ -2597,32 +2466,12 @@ static void unwatch_signals(pa_device_manager *dm) {
     dbus_connection_remove_filter(pa_dbus_connection_get(dm->dbus_conn), dbus_filter_device_detect_handler, dm);
 }
 
-static int _get_avail_mode(pa_tz_device *device) {
-    int avail_mode = 0;
-    char *type;
-
-    pa_assert(device);
-
-    type = pa_tz_device_get_type(device);
-    if (pa_streq(type, DEVICE_TYPE_BT) == false) {
-        pa_log_debug("Not BT device");
-        return 0;
-    }
-
-    if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_SCO))
-        avail_mode |= DM_DEVICE_BT_MODE_VOICE;
-    if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP))
-        avail_mode |= DM_DEVICE_BT_MODE_MEDIA;
-
-    return avail_mode;
-}
-
 static void send_device_connection_changed_signal(uint32_t event_id, pa_tz_device *device, bool connected, pa_device_manager *dm) {
     DBusMessage *signal_msg;
     DBusMessageIter msg_iter, device_iter;
     dbus_bool_t _connected = connected;
     dm_device_state_t compound_state;
-    dbus_int32_t device_id, direction, avail_mode;
+    dbus_int32_t device_id, direction;
     char *type, *name;
 
     pa_assert(device);
@@ -2638,17 +2487,15 @@ static void send_device_connection_changed_signal(uint32_t event_id, pa_tz_devic
     direction = (dbus_int32_t) pa_tz_device_get_direction(device);
     type = pa_tz_device_get_type(device);
     name = pa_tz_device_get_name(device);
-    avail_mode = _get_avail_mode(device);
     device_id = (dbus_int32_t) pa_tz_device_get_id(device);
     compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
 
-    simple_device_dump(PA_LOG_INFO, connected ? "[Connected]" : "[Disconnected]", device_id, type, name, direction, compound_state, avail_mode);
+    simple_device_dump(PA_LOG_INFO, connected ? "[Connected]" : "[Disconnected]", device_id, type, name, direction, compound_state);
 
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &device_id);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
-    dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
     pa_assert_se(dbus_message_iter_close_container(&msg_iter, &device_iter));
     dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_BOOLEAN, &_connected);
@@ -2662,7 +2509,7 @@ static void send_device_info_changed_signal(uint32_t event_id, pa_tz_device *dev
     DBusMessage *signal_msg;
     DBusMessageIter msg_iter, device_iter;
     dm_device_state_t compound_state;
-    dbus_int32_t device_id, direction, avail_mode;
+    dbus_int32_t device_id, direction;
     char *type, *name;
     const char *changed_prefix[] = {"[State Changed]", "[Direction Changed]", "[Avail-Mode Changed]"};
 
@@ -2681,15 +2528,13 @@ static void send_device_info_changed_signal(uint32_t event_id, pa_tz_device *dev
     name = pa_tz_device_get_name(device);
     device_id = (dbus_int32_t) pa_tz_device_get_id(device);
     compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
-    avail_mode = (dbus_int32_t) _get_avail_mode(device);
 
-    simple_device_dump(PA_LOG_DEBUG, changed_prefix[changed_type], device_id, type, name, direction, compound_state, avail_mode);
+    simple_device_dump(PA_LOG_DEBUG, changed_prefix[changed_type], device_id, type, name, direction, compound_state);
 
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &device_id);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
-    dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
     pa_assert_se(dbus_message_iter_close_container(&msg_iter, &device_iter));
     dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_INT32, &changed_type);
@@ -2814,7 +2659,7 @@ static void handle_get_connected_device_list(DBusConnection *conn, DBusMessage *
     pa_tz_device *device;
     dm_device_state_t compound_state;
     uint32_t device_idx;
-    dbus_int32_t device_id, direction, avail_mode;
+    dbus_int32_t device_id, direction;
     int mask;
     char *type, *name;
 
@@ -2834,28 +2679,26 @@ static void handle_get_connected_device_list(DBusConnection *conn, DBusMessage *
     pa_log_info("Get connected device list (mask : %d)", mask);
 
     dbus_message_iter_init_append(reply, &msg_iter);
-    pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiiis)", &array_iter));
+    pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiis)", &array_iter));
 
     PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
         compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
         direction = pa_tz_device_get_direction(device);
         type = pa_tz_device_get_type(device);
         name = pa_tz_device_get_name(device);
-        avail_mode = _get_avail_mode(device);
         if (device_is_match_with_mask(device,  mask)) {
             device_id = (dbus_int32_t)pa_tz_device_get_id(device);
 
-            simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, compound_state, avail_mode);
+            simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, compound_state);
             pa_assert_se(dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &device_iter));
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &device_id);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
-            dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
             pa_assert_se(dbus_message_iter_close_container(&array_iter, &device_iter));
         } else {
-            simple_device_dump(PA_LOG_INFO, "[UNMATCH]", device_id, type, name, direction, compound_state, avail_mode);
+            simple_device_dump(PA_LOG_INFO, "[UNMATCH]", device_id, type, name, direction, compound_state);
         }
     }
 
@@ -2884,11 +2727,9 @@ static void handle_get_bt_a2dp_status(DBusConnection *conn, DBusMessage *msg, vo
     pa_assert_se((reply = dbus_message_new_method_return(msg)));
 
     /* FIXME : Give system_id for multi device */
-    if ((device = _device_list_get_device(dm, DEVICE_TYPE_BT, NULL)) != NULL) {
-        if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP)) {
-            is_bt_on = true;
-            bt_name = pa_tz_device_get_name(device);
-        }
+    if ((device = _device_list_get_device(dm, DEVICE_TYPE_BT_A2DP, NULL)) != NULL) {
+        is_bt_on = true;
+        bt_name = pa_tz_device_get_name(device);
     }
 
     pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &is_bt_on,
@@ -2903,27 +2744,24 @@ static void handle_get_bt_a2dp_status(DBusConnection *conn, DBusMessage *msg, vo
 
 static void handle_load_sink(DBusConnection *conn, DBusMessage *msg, void *userdata) {
     pa_device_manager *dm;
-    char *type, *device_profile, *role;
+    char *type, *role;
     DBusMessage *reply = NULL;
 
     pa_assert_se((reply = dbus_message_new_method_return(msg)));
     dm = (pa_device_manager *) userdata;
     pa_assert_se(dbus_message_get_args(msg, NULL,
                                        DBUS_TYPE_STRING, &type,
-                                       DBUS_TYPE_STRING, &device_profile,
                                        DBUS_TYPE_STRING, &role,
                                        DBUS_TYPE_INVALID));
 
-    if (pa_streq(device_profile, "none"))
-        device_profile = NULL;
-    pa_device_manager_load_sink(dm, type, device_profile, role);
+    pa_device_manager_load_sink(dm, type, role);
     pa_assert_se(dbus_connection_send(conn, reply, NULL));
     dbus_message_unref(reply);
 }
 
 static void handle_test_device_status_change(DBusConnection *conn, DBusMessage *msg, void *userdata) {
     pa_device_manager *dm = (pa_device_manager *)userdata;
-    char *type, *device_profile;
+    char *type;
     dbus_int32_t status;
     DBusMessage *reply = NULL;
     DBusError error;
@@ -2933,7 +2771,6 @@ static void handle_test_device_status_change(DBusConnection *conn, DBusMessage *
     dbus_error_init(&error);
     if (!dbus_message_get_args(msg, NULL,
                                        DBUS_TYPE_STRING, &type,
-                                       DBUS_TYPE_STRING, &device_profile,
                                        DBUS_TYPE_INT32, &status,
                                        DBUS_TYPE_INVALID)) {
         pa_log_error("failed to get dbus args : %s", error.message);
@@ -2941,11 +2778,9 @@ static void handle_test_device_status_change(DBusConnection *conn, DBusMessage *
         dbus_error_free(&error);
     }
 
-    pa_log_debug("handle_test_device_status_change, type:%s, profile:%s, status:%d", type, device_profile, status);
-    if (pa_streq(device_profile, "none"))
-        device_profile = NULL;
+    pa_log_debug("handle_test_device_status_change, type:%s, status:%d", type, status);
 
-    handle_device_status_changed(dm, type, device_profile, NULL,  NULL, status);
+    handle_device_status_changed(dm, type, NULL,  NULL, status);
     pa_assert_se(dbus_connection_send(conn, reply, NULL));
     dbus_message_unref(reply);
 }
@@ -3136,7 +2971,7 @@ void pa_device_manager_unload_forwarding(pa_device_manager *dm) {
         pa_log_warn("There is no forwarding device");
 }
 
-int pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+int pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const char *role) {
     const char *device_string, *params;
     struct device_type_info *type_info;
     struct device_file_info *file_info;
@@ -3147,28 +2982,28 @@ int pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const c
     pa_assert(dm);
     pa_assert(dm->device_list);
 
-    pa_log_info("Load Sink for '%s.%s.%s'", type, device_profile, role);
+    pa_log_info("Load Sink for '%s.%s'", type, role);
     PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
         if (pa_streq(type, pa_tz_device_get_type(device))) {
-            if (pa_tz_device_profile_get_sink(device, device_profile, role) == NULL) {
-                pa_log_warn("Proper sink for '%s.%s.%s' already loaded", type, device_profile, role);
+            if (pa_tz_device_get_sink(device, role) == NULL) {
+                pa_log_warn("Proper sink for '%s.%s' already loaded", type, role);
                 return -1;
             }
         }
     }
 
-    if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile))) {
+    if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
         pa_log_error("No type map for %s", type);
         return -1;
     }
 
     if (type_info->playback_devices == NULL) {
-        pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
+        pa_log_error("No playback devices for %s", type_info->type);
         goto fail;
     }
 
     if (!(device_string = pa_hashmap_get(type_info->playback_devices, role))) {
-        pa_log_error("No device-string for '%s.%s.%s'", type, device_profile, role);
+        pa_log_error("No device-string for '%s.%s'", type, role);
         goto fail;
     }
 
@@ -3195,7 +3030,7 @@ fail:
     return -1;
 }
 
-int pa_device_manager_load_source(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+int pa_device_manager_load_source(pa_device_manager *dm, const char *type, const char *role) {
     const char *device_string, *params;
     struct device_type_info *type_info;
     struct device_file_info *file_info;
@@ -3205,29 +3040,29 @@ int pa_device_manager_load_source(pa_device_manager *dm, const char *type, const
 
     pa_assert(dm);
 
-    pa_log_info("Load Source for '%s.%s.%s'", type, device_profile, role);
+    pa_log_info("Load Source for '%s.%s'", type, role);
 
     PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
         if (pa_streq(type, pa_tz_device_get_type(device))) {
-            if (pa_tz_device_profile_get_source(device, device_profile, role) == NULL) {
-                pa_log_warn("Proper source for '%s.%s.%s' already loaded", type, device_profile, role);
+            if (pa_tz_device_get_source(device, role) == NULL) {
+                pa_log_warn("Proper source for '%s.%s' already loaded", type, role);
                 return -1;
             }
         }
     }
 
-    if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile))) {
+    if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
         pa_log_error("No type map for %s", type);
         return -1;
     }
 
     if (type_info->capture_devices == NULL) {
-        pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
+        pa_log_error("No capture devices for %s", type_info->type);
         goto fail;
     }
 
     if (!(device_string = pa_hashmap_get(type_info->capture_devices, role))) {
-        pa_log_error("No device-string for '%s.%s.%s'", type, device_profile, role);
+        pa_log_error("No device-string for '%s.%s'", type, role);
         goto fail;
     }
 
@@ -3259,12 +3094,6 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi
     return PA_HOOK_OK;
 }
 
-static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *data, pa_device_manager *dm) {
-    if (data->changed == PA_TZ_DEVICE_PROFILE_ADDED || data->changed == PA_TZ_DEVICE_PROFILE_REMOVED)
-        send_device_info_changed_signal(data->event_id, data->device, DM_DEVICE_CHANGED_INFO_BT_AVAIL_MODE, dm);
-    return PA_HOOK_OK;
-}
-
 static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_state_changed *data, pa_device_manager *dm) {
     send_device_info_changed_signal(data->event_id, data->device, DM_DEVICE_CHANGED_INFO_STATE, dm);
     return PA_HOOK_OK;
@@ -3297,8 +3126,6 @@ pa_device_manager* pa_device_manager_get(pa_core *c) {
     dm->comm = pa_communicator_get(dm->core);
     dm->comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
             PA_HOOK_EARLY, (pa_hook_cb_t)device_connection_changed_hook_cb, dm);
-    dm->comm_hook_device_profile_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
-            PA_HOOK_EARLY, (pa_hook_cb_t)device_profile_changed_hook_cb, dm);
     dm->comm_hook_device_state_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_STATE_CHANGED),
             PA_HOOK_EARLY, (pa_hook_cb_t)device_state_changed_hook_cb, dm);
     if (!(dm->type_infos = parse_device_type_infos())) {
@@ -3319,10 +3146,10 @@ pa_device_manager* pa_device_manager_get(pa_core *c) {
     }
 
     /* Just for convenience when test*/
-    if (!_device_manager_set_default_sink(dm,  DEVICE_TYPE_SPEAKER,  NULL, "normal")) {
+    if (!_device_manager_set_default_sink(dm,  DEVICE_TYPE_SPEAKER, "normal")) {
         pa_log_warn("Set default sink with speaker(normal) failed");
     }
-    if (!_device_manager_set_default_source(dm,  DEVICE_TYPE_MIC,  NULL, "normal")) {
+    if (!_device_manager_set_default_source(dm,  DEVICE_TYPE_MIC, "normal")) {
         pa_log_warn("Set default source with mic(normal) failed");
     }
 
@@ -3351,8 +3178,6 @@ void pa_device_manager_unref(pa_device_manager *dm) {
 
     if (dm->comm_hook_device_connection_changed_slot)
         pa_hook_slot_free(dm->comm_hook_device_connection_changed_slot);
-    if (dm->comm_hook_device_profile_changed_slot)
-        pa_hook_slot_free(dm->comm_hook_device_profile_changed_slot);
     if (dm->comm_hook_device_state_changed_slot)
         pa_hook_slot_free(dm->comm_hook_device_state_changed_slot);
     if (dm->sink_put_hook_slot)
index 12abeeb..1db9dc0 100644 (file)
@@ -49,7 +49,7 @@ pa_tz_device* pa_device_manager_load_forwarding(pa_device_manager *dm);
 void pa_device_manager_unload_forwarding(pa_device_manager *dm);
 
 /* load pulse device */
-int pa_device_manager_load_sink(pa_device_manager *dm, const char *device_type, const char *device_profile, const char *role);
-int pa_device_manager_load_source(pa_device_manager *dm, const char *device_type, const char *device_profile, const char *role);
+int pa_device_manager_load_sink(pa_device_manager *dm, const char *device_type, const char *role);
+int pa_device_manager_load_source(pa_device_manager *dm, const char *device_type, const char *role);
 
 #endif
index bb2b940..20c88f7 100644 (file)
@@ -108,7 +108,8 @@ typedef enum _device_type {
     DEVICE_BUILTIN_RECEIVER,
     DEVICE_BUILTIN_MIC,
     DEVICE_AUDIO_JACK,
-    DEVICE_BT,
+    DEVICE_BT_A2DP,
+    DEVICE_BT_SCO,
     DEVICE_HDMI,
     DEVICE_FORWARDING,
     DEVICE_USB_AUDIO,
@@ -134,8 +135,10 @@ static device_type_t convert_device_type_str(const char *device)
         return DEVICE_BUILTIN_MIC;
     else if (pa_streq(device, DEVICE_TYPE_AUDIO_JACK))
         return DEVICE_AUDIO_JACK;
-    else if (pa_streq(device, DEVICE_TYPE_BT))
-        return DEVICE_BT;
+    else if (pa_streq(device, DEVICE_TYPE_BT_A2DP))
+        return DEVICE_BT_A2DP;
+    else if (pa_streq(device, DEVICE_TYPE_BT_SCO))
+        return DEVICE_BT_SCO;
     else if (pa_streq(device, DEVICE_TYPE_HDMI))
         return DEVICE_HDMI;
     else if (pa_streq(device, DEVICE_TYPE_FORWARDING))
@@ -156,7 +159,6 @@ struct userdata {
         pa_hook_slot *comm_hook_select_proper_sink_or_source_slot;
         pa_hook_slot *comm_hook_change_route_slot;
         pa_hook_slot *comm_hook_device_connection_changed_slot;
-        pa_hook_slot *comm_hook_device_profile_changed_slot;
         pa_hook_slot *comm_hook_update_info_slot;
     } communicator;
 
@@ -232,11 +234,8 @@ static pa_tz_device* _get_sco_connected_device(pa_device_manager *dm) {
     device_list = pa_device_manager_get_device_list(dm);
 
     PA_IDXSET_FOREACH(device, device_list, device_idx) {
-        if (pa_streq(device->type, DEVICE_TYPE_BT)) {
-            /* FIXME : not works */
-            if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_SCO)) {
-                return device;
-            }
+        if (pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
+            return device;
         }
     }
     return NULL;
@@ -261,10 +260,6 @@ static int update_bt_sco_state(pa_device_manager *dm, bool open) {
         return -1;
     }
 
-    if (sco_status == DM_DEVICE_BT_SCO_STATUS_DISCONNECTED) {
-        pa_log_info("BT SCO is not available for this BT device");
-        return 0;
-    }
     if (open) {
         if (sco_status == DM_DEVICE_BT_SCO_STATUS_CONNECTED) {
             if (pa_tz_device_sco_open(bt_device) < 0) {
@@ -369,7 +364,10 @@ static bool skip_device(const char *stream_role, const char *device_type)
     if (pa_streq(device_type, DEVICE_TYPE_FORWARDING))
         return true;
 
-    if (pa_streq(device_type, DEVICE_TYPE_BT))
+    if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
+        return true;
+
+    if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
         return true;
 
     /* get sound profile */
@@ -403,7 +401,6 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
     uint32_t dm_device_id = 0;
     const char *device_type = NULL;
     const char *dm_device_type = NULL;
-    const char *dm_device_subtype = NULL;
     dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
     pa_tz_device *device = NULL;
     pa_tz_device *latest_device = NULL;
@@ -455,11 +452,10 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
                     continue;
                 PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
                     dm_device_id = pa_tz_device_get_id(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u]",
-                                 dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id);
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], id[%u]",
+                                 dm_device_type, dm_device_direction, dm_device_id);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         is_found = true;
                         pa_log_info("  ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
@@ -484,12 +480,11 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
                     continue;
                 PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
                     dm_device_id = pa_tz_device_get_id(device);
                     creation_time = pa_tz_device_get_creation_time(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u], creation_time[%llu]",
-                                 dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id, creation_time);
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]",
+                                 dm_device_type, dm_device_direction, dm_device_id, creation_time);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         if (!latest_device || (latest_creation_time <= creation_time)) {
                             latest_device = device;
@@ -518,10 +513,9 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
             PA_IDXSET_FOREACH(device_id, data->idx_manual_devices, m_idx) {
                 if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], device id[%u]",
-                            dm_device_type, dm_device_subtype, dm_device_direction, *device_id);
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], device id[%u]",
+                            dm_device_type, dm_device_direction, *device_id);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         pa_log_info("  ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction);
                         if (data->stream_type == STREAM_SINK_INPUT) {
@@ -548,10 +542,9 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
             PA_IDXSET_FOREACH(device_id, data->idx_manual_devices, m_idx) {
                 if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], device id[%u]",
-                            dm_device_type, dm_device_subtype, dm_device_direction, *device_id);
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], device id[%u]",
+                            dm_device_type, dm_device_direction, *device_id);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         pa_log_info("  ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction);
                         /* currently, we support two sinks for combining */
@@ -658,7 +651,6 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
     pa_tz_device *_device = NULL;
     pa_tz_device *latest_device = NULL;
     const char *dm_device_type = NULL;
-    const char *dm_device_subtype = NULL;
     dm_device_state_t dm_device_state = DM_DEVICE_STATE_DEACTIVATED;
     dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
     io_direction_t hal_direction;
@@ -744,11 +736,10 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                     continue;
                 PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
                     dm_device_id = pa_tz_device_get_id(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u]",
-                                 dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id);
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], id[%u]",
+                                 dm_device_type, dm_device_direction, dm_device_id);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         pa_log_debug("  ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
                         use_internal_codec = pa_tz_device_is_use_internal_codec(device);
@@ -871,13 +862,12 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                     continue;
                 PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
                     dm_device_type = pa_tz_device_get_type(device);
-                    dm_device_subtype = pa_tz_device_get_profile(device);
                     dm_device_direction = pa_tz_device_get_direction(device);
                     dm_device_id = pa_tz_device_get_id(device);
                     creation_time = pa_tz_device_get_creation_time(device);
-                    pa_log_debug("  -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u], creation_time[%llu]",
-                                 dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id, creation_time);
-                    if (pa_streq(device->type, DEVICE_TYPE_BT) && !pa_tz_device_have_profile(device, "a2dp"))
+                    pa_log_debug("  -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]",
+                                 dm_device_type, dm_device_direction, dm_device_id, creation_time);
+                    if (pa_streq(device->type, DEVICE_TYPE_BT_A2DP))
                         continue;
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         if (!latest_device || (latest_creation_time <= creation_time)) {
@@ -955,7 +945,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                 if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
                     /* FIXME : This is temparary code, until App could give
                      * proper BT-SCO device for call-voice */
-                    if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT)) {
+                    if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT_A2DP)) {
                         pa_tz_device *sco_device;
                         if ((sco_device = _get_sco_connected_device(u->device_manager)) == NULL) {
                             pa_log_error("  ** could not find BT SCO");
@@ -969,11 +959,10 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                     dm_device_type = pa_tz_device_get_type(device);
                     if (pa_streq(device_type, dm_device_type)) {
                         dm_device_direction = pa_tz_device_get_direction(device);
-                        dm_device_subtype = pa_tz_device_get_profile(device);
-                        pa_log_debug("  ** found a matched device: type[%-16s], subtype[%-5s], direction[0x%x]",
-                                     dm_device_type, dm_device_subtype, dm_device_direction);
+                        pa_log_debug("  ** found a matched device: type[%-16s], direction[0x%x]",
+                                     dm_device_type, dm_device_direction);
                         /* Check for BT SCO in case of call routing */
-                        if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT)) {
+                        if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
                             /* update BT SCO: open */
                             if (update_bt_sco_state(u->device_manager, true)) {
                                 pa_log_error("  ** could not open BT SCO");
@@ -1222,38 +1211,6 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi
     return PA_HOOK_OK;
 }
 
-/* Update connected device list when a device profile has been changed */
-static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, struct userdata *u) {
-    dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
-    int* ptr_in = NULL;
-    int* ptr_out = NULL;
-
-    pa_assert(c);
-    pa_assert(conn);
-    pa_assert(u);
-
-    device_direction = pa_tz_device_get_direction(conn->device);
-
-    pa_log_info("[CONN] device_profile_changed_hook_cb is called. conn(%p), changed(%d), device(%p), direction(0x%x)",
-                conn, conn->changed, conn->device, device_direction);
-
-    if (conn->changed == PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED)
-        if (pa_streq(pa_tz_device_get_type(conn->device), DEVICE_TYPE_BT)) {
-            /* In case of the bluetooth, we do not maintain a ref. count of the bluetooth devices.
-             * Because bluetooth framework supports only one device simultaneously for audio profile. */
-            ptr_in = &cached_connected_devices[convert_device_type_str(DEVICE_TYPE_BT)][CACHED_DEVICE_DIRECTION_IN];
-            ptr_out = &cached_connected_devices[convert_device_type_str(DEVICE_TYPE_BT)][CACHED_DEVICE_DIRECTION_OUT];
-            *ptr_in = *ptr_out = 0;
-            if (device_direction & DM_DEVICE_DIRECTION_IN)
-                *ptr_in = 1;
-            if (device_direction & DM_DEVICE_DIRECTION_OUT)
-                *ptr_out = 1;
-            dump_connected_devices();
-        }
-
-    return PA_HOOK_OK;
-}
-
 int pa__init(pa_module *m)
 {
     pa_modargs *ma = NULL;
@@ -1283,9 +1240,6 @@ int pa__init(pa_module *m)
         u->communicator.comm_hook_device_connection_changed_slot = pa_hook_connect(
                 pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
                 PA_HOOK_EARLY, (pa_hook_cb_t)device_connection_changed_hook_cb, u);
-        u->communicator.comm_hook_device_profile_changed_slot = pa_hook_connect(
-                pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
-                PA_HOOK_EARLY, (pa_hook_cb_t)device_profile_changed_hook_cb, u);
         u->communicator.comm_hook_update_info_slot = pa_hook_connect(
                 pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_UPDATE_INFORMATION),
                 PA_HOOK_EARLY, (pa_hook_cb_t)update_info_hook_cb, u);
@@ -1344,8 +1298,6 @@ void pa__done(pa_module *m)
             pa_hook_slot_free(u->communicator.comm_hook_change_route_slot);
         if (u->communicator.comm_hook_device_connection_changed_slot)
             pa_hook_slot_free(u->communicator.comm_hook_device_connection_changed_slot);
-        if (u->communicator.comm_hook_device_profile_changed_slot)
-            pa_hook_slot_free(u->communicator.comm_hook_device_profile_changed_slot);
         if (u->communicator.comm_hook_update_info_slot)
             pa_hook_slot_free(u->communicator.comm_hook_update_info_slot);
         pa_communicator_unref(u->communicator.comm);
index c47152e..ec71b6e 100644 (file)
@@ -141,7 +141,6 @@ struct _stream_manager {
     struct {
         pa_communicator *comm;
         pa_hook_slot *comm_hook_device_connection_changed_slot;
-        pa_hook_slot *comm_hook_device_profile_changed_slot;
         pa_hook_slot *comm_hook_event_fully_handled_slot;
     } comm;
 };
index 6111cea..1dfc829 100644 (file)
@@ -3183,10 +3183,7 @@ static void update_sink_or_source_as_device_change(stream_route_type_t stream_ro
                     }
                 } else if (!is_connected) {
                     /* DISCONNECTED: find a connected device that has the next priority */
-                    if ((sink && (sink == ((pa_sink_input*)s)->sink)) ||
-                      /* FIX ME: Although A2DP of BT device is off and it changes to SCO, sink from the device should be same as BT sink(for A2DP).
-                       * Because it does not work like that, new condition is added to avoid it temporarily. */
-                        (pa_safe_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq(pa_tz_device_get_profile(device), "sco"))) {
+                    if ((sink && (sink == ((pa_sink_input*)s)->sink))) {
                         find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
                         if (next_device) {
                             if ((next_sink = pa_tz_device_get_sink(next_device, DEVICE_ROLE_NORMAL))) {
@@ -3457,41 +3454,6 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi
     return PA_HOOK_OK;
 }
 
-/* Update connected device list when a device profile has been changed */
-static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, pa_stream_manager *m) {
-    dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
-    bool use_internal_codec = false;
-    bool bt_sink_available = false;
-
-    pa_assert(c);
-    pa_assert(conn);
-    pa_assert(m);
-
-    device_direction = pa_tz_device_get_direction(conn->device);
-    use_internal_codec = pa_tz_device_is_use_internal_codec(conn->device);
-
-    pa_log_info("[SM][CONN] device_profile_changed_hook_cb is called. conn(%p), changed(%d), device(%p), direction(0x%x), use_internal_codec(%d)",
-                conn, conn->changed, conn->device, device_direction, use_internal_codec);
-
-    if (conn->changed == PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED) {
-        if (pa_streq(pa_tz_device_get_type(conn->device), DEVICE_TYPE_BT)) {
-            pa_log_info("[SM][CONN] BT: active profile changed to [%s]", pa_tz_device_get_profile(conn->device));
-            if (use_internal_codec)
-                bt_sink_available = false; /* already bt device is connected and A2DP is newly deactivated, now SCO is only activated */
-            else
-                bt_sink_available = true;  /* already bt device is connected and A2DP is newly activated */
-        }
-        if (device_direction & DM_DEVICE_DIRECTION_OUT) {
-            update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO, m->core->sink_inputs,
-                                                   STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
-            update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED, m->core->sink_inputs,
-                                                   STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
-        }
-    }
-
-    return PA_HOOK_OK;
-}
-
 static void subscribe_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, pa_stream_manager *m) {
     pa_client *client = NULL;
     stream_parent *sp = NULL;
@@ -3691,8 +3653,6 @@ pa_stream_manager* pa_stream_manager_init(pa_core *c) {
     m->comm.comm = pa_communicator_get(c);
     m->comm.comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
             PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_connection_changed_hook_cb, m);
-    m->comm.comm_hook_device_profile_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
-            PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_profile_changed_hook_cb, m);
     m->comm.comm_hook_event_fully_handled_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_EVENT_FULLY_HANDLED),
             PA_HOOK_EARLY + 10, (pa_hook_cb_t)event_fully_handled_hook_cb, m);
 
index 9eb713c..43b9d48 100644 (file)
@@ -20,18 +20,11 @@ static inline bool pa_safe_streq2(const char *a, const char *b) {
     return false;
 }
 
-bool device_profile_is_equal(const char *device_profile1, const char *device_profile2) {
-    return pa_safe_streq2(device_profile1, device_profile2);
-}
-
-bool device_type_is_equal(const char *device_type1, const char *device_profile1, const char *device_type2, const char *device_profile2) {
+bool device_type_is_equal(const char *device_type1, const char *device_type2) {
     pa_assert(device_type1);
     pa_assert(device_type2);
 
-    if (pa_streq(device_type1, device_type2))
-        return device_profile_is_equal(device_profile1, device_profile2);
-    else
-        return false;
+    return pa_streq(device_type1, device_type2);
 }
 
 bool device_type_is_builtin(const char *device_type) {
@@ -58,7 +51,9 @@ bool device_type_is_valid(const char *device_type) {
         return true;
     else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK))
         return true;
-    else if (pa_streq(device_type, DEVICE_TYPE_BT))
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
+        return true;
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
         return true;
     else if (pa_streq(device_type, DEVICE_TYPE_HDMI))
         return true;
@@ -70,22 +65,12 @@ bool device_type_is_valid(const char *device_type) {
         return false;
 }
 
-bool device_type_is_use_external_card(const char *device_type, const char *profile) {
+bool device_type_is_use_external_card(const char *device_type) {
     if (!device_type)
         return false;
     else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO))
         return true;
-    else if ((pa_streq(device_type, DEVICE_TYPE_BT)) &&
-            profile && pa_streq(profile, DEVICE_PROFILE_BT_A2DP))
-        return true;
-    else
-        return false;
-}
-
-bool device_type_is_multi_profile(const char *device_type) {
-    if (!device_type)
-        return false;
-    else if (pa_streq(device_type, DEVICE_TYPE_BT))
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
         return true;
     else
         return false;
@@ -94,7 +79,9 @@ bool device_type_is_multi_profile(const char *device_type) {
 bool device_type_is_avail_multi_device(const char *device_type) {
     if (!device_type)
         return false;
-    else if (pa_streq(device_type, DEVICE_TYPE_BT))
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
+        return true;
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
         return true;
     else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO))
         return true;
@@ -102,7 +89,7 @@ bool device_type_is_avail_multi_device(const char *device_type) {
         return false;
 }
 
-bool device_type_is_need_detect(const char *type, const char *profile) {
+bool device_type_is_need_detect(const char *type) {
     if (!type)
         return false;
     else if (pa_streq(type, DEVICE_TYPE_AUDIO_JACK))
@@ -111,7 +98,7 @@ bool device_type_is_need_detect(const char *type, const char *profile) {
         return true;
     else if (pa_streq(type, DEVICE_TYPE_FORWARDING))
         return true;
-    else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT ,DEVICE_PROFILE_BT_SCO))
+    else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO))
         return true;
     else
         return false;
@@ -121,7 +108,7 @@ bool device_type_is_need_detect(const char *type, const char *profile) {
  * and other type(ex.audio-jack)'s direction varies with detected type,
  * and the other types(ex. bt-a2dp, usb-audio)'s direction is decided with
  * sink/source */
-dm_device_direction_t device_type_get_static_direction(const char *type, const char *profile) {
+dm_device_direction_t device_type_get_static_direction(const char *type) {
     if (!type)
         return DM_DEVICE_DIRECTION_NONE;
     else if (pa_streq(type, DEVICE_TYPE_SPEAKER))
@@ -130,7 +117,7 @@ dm_device_direction_t device_type_get_static_direction(const char *type, const c
         return DM_DEVICE_DIRECTION_OUT;
     else if (pa_streq(type, DEVICE_TYPE_MIC))
         return DM_DEVICE_DIRECTION_IN;
-    else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT ,DEVICE_PROFILE_BT_SCO))
+    else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO))
         return DM_DEVICE_DIRECTION_BOTH;
     else if (pa_streq(type, DEVICE_TYPE_HDMI))
         return DM_DEVICE_DIRECTION_OUT;
@@ -142,7 +129,7 @@ dm_device_direction_t device_type_get_static_direction(const char *type, const c
 
 /* Check whether 'direction' is valid for 'device_type'
  * This is static device-type availability, not for runtime checking */
-bool device_type_is_valid_direction(const char *device_type, const char *device_profile, dm_device_direction_t direction) {
+bool device_type_is_valid_direction(const char *device_type, dm_device_direction_t direction) {
     if (!device_type || direction == DM_DEVICE_DIRECTION_NONE)
         return false;
 
@@ -154,9 +141,9 @@ bool device_type_is_valid_direction(const char *device_type, const char *device_
         return direction == DM_DEVICE_DIRECTION_IN;
     else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK))
         return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_BOTH;
-    else if (pa_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq2(device_profile, DEVICE_PROFILE_BT_SCO))
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
         return direction == DM_DEVICE_DIRECTION_BOTH;
-    else if (pa_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq2(device_profile, DEVICE_PROFILE_BT_A2DP))
+    else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
         return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_IN;
     else if (pa_streq(device_type, DEVICE_TYPE_HDMI))
         return direction == DM_DEVICE_DIRECTION_OUT;
@@ -223,31 +210,3 @@ dm_device_direction_t device_direction_to_int(const char *device_direction) {
         return -1;
     }
 }
-
-int get_profile_priority(const char *device_profile) {
-    if (!device_profile) {
-        return 0;
-    } 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;
-    }
-}
-
-int compare_profile_priority(const char *device_profile1,  const char *device_profile2) {
-    int priority1, priority2;
-
-    priority1 = get_profile_priority(device_profile1);
-    priority2 = get_profile_priority(device_profile2);
-
-    if (priority1 > priority2) {
-        return 1;
-    } else if (priority1 == priority2) {
-        return 0;
-    } else {
-        return -1;
-    }
-}
-
index dedebdf..251d4cd 100644 (file)
@@ -8,16 +8,13 @@
 #define DEVICE_TYPE_RECEIVER                "builtin-receiver"
 #define DEVICE_TYPE_MIC                     "builtin-mic"
 #define DEVICE_TYPE_AUDIO_JACK              "audio-jack"
-#define DEVICE_TYPE_BT                      "bt"
+#define DEVICE_TYPE_BT_A2DP                 "bt-a2dp" /* match for SOUND_DEVICE_BLUETOOTH_MEDIA */
+#define DEVICE_TYPE_BT_SCO                  "bt-sco"  /* match for SOUND_DEVICE_BLUETOOTH_CALL */
 #define DEVICE_TYPE_HDMI                    "hdmi"
 #define DEVICE_TYPE_FORWARDING              "forwarding"
 #define DEVICE_TYPE_USB_AUDIO               "usb-audio"
 #define DEVICE_TYPE_NONE                    "none"
 
-#define PROFILE_NUM_MAX                     2
-#define DEVICE_PROFILE_BT_SCO               "sco"
-#define DEVICE_PROFILE_BT_A2DP              "a2dp"
-
 #define DEVICE_ROLE_NORMAL                  "normal"
 #define DEVICE_ROLE_CALL_VOICE              "call-voice"
 #define DEVICE_ROLE_CALL_VIDEO              "call-video"
@@ -39,7 +36,6 @@ typedef enum dm_device_state_type {
 } dm_device_state_t;
 
 typedef enum dm_device_bt_sco_status_type {
-    DM_DEVICE_BT_SCO_STATUS_DISCONNECTED = 0,
     DM_DEVICE_BT_SCO_STATUS_CONNECTED,
     DM_DEVICE_BT_SCO_STATUS_OPENED
 } dm_device_bt_sco_status_t;
@@ -49,17 +45,15 @@ typedef enum dm_device_bt_sco_status_type {
     for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)))
 
 bool device_type_is_builtin(const char *device_type);
-bool device_type_is_use_external_card(const char *device_type, const char *device_profile);
+bool device_type_is_use_external_card(const char *device_type);
 bool device_type_is_valid(const char *device_type);
-bool device_type_is_valid_direction(const char *device_type, const char *device_profile, dm_device_direction_t direction);
-bool device_type_is_multi_profile(const char *device_type);
+bool device_type_is_valid_direction(const char *device_type, dm_device_direction_t direction);
 bool device_type_is_avail_multi_device(const char *device_type);
-bool device_type_is_need_detect(const char *type, const char *profile);
-dm_device_direction_t device_type_get_static_direction(const char *type, const char *profile);
+bool device_type_is_need_detect(const char *type);
+dm_device_direction_t device_type_get_static_direction(const char *type);
 const char* device_direction_to_string(dm_device_direction_t direction);
 bool device_role_is_valid(const char *device_role);
 dm_device_direction_t device_direction_to_int(const char *device_direction);
-bool device_profile_is_equal(const char *device_profile1, const char *device_profile2);
-bool device_type_is_equal(const char *device_type1, const char *device_profile1, const char *device_type2, const char *device_profile2);
+bool device_type_is_equal(const char *device_type1, const char *device_type2);
 
 #endif
index 26446a3..861a5e3 100644 (file)
@@ -19,7 +19,7 @@
 #define BT_CVSD_CODEC_ID 1 // narrow-band
 #define BT_MSBC_CODEC_ID 2 // wide-band
 
-#define COMPOUND_STATE(d) (((pa_tz_profile*)d)->playback_state | ((pa_tz_profile*)d)->capture_state)
+#define COMPOUND_STATE(d) (((pa_tz_device*)d)->playback_state | ((pa_tz_device*)d)->capture_state)
 
 int device_id_max_g = 1;
 uint32_t event_id_max_g = 1;
@@ -62,22 +62,26 @@ static char* get_capture_list_str(pa_hashmap *capture_devices) {
     return pa_strbuf_tostring_free(buf);
 }
 
-/* Returned string must be freed */
-static char* get_device_profile_info_str(pa_tz_profile *profile) {
+static char* _device_get_info_str(pa_tz_device *device) {
     pa_strbuf *buf;
     char *playback_str, *capture_str;
-    if (!profile)
+
+    if (!device)
         return NULL;
 
     buf = pa_strbuf_new();
-    pa_strbuf_printf(buf, "    Profile      : %s\n", pa_strna(profile->profile));
-    pa_strbuf_printf(buf, "    Direction    : %s\n", device_direction_to_string(profile->direction));
-    pa_strbuf_printf(buf, "    Is activated : %s\n", pa_yes_no(COMPOUND_STATE(profile) == DM_DEVICE_STATE_ACTIVATED));
-    pa_strbuf_printf(buf, "    Internal     : %s\n", pa_yes_no(profile->use_internal_codec));
-    if (profile->profile && pa_streq(profile->profile, DEVICE_PROFILE_BT_SCO))
-        pa_strbuf_printf(buf, "    SCO opened   : %s\n", pa_yes_no(profile->sco_opened));
-    playback_str = get_playback_list_str(profile->playback_devices);
-    capture_str = get_capture_list_str(profile->capture_devices);
+    pa_strbuf_printf(buf, "[Device #%u]\n", device->id);
+    pa_strbuf_printf(buf, "  ID           : %u\n", device->id);
+    pa_strbuf_printf(buf, "  Type         : %s\n", device->type);
+    pa_strbuf_printf(buf, "  Name         : %s\n", device->name);
+    pa_strbuf_printf(buf, "  System ID    : %s\n", device->system_id);
+    pa_strbuf_printf(buf, "  Direction    : %s\n", device_direction_to_string(device->direction));
+    pa_strbuf_printf(buf, "  Is activated : %s\n", pa_yes_no(COMPOUND_STATE(device) == DM_DEVICE_STATE_ACTIVATED));
+    pa_strbuf_printf(buf, "  Internal     : %s\n", pa_yes_no(device->use_internal_codec));
+    if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO))
+        pa_strbuf_printf(buf, "    SCO opened   : %s\n", pa_yes_no(device->sco_opened));
+    playback_str = get_playback_list_str(device->playback_devices);
+    capture_str = get_capture_list_str(device->capture_devices);
 
     if (playback_str)
         pa_strbuf_puts(buf, playback_str);
@@ -90,35 +94,6 @@ static char* get_device_profile_info_str(pa_tz_profile *profile) {
     return pa_strbuf_tostring_free(buf);
 }
 
-static char* _device_get_info_str(pa_tz_device *device) {
-    pa_strbuf *buf;
-    char *profile_info;
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-
-    if (!device)
-        return NULL;
-
-    buf = pa_strbuf_new();
-    pa_strbuf_printf(buf, "[Device #%u]\n", device->id);
-    pa_strbuf_printf(buf, "  ID             : %u\n", device->id);
-    pa_strbuf_printf(buf, "  Type           : %s\n", device->type);
-    pa_strbuf_printf(buf, "  Name           : %s\n", device->name);
-    if (device_type_is_multi_profile(device->type))
-        pa_strbuf_printf(buf, "  System ID      : %s\n", device->system_id);
-    pa_strbuf_printf(buf, "  Active Profile : %u\n", device->active_profile);
-
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
-        pa_strbuf_printf(buf, "  (Profile #%d)\n", profile_idx);
-        profile_info = get_device_profile_info_str(profile);
-        if (profile_info)
-            pa_strbuf_puts(buf, profile_info);
-        pa_xfree(profile_info);
-    }
-
-    return pa_strbuf_tostring_free(buf);
-}
-
 
 void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level) {
     char *info;
@@ -144,20 +119,6 @@ static void notify_device_connection_changed(pa_tz_device *device, bool connecte
     pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED), &hook_data);
 }
 
-static void notify_device_profile_changed(pa_tz_device *device, pa_tz_device_profile_changed_t changed_type) {
-    pa_tz_device_hook_data_for_profile_changed hook_data;
-    const char* changed_type_str[PA_TZ_DEVICE_PROFILE_CHANGED_MAX] =
-        {"Profile Added", "Profile Removed", "Active-profile Changed"};
-
-    hook_data.event_id = _new_event_id();
-    hook_data.changed = changed_type;
-    hook_data.device = device;
-
-    pa_log_info("Fire hook for device profile changed, device(%s/%u) %s",
-            device->type, device->id, changed_type_str[changed_type]);
-    pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED), &hook_data);
-}
-
 static void notify_device_state_changed(pa_tz_device *device, dm_device_state_t state) {
     pa_tz_device_hook_data_for_state_changed hook_data;
 
@@ -188,8 +149,6 @@ void pa_tz_device_new_data_init(pa_tz_device_new_data *data, pa_idxset *list,
 
     data->playback_pcms= pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
     data->capture_pcms = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-
-    data->n_profile = 0;
 }
 
 void pa_tz_device_new_data_set_type(pa_tz_device_new_data *data, const char *type) {
@@ -233,18 +192,6 @@ void pa_tz_device_new_data_add_source(pa_tz_device_new_data *data, const char *r
 
     pa_hashmap_put(data->capture_pcms, (void*)role, source);
 }
-/* after set_type, only for multi profile type, and check direction, profile */
-void pa_tz_device_new_data_add_profile(pa_tz_device_new_data *data, pa_tz_profile_new_data *profile_data, bool as_active) {
-    uint32_t profile_idx;
-    pa_assert(data);
-
-    profile_idx = data->n_profile;
-    data->profile_data[profile_idx] = profile_data;
-    if (as_active)
-        data->active_profile = profile_idx;
-
-    data->n_profile++;
-}
 
 void pa_tz_device_new_data_done(pa_tz_device_new_data *data) {
     pa_assert(data);
@@ -254,7 +201,6 @@ void pa_tz_device_new_data_done(pa_tz_device_new_data *data) {
 }
 
 static int _check_valid_device_new_data(pa_tz_device_new_data *data) {
-    bool is_multi_profile;
     pa_assert(data);
 
     if (data->type == NULL) {
@@ -262,90 +208,42 @@ static int _check_valid_device_new_data(pa_tz_device_new_data *data) {
         return -1;
     }
 
-    is_multi_profile = device_type_is_multi_profile(data->type);
-
-    if (is_multi_profile == false && data->direction == DM_DEVICE_DIRECTION_NONE) {
+    if (data->direction == DM_DEVICE_DIRECTION_NONE) {
         pa_log_error("new data direction is none");
         return -1;
     }
 
-    if (is_multi_profile == true && data->n_profile == 0) {
-        pa_log_error("multi profile type, but there is no profile");
-        return -1;
-    }
-    if (is_multi_profile == false && data->n_profile > 0) {
-        pa_log_error("not multi profile type, but there are profile");
-        return -1;
-    }
-
     return 0;
 }
 
-static pa_tz_profile* profile_new(char *profile_str, dm_device_direction_t direction,
-        pa_hashmap *playbacks, pa_hashmap *captures, bool use_internal_codec, pa_tz_device *device) {
-    pa_tz_profile *profile;
-
-    pa_log_info("New profile(%s) direction(%s), for device(%u)",
-            pa_strempty(profile_str), device_direction_to_string(direction), device->id);
-
-    profile = pa_xmalloc(sizeof(pa_tz_profile));
-
-    profile->profile = pa_xstrdup(profile_str);
-    profile->playback_devices = playbacks;
-    profile->capture_devices = captures;
-    profile->direction = direction;
-    profile->playback_state = DM_DEVICE_STATE_DEACTIVATED;
-    profile->capture_state = DM_DEVICE_STATE_DEACTIVATED;
-    profile->device = device;
-    profile->creation_time = pa_rtclock_now();
-    profile->use_internal_codec = use_internal_codec;
-    profile->sco_opened = false;
-
-    return profile;
-}
-
-static void profile_free(pa_tz_profile *profile) {
-    if (!profile)
-        return;
-
-    pa_log_info("Free profile(%s) for device(%u)",
-            pa_strempty(profile->profile), profile->device->id);
-
-    pa_xfree(profile->profile);
-
-    if (profile->playback_devices)
-        pa_hashmap_free(profile->playback_devices);
-    if (profile->capture_devices)
-        pa_hashmap_free(profile->capture_devices);
-
-    pa_xfree(profile);
-}
-
-static int profile_add_sink(pa_tz_profile *profile, const char *role, pa_sink *sink) {
-    pa_assert(profile);
+static int device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink) {
+    pa_assert(device);
+    pa_assert(device->playback_devices);
 
-    if (pa_hashmap_put(profile->playback_devices, (void*)role, sink) < 0) {
+    if (pa_hashmap_put(device->playback_devices, (void*)role, sink) < 0) {
         pa_log_error("Failed to add sink : put sink failed");
         return -1;
     }
     return 0;
 }
 
-static int profile_add_source(pa_tz_profile *profile, const char *role, pa_source *source) {
-    pa_assert(profile);
+static int device_add_source(pa_tz_device *device, const char *role, pa_source *source) {
+    pa_assert(device);
+    pa_assert(device->capture_devices);
 
-    if (pa_hashmap_put(profile->capture_devices, (void*)role, source) < 0) {
+    if (pa_hashmap_put(device->capture_devices, (void*)role, source) < 0) {
         pa_log_error("Failed to add source : put source failed");
         return -1;
     }
     return 0;
 }
 
-static pa_sink* profile_get_sink(pa_tz_profile *profile, const char *role) {
+static pa_sink* device_get_sink(pa_tz_device *device, const char *role) {
     pa_sink *sink;
-    pa_assert(profile);
+    pa_assert(device);
+    pa_assert(device->playback_devices);
 
-    if ((sink = pa_hashmap_get(profile->playback_devices, role)) == NULL) {
+    if ((sink = pa_hashmap_get(device->playback_devices, role)) == NULL) {
         pa_log_warn("Failed to get sink for %s", role);
         return NULL;
     }
@@ -353,11 +251,12 @@ static pa_sink* profile_get_sink(pa_tz_profile *profile, const char *role) {
     return sink;
 }
 
-static pa_source* profile_get_source(pa_tz_profile *profile, const char *role) {
+static pa_source* device_get_source(pa_tz_device *device, const char *role) {
     pa_source *source;
-    pa_assert(profile);
+    pa_assert(device);
+    pa_assert(device->capture_devices);
 
-    if ((source = pa_hashmap_get(profile->capture_devices, role)) == NULL) {
+    if ((source = pa_hashmap_get(device->capture_devices, role)) == NULL) {
         pa_log_warn("Failed to get source for %s", role);
         return NULL;
     }
@@ -365,79 +264,79 @@ static pa_source* profile_get_source(pa_tz_profile *profile, const char *role) {
     return source;
 }
 
-static void profile_set_state(pa_tz_profile *profile, dm_device_direction_t direction, dm_device_state_t state) {
+static void device_set_state(pa_tz_device *device, dm_device_direction_t direction, dm_device_state_t state) {
     dm_device_state_t prev_state, new_state;
-    pa_assert(profile);
+    pa_assert(device);
 
-    prev_state = COMPOUND_STATE(profile);
-    pa_log_debug("previous playback_state : %d, capture_state : %d => state %d", profile->playback_state, profile->capture_state, prev_state);
+    prev_state = COMPOUND_STATE(device);
+    pa_log_debug("previous playback_state : %d, capture_state : %d => state %d", device->playback_state, device->capture_state, prev_state);
     if (direction & DM_DEVICE_DIRECTION_IN)
-        profile->capture_state = state;
+        device->capture_state = state;
     if (direction & DM_DEVICE_DIRECTION_OUT)
-        profile->playback_state = state;
-    new_state = COMPOUND_STATE(profile);
-    pa_log_debug("new playback_state : %d, capture_state : %d => state %d", profile->playback_state, profile->capture_state, new_state);
+        device->playback_state = state;
+    new_state = COMPOUND_STATE(device);
+    pa_log_debug("new playback_state : %d, capture_state : %d => state %d", device->playback_state, device->capture_state, new_state);
 
     if (prev_state != new_state) {
-        notify_device_state_changed(profile->device, new_state);
-        pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+        notify_device_state_changed(device, new_state);
+        pa_tz_device_dump_info(device, PA_LOG_DEBUG);
     }
 }
 
-static dm_device_state_t profile_get_state(pa_tz_profile *profile, dm_device_direction_t direction) {
-    pa_assert(profile);
+static dm_device_state_t device_get_state(pa_tz_device *device, dm_device_direction_t direction) {
+    pa_assert(device);
 
     if (direction == DM_DEVICE_DIRECTION_BOTH)
-        return COMPOUND_STATE(profile);
+        return COMPOUND_STATE(device);
     else if (direction == DM_DEVICE_DIRECTION_OUT)
-        return profile->playback_state;
+        return device->playback_state;
     else if (direction == DM_DEVICE_DIRECTION_IN)
-        return profile->capture_state;
+        return device->capture_state;
     else
         return DM_DEVICE_STATE_DEACTIVATED;
 }
 
-static int profile_remove_sink_with_role(pa_tz_profile *profile, const char *role) {
+static int device_remove_sink_with_role(pa_tz_device *device, const char *role) {
     pa_sink *sink;
-    pa_assert(profile);
+    pa_assert(device);
 
-    sink = pa_hashmap_remove(profile->playback_devices, role);
+    sink = pa_hashmap_remove(device->playback_devices, role);
     return sink ? 0 : -1;
 }
 
-static int profile_remove_source_with_role(pa_tz_profile *profile, const char *role) {
+static int device_remove_source_with_role(pa_tz_device *device, const char *role) {
     pa_source *source;
-    pa_assert(profile);
+    pa_assert(device);
 
-    source = pa_hashmap_remove(profile->capture_devices, role);
+    source = pa_hashmap_remove(device->capture_devices, role);
     return source ? 0 : -1;
 }
 
-static int profile_remove_sink(pa_tz_profile *profile, pa_sink *sink) {
+static int device_remove_sink(pa_tz_device *device, pa_sink *sink) {
     pa_sink *_sink;
     void *state;
     char *role;
 
-    pa_assert(profile);
+    pa_assert(device);
 
-    PA_HASHMAP_FOREACH_KEY(_sink, profile->playback_devices, state, role) {
+    PA_HASHMAP_FOREACH_KEY(_sink, device->playback_devices, state, role) {
         if (sink == _sink)
-            return profile_remove_sink_with_role(profile, role);
+            return device_remove_sink_with_role(device, role);
     }
 
     return -1;
 }
 
-static int profile_remove_source(pa_tz_profile *profile, pa_source *source) {
+static int device_remove_source(pa_tz_device *device, pa_source *source) {
     pa_source *_source;
     void *state;
     char *role;
 
-    pa_assert(profile);
+    pa_assert(device);
 
-    PA_HASHMAP_FOREACH_KEY(_source, profile->capture_devices, state, role) {
+    PA_HASHMAP_FOREACH_KEY(_source, device->capture_devices, state, role) {
         if (source == _source)
-            return profile_remove_source_with_role(profile, role);
+            return device_remove_source_with_role(device, role);
     }
 
     return -1;
@@ -448,8 +347,6 @@ pa_tz_device* pa_tz_device_new(pa_tz_device_new_data *data) {
     pa_tz_device *device;
     pa_sink *sink;
     pa_source *source;
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
 
     pa_assert(data);
 
@@ -470,36 +367,24 @@ pa_tz_device* pa_tz_device_new(pa_tz_device_new_data *data) {
     else
         device->name = pa_xstrdup(data->type);
     device->system_id = pa_xstrdup(data->system_id);
-    device->active_profile = 0;
 
     pa_log_info("New device type(%s) id(%u) name(%s) system_id(%s)",
             device->type, device->id, device->name, pa_strempty(device->system_id));
 
-    device->profiles = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+    device->playback_devices = data->playback_pcms;
+    device->capture_devices = data->capture_pcms;
+    device->direction = data->direction;
+    device->playback_state = DM_DEVICE_STATE_DEACTIVATED;
+    device->capture_state = DM_DEVICE_STATE_DEACTIVATED;
+    device->creation_time = pa_rtclock_now();
+    device->use_internal_codec = data->use_internal_codec;
+    device->sco_opened = false;
 
-    /* If multi profile type, get from data->profile_data */
-    if (device_type_is_multi_profile(data->type)) {
-        pa_tz_profile_new_data *pdata;
-        for (int i = 0; i < data->n_profile; i++) {
-            pdata = data->profile_data[i];
-            profile = profile_new(pdata->profile, pdata->direction,
-                    pdata->playback_pcms, pdata->capture_pcms, pdata->use_internal_codec, device);
-            pa_idxset_put(device->profiles, profile, NULL);
-        }
-        device->active_profile = data->active_profile;
-    } else {
-        profile = profile_new(NULL, data->direction,
-                data->playback_pcms, data->capture_pcms, data->use_internal_codec, device);
-        pa_idxset_put(device->profiles, profile, NULL);
-    }
-
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
-        if (device_type_is_use_external_card(device->type, profile->profile)) {
-            if ((sink = profile_get_sink(profile, DEVICE_ROLE_NORMAL)))
-                sink->device_item = device;
-            if ((source = profile_get_source(profile, DEVICE_ROLE_NORMAL)))
-                source->device_item = device;
-        }
+    if (device_type_is_use_external_card(device->type)) {
+        if ((sink = device_get_sink(device, DEVICE_ROLE_NORMAL)))
+            sink->device_item = device;
+        if ((source = device_get_source(device, DEVICE_ROLE_NORMAL)))
+            source->device_item = device;
     }
 
     pa_idxset_put(device->list, device, NULL);
@@ -510,169 +395,7 @@ pa_tz_device* pa_tz_device_new(pa_tz_device_new_data *data) {
     return device;
 }
 
-static uint32_t _get_profile_idx(pa_tz_device *device, const char *profile_str) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-
-    pa_assert(device);
-    pa_assert(device->profiles);
-
-    if (profile_str == NULL || pa_streq(profile_str, "")) {
-        pa_idxset_first(device->profiles, &profile_idx);
-        return profile_idx;
-    }
-
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
-        if (device_profile_is_equal(profile->profile, profile_str))
-            return profile_idx;
-    }
-
-    return PA_INVALID_INDEX;
-}
-
-static pa_tz_profile* _get_profile(pa_tz_device *device, const char *profile_str) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-
-    pa_assert(device);
-    pa_assert(device->profiles);
-
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
-        if (device_profile_is_equal(profile->profile, profile_str))
-            return profile;
-    }
-
-    return NULL;
-}
-
-static pa_tz_profile* _get_profile_by_idx(pa_tz_device *device, uint32_t profile_idx) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    profile = pa_idxset_get_by_index(device->profiles, profile_idx);
-    if (profile == NULL)
-        pa_log_error("No profile(%u) in device(%u)", profile_idx, device->id);
-
-    return profile;
-}
-
-
-static pa_tz_profile* _get_active_profile(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    profile = _get_profile_by_idx(device, device->active_profile);
-    if (profile == NULL)
-        pa_log_error("Failed to find active profile(%u)", device->active_profile);
-
-    return profile;
-}
-
-/* if profile is null, set first profile as active */
-int _set_active_profile(pa_tz_device *device, const char *profile, bool noti) {
-    uint32_t profile_idx, prev_active_idx;
-
-    pa_assert(device);
-
-    pa_log_info("Set active profile, device(%u) profile(%s)",
-            device->id, pa_strempty(profile));
-
-    prev_active_idx = device->active_profile;
-    profile_idx = _get_profile_idx(device, profile);
-    if (profile_idx == PA_INVALID_INDEX) {
-        pa_log_error("index for profile(%s) is invalid", pa_strempty(profile));
-        return -1;
-    }
-    device->active_profile = profile_idx;
-    pa_log_info("active profile index: prev(%u) -> new(%u)", prev_active_idx, profile_idx);
-
-    if (noti)
-        notify_device_profile_changed(device, PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED);
-
-    return 0;
-}
-
-/* only for multi profile type */
-int pa_tz_device_add_profile(pa_tz_device *device, pa_tz_profile_new_data *pdata, bool as_active) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-    pa_assert(device->profiles);
-
-    pa_log_info("device add profile, device(%u) profile(%s) as_active(%s)",
-            device->id, pa_strempty(pdata->profile), pa_yes_no(as_active));
-
-    if (device_type_is_multi_profile(device->type) == false) {
-        pa_log_error("Failed to add profile : not multi profile type");
-        return -1;
-    }
-    if (pa_idxset_size(device->profiles) >= PROFILE_NUM_MAX) {
-        pa_log_error("Failed to add profile : Too many profiles");
-        return -1;
-    }
-
-    profile = profile_new(pdata->profile, pdata->direction,
-            pdata->playback_pcms, pdata->capture_pcms, pdata->use_internal_codec, device);
-    pa_idxset_put(device->profiles, profile, NULL);
-
-    if (as_active)
-        _set_active_profile(device, pdata->profile, true);
-    notify_device_profile_changed(device, PA_TZ_DEVICE_PROFILE_ADDED);
-    pa_tz_device_dump_info(device, PA_LOG_INFO);
-
-    return 0;
-}
-
-int pa_tz_device_remove_profile(pa_tz_device *device, const char *profile_str) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx, remove_idx;
-    bool found = false;
-    unsigned profile_num;
-
-    pa_assert(device);
-    pa_assert(device->profiles);
-
-    pa_log_info("device remove profile, device(%u) profile(%s)",
-            device->id, pa_strempty(profile_str));
-
-    if (device_type_is_multi_profile(device->type) == false) {
-        pa_log_error("Failed to add profile : not multi profile type");
-        return -1;
-    }
-
-    if ((profile_num = pa_tz_device_get_profile_num(device)) <= 1) {
-        pa_log_error("This device have too small profiles %u, Should be freed", profile_num);
-        return -1;
-    }
-
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
-        if (pa_safe_streq(profile->profile, profile_str)) {
-            pa_log_info("found matching profile to remove");
-            found = true;
-            remove_idx = profile_idx;
-        }
-    }
-
-    if (found) {
-        pa_idxset_remove_by_index(device->profiles, remove_idx);
-        /* change active profile if removed one was active */
-        if (device->active_profile == remove_idx)
-            _set_active_profile(device, NULL, true);
-        notify_device_profile_changed(device, PA_TZ_DEVICE_PROFILE_REMOVED);
-        pa_tz_device_dump_info(device, PA_LOG_INFO);
-        return 0;
-    } else {
-        pa_log_warn("no matching profile to remove");
-        return -1;
-    }
-}
-
-/* only for single profile type */
 int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
     pa_assert(device_role_is_valid(role));
     pa_assert(sink);
@@ -680,15 +403,8 @@ int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink)
     pa_log_info("device add sink, device(%u) role(%s) sink(%s)",
             device->id, role, sink->name);
 
-    if (pa_tz_device_get_profile_num(device) > 1) {
-        pa_log_error("Failed to add sink : Too many profiles");
-        return -1;
-    }
-
-    profile = pa_idxset_first(device->profiles, NULL);
-
-    if (profile_add_sink(profile, role, sink) < 0) {
-        pa_log_error("Failed to add sink : Can't add to profile");
+    if (device_add_sink(device, role, sink) < 0) {
+        pa_log_error("Failed to add sink : Can't add to device");
         return -1;
     }
 
@@ -696,8 +412,6 @@ int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink)
 }
 
 int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *source) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
     pa_assert(device_role_is_valid(role));
     pa_assert(source);
@@ -705,15 +419,8 @@ int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *s
     pa_log_info("device add source, device(%u) role(%s) source(%s)",
             device->id, role, source->name);
 
-    if (pa_tz_device_get_profile_num(device) > 1) {
-        pa_log_warn("Failed to add source : Too many profiles");
-        return -1;
-    }
-
-    profile = pa_idxset_first(device->profiles, NULL);
-
-    if (profile_add_source(profile, role, source) < 0) {
-        pa_log_error("Failed to add source : Can't add to profile");
+    if (device_add_source(device, role, source) < 0) {
+        pa_log_error("Failed to add source : Can't add to device");
         return -1;
     }
 
@@ -721,244 +428,43 @@ int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *s
 }
 
 int pa_tz_device_remove_sink(pa_tz_device *device, pa_sink *sink) {
-    pa_tz_profile *profile;
-    int removed = 0;
-    uint32_t profile_idx;
-
     pa_assert(device);
     pa_assert(sink);
 
     pa_log_info("device remove sink, device(%u) sink(%s)",
             device->id, sink->name);
 
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
-        removed &= profile_remove_sink(profile, sink);
-
-    return removed;
+    return device_remove_sink(device, sink);
 }
 
 int pa_tz_device_remove_source(pa_tz_device *device, pa_source *source) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-    int removed = 0;
-
     pa_assert(device);
     pa_assert(source);
 
     pa_log_info("device remove source, device(%u) source(%s)",
             device->id, source->name);
 
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
-        removed &= profile_remove_source(profile, source);
-
-    return removed;
+    return device_remove_source(device, source);
 }
 
 int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-    int removed = 0;
-
     pa_assert(device);
     pa_assert(device_role_is_valid(role));
 
     pa_log_info("device remove sink with role, device(%u) role(%s)",
             device->id, role);
 
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
-        removed &= profile_remove_sink_with_role(profile, role);
-
-    return removed;
+    return device_remove_sink_with_role(device, role);
 }
 
 int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role) {
-    pa_tz_profile *profile;
-    uint32_t profile_idx;
-    int removed = 0;
-
     pa_assert(device);
     pa_assert(device_role_is_valid(role));
 
     pa_log_info("device remove source with role, device(%u) role(%s)",
             device->id, role);
 
-    PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
-        removed &= profile_remove_source_with_role(profile, role);
-
-    return removed;
-}
-
-/* only for multi profile */
-int pa_tz_device_profile_add_sink(pa_tz_device *device, const char *profile_str, const char *role, pa_sink *sink) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile add sink, device(%u) profile(%s) role(%s) sink(%s)",
-            device->id, pa_strempty(profile_str), role, sink->name);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_add_sink(profile, role, sink) < 0) {
-        pa_log_error("Can't add to profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-int pa_tz_device_profile_add_source(pa_tz_device *device, const char *profile_str, const char *role, pa_source *source) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile add source, device(%u) profile(%s) role(%s) source(%s)",
-            device->id, pa_strempty(profile_str), role, source->name);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_add_source(profile, role, source) < 0) {
-        pa_log_error("Can't add to profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-int pa_tz_device_profile_remove_sink(pa_tz_device *device, const char *profile_str, pa_sink *sink) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile remove sink, device(%u) profile(%s) sink(%s)",
-            device->id, pa_strempty(profile_str), sink->name);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_remove_sink(profile, sink) < 0) {
-        pa_log_error("Can't remove from profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-int pa_tz_device_profile_remove_source(pa_tz_device *device, const char *profile_str, pa_source *source) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile remove source, device(%u) profile(%s) source(%s)",
-            device->id, pa_strempty(profile_str), source->name);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_remove_source(profile, source) < 0) {
-        pa_log_error("Can't remove from profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-int pa_tz_device_profile_remove_sink_with_role(pa_tz_device *device, const char *profile_str, const char *role) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-    pa_assert(device_role_is_valid(role));
-
-    pa_log_info("device profile remove sink with role, device(%u) profile(%s) role(%s)",
-            device->id, pa_strempty(profile_str), role);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_remove_sink_with_role(profile, role) < 0) {
-        pa_log_error("Can't remove from profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-int pa_tz_device_profile_remove_source_with_role(pa_tz_device *device, const char *profile_str, const char *role) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-    pa_assert(device_role_is_valid(role));
-
-    pa_log_info("device profile remove source with role, device(%u) profile(%s) role(%s)",
-            device->id, pa_strempty(profile_str), role);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return -1;
-    }
-
-    if (profile_remove_source_with_role(profile, role) < 0) {
-        pa_log_error("Can't remove from profile");
-        return -1;
-    }
-
-    return 0;
-}
-
-pa_sink* pa_tz_device_profile_get_sink(pa_tz_device *device, const char *profile_str, const char *role) {
-    pa_sink *sink;
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile get sink, device(%u) profile(%s) role(%s)",
-            device->id, pa_strempty(profile_str), role);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return NULL;
-    }
-
-    if ((sink = profile_get_sink(profile, role)) == NULL) {
-        pa_log_error("Can't get sink from profile");
-        return NULL;
-    }
-
-    return sink;
-}
-
-pa_source* pa_tz_device_profile_get_source(pa_tz_device *device, const char *profile_str, const char *role) {
-    pa_source *source;
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-
-    pa_log_info("device profile get source, device(%u) profile(%s) role(%s)",
-            device->id, pa_strempty(profile_str), role);
-
-    if ((profile = _get_profile(device, profile_str)) == NULL) {
-        pa_log_error("Can't get profile %s", profile_str);
-        return NULL;
-    }
-
-    if ((source = profile_get_source(profile, role)) == NULL) {
-        pa_log_error("Can't get source from profile");
-        return NULL;
-    }
-
-    return source;
+    return device_remove_source_with_role(device, role);
 }
 
 void pa_tz_device_free(pa_tz_device *device) {
@@ -976,70 +482,19 @@ void pa_tz_device_free(pa_tz_device *device) {
     pa_xfree(device->name);
     pa_xfree(device->system_id);
 
-    pa_idxset_free(device->profiles, (pa_free_cb_t)profile_free);
-
     pa_xfree(device);
 }
 
-/* pa_tz_profile_new_data */
-void pa_tz_profile_new_data_init(pa_tz_profile_new_data *profile_data) {
-    pa_assert(profile_data);
-
-    profile_data->profile = NULL;
-    profile_data->direction = DM_DEVICE_DIRECTION_NONE;
-
-    profile_data->playback_pcms= pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-    profile_data->capture_pcms = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-}
-
-void pa_tz_profile_new_data_set_direction(pa_tz_profile_new_data *profile_data, dm_device_direction_t direction) {
-    pa_assert(profile_data);
-
-    profile_data->direction = direction;
-}
-
-void pa_tz_profile_new_data_set_profile(pa_tz_profile_new_data *profile_data, const char *profile) {
-    pa_assert(profile_data);
-
-    profile_data->profile = pa_xstrdup(profile);
-}
-
-void pa_tz_profile_new_data_set_use_internal_codec(pa_tz_profile_new_data *profile_data, bool use_internal_codec) {
-    pa_assert(profile_data);
-    profile_data->use_internal_codec = use_internal_codec;
-}
-
-void pa_tz_profile_new_data_add_sink(pa_tz_profile_new_data *profile_data, const char *role, pa_sink *sink) {
-    pa_assert(profile_data);
-
-    pa_hashmap_put(profile_data->playback_pcms, (void*)role, sink);
-}
-
-void pa_tz_profile_new_data_add_source(pa_tz_profile_new_data *profile_data, const char *role, pa_source *source) {
-    pa_assert(profile_data);
-
-    pa_hashmap_put(profile_data->capture_pcms, (void*)role, source);
-}
-
-void pa_tz_profile_new_data_done(pa_tz_profile_new_data *profile_data) {
-    pa_assert(profile_data);
-
-    pa_xfree(profile_data->profile);
-}
-
 /* exported api */
 pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role) {
-    pa_tz_profile *profile;
     pa_sink *sink;
 
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    pa_log_info("device get sink, device(%u) role(%s), active-profile(%s)",
-            device->id, role, pa_strempty(profile->profile));
+    pa_log_info("device get sink, device(%u) role(%s)", device->id, role);
 
-    if ((sink = profile_get_sink(profile, role)) == NULL) {
-        pa_log_error("Failed to get sink from profile");
+    if ((sink = device_get_sink(device, role)) == NULL) {
+        pa_log_error("Failed to get sink from device");
         return NULL;
     }
 
@@ -1047,17 +502,15 @@ pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role) {
 }
 
 pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role) {
-    pa_tz_profile *profile;
     pa_source *source;
 
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    pa_log_info("device get source, device(%u) role(%s), active-profile(%s)",
-            device->id, role, pa_strempty(profile->profile));
+    pa_log_info("device get source, device(%u) role(%s)",
+            device->id, role);
 
-    if ((source = profile_get_source(profile, role)) == NULL) {
-        pa_log_error("Failed to get source from profile");
+    if ((source = device_get_source(device, role)) == NULL) {
+        pa_log_error("Failed to get source from device");
         return NULL;
     }
 
@@ -1067,23 +520,17 @@ pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role) {
 /* TODO : Change param dm_device_state_t to bool or pa_tz_device_state_t,
  * Because this state represent pa_tz_device's own state */
 void pa_tz_device_set_state(pa_tz_device *device, dm_device_direction_t direction, dm_device_state_t state) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    pa_log_info("device set state, device(%u) type(%s) active-profile(%s) direction(%s) -> %d",
-            device->id, device->type, pa_strempty(profile->profile), device_direction_to_string(direction), state);
-    profile_set_state(profile, direction, state);
+    pa_log_info("device set state, device(%u) type(%s) direction(%s) -> %d",
+            device->id, device->type, device_direction_to_string(direction), state);
+    device_set_state(device, direction, state);
 }
 
 dm_device_state_t pa_tz_device_get_state(pa_tz_device *device, dm_device_direction_t direction) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    return profile_get_state(profile, direction);
+    return device_get_state(device, direction);
 }
 
 uint32_t pa_tz_device_get_id(pa_tz_device *device) {
@@ -1110,56 +557,22 @@ char* pa_tz_device_get_system_id(pa_tz_device *device) {
     return device->system_id;
 }
 
-char* pa_tz_device_get_profile(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
-    pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
-
-    return profile->profile;
-}
-
 dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    return profile->direction;
+    return device->direction;
 }
 
 pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    return profile->creation_time;
+    return device->creation_time;
 }
 
 bool pa_tz_device_is_use_internal_codec(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
-    pa_assert(profile = _get_active_profile(device));
 
-    return profile->use_internal_codec;
-}
-
-unsigned pa_tz_device_get_profile_num(pa_tz_device *device) {
-    pa_assert(device);
-    pa_assert(device->profiles);
-
-    return pa_idxset_size(device->profiles);
-}
-
-bool pa_tz_device_have_profile(pa_tz_device *device, const char *profile) {
-    pa_assert(device);
-
-    if (_get_profile(device, profile) == NULL)
-        return false;
-    else
-        return true;
+    return device->use_internal_codec;
 }
 
 static int method_call_bt_sco(pa_dbus_connection *conn, bool onoff) {
@@ -1251,24 +664,18 @@ static int method_call_bt_sco_get_property(pa_dbus_connection *conn, bool *is_wi
     return 0;
 }
 
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
 int pa_tz_device_sco_open(pa_tz_device *device) {
-    pa_tz_profile *profile;
-
     pa_assert(device);
     pa_assert(device->dbus_conn);
 
     pa_log_info("BT SCO Open for device(%u)", device->id);
-    if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
-        pa_log_error("Not BT device");
-        return -1;
-    }
-    if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
-        pa_log_error("No BT SCO profile");
+    if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
+        pa_log_error("Not BT SCO device");
         return -1;
     }
 
-    if (profile->sco_opened) {
+    if (device->sco_opened) {
         pa_log_warn("SCO already opened");
         return -1;
     }
@@ -1278,31 +685,25 @@ int pa_tz_device_sco_open(pa_tz_device *device) {
         return -1;
     }
 
-    profile->sco_opened = true;
-    _set_active_profile(device, DEVICE_PROFILE_BT_SCO, false);
-    pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+    device->sco_opened = true;
+    pa_tz_device_dump_info(device, PA_LOG_DEBUG);
     pa_log_info("BT SCO Open - SUCCESS");
 
     return 0;
 }
 
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
 int pa_tz_device_sco_close(pa_tz_device *device) {
-    pa_tz_profile *profile;
     pa_assert(device);
 
     pa_log_info("BT SCO Close for device(%u)", device->id);
 
-    if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
-        pa_log_error("Not BT device");
-        return -1;
-    }
-    if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
-        pa_log_error("No BT SCO profile");
+    if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
+        pa_log_error("Not BT SCO device");
         return -1;
     }
 
-    if (profile->sco_opened == false) {
+    if (device->sco_opened == false) {
         pa_log_warn("SCO not opened");
         return -1;
     }
@@ -1312,28 +713,22 @@ int pa_tz_device_sco_close(pa_tz_device *device) {
         return -1;
     }
 
-    profile->sco_opened = false;
-    if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP))
-        _set_active_profile(device, DEVICE_PROFILE_BT_A2DP, false);
-    pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+    device->sco_opened = false;
+    pa_tz_device_dump_info(device, PA_LOG_DEBUG);
     pa_log_info("BT SCO Close - Success");
 
     return 0;
 }
 
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
 int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec) {
     pa_assert(device);
 
     pa_log_info("BT SCO get property for device(%u)", device->id);
-    if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
+    if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
         pa_log_error("Not BT device");
         return -1;
     }
-    if ((_get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
-        pa_log_error("No BT SCO profile");
-        return -1;
-    }
 
     if (method_call_bt_sco_get_property(device->dbus_conn, is_wide_band, nrec) < 0) {
         pa_log_error("Failed to get BT SCO Property");
@@ -1345,13 +740,12 @@ int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool
     return 0;
 }
 
-/* only for bt device */
+/* only for bt sco device */
 int pa_tz_device_sco_get_status(pa_tz_device *device, dm_device_bt_sco_status_t *status) {
-    pa_tz_profile *profile;
     pa_assert(device);
 
     pa_log_info("BT SCO get status for device(%u)", device->id);
-    if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
+    if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
         pa_log_error("Not BT device");
         return -1;
     }
@@ -1360,14 +754,10 @@ int pa_tz_device_sco_get_status(pa_tz_device *device, dm_device_bt_sco_status_t
         return -1;
     }
 
-    if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO))) {
-        if (profile->sco_opened == false)
-            *status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
-        else
-            *status = DM_DEVICE_BT_SCO_STATUS_OPENED;
-    } else {
-        *status = DM_DEVICE_BT_SCO_STATUS_DISCONNECTED;
-    }
+    if (device->sco_opened == false)
+        *status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
+    else
+        *status = DM_DEVICE_BT_SCO_STATUS_OPENED;
 
     pa_log_debug("BT SCO Get Status, %d", *status);
     return 0;
index 0776c98..82a1612 100644 (file)
@@ -9,30 +9,12 @@
 #include <pulsecore/dbus-util.h>
 #endif
 
-typedef enum pa_tz_device_profile_changed_type {
-    PA_TZ_DEVICE_PROFILE_ADDED,
-    PA_TZ_DEVICE_PROFILE_REMOVED,
-    PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED,
-    PA_TZ_DEVICE_PROFILE_CHANGED_MAX
-} pa_tz_device_profile_changed_t;
-
 typedef struct pa_tz_device pa_tz_device;
-typedef struct pa_tz_profile pa_tz_profile;
 typedef struct pa_tz_device_new_data pa_tz_device_new_data;
-typedef struct pa_tz_profile_new_data pa_tz_profile_new_data;
 
 /* structures for represent device items which can be connected/disconnected */
-/*
-    Before beginning, There are two structure(pa_tz_device, pa_tz_profile)
-    for represent device by following reasons.
-    When bt-a2dp and bt-sco are on physically same device ,it is of course same device.
-    So those physically same device item are represended by pa_tz_device,
-    and each profile is represented by pa_tz_profile.
-*/
 
 /*
-    Structure to represent physicall device,
-    which can have multiple profiles (ex. bt-a2dp and sco).
     If this is created or freed, device connected/disconnected
     hook(for internal)/callback(for apps) will be called.
 */
@@ -47,13 +29,25 @@ struct pa_tz_device {
      * each physicall device */
     char *system_id;
 
-    /* Even though there are several profiles in device,
-     * only one profile can be activated.
-     * This indicate current activat profile */
-    uint32_t active_profile;
-    /* Have only one item except bt device */
-    /* pa_tz_profile* profiles[PROFILE_NUM_MAX]; */
-    pa_idxset *profiles;
+    dm_device_direction_t direction;
+
+    /* Set by stream-manager
+     * If this is changed, will be notifacted */
+    dm_device_state_t playback_state;
+    dm_device_state_t capture_state;
+
+    /* Can get proper sink/source in hashmaps with key(=device_role) */
+    pa_hashmap *playback_devices;
+    pa_hashmap *capture_devices;
+
+    /* creation time */
+    pa_usec_t creation_time;
+
+    /* Will be true, if this device uses internal codec(card),
+     * false, if this device uses external card(bt-a2dp, usb */
+    bool use_internal_codec;
+    /* If this is sco device, this can be used to */
+    bool sco_opened;
 
     /* Devices are contained in this list */
     pa_idxset *list;
@@ -68,75 +62,22 @@ struct pa_tz_device_new_data {
     /* for multi-device type(bt, usb) */
     char *system_id;
 
-    /* for solo profile type */
     dm_device_direction_t direction;
     bool use_internal_codec;
     pa_hashmap *playback_pcms;
     pa_hashmap *capture_pcms;
 
-    /* for multi profile type */
-    pa_tz_profile_new_data* profile_data[PROFILE_NUM_MAX];
-    uint32_t n_profile;
-    uint32_t active_profile;
-
     pa_idxset *list;
     pa_communicator *comm;
     pa_dbus_connection *dbus_conn;
 };
 
-struct pa_tz_profile_new_data {
-    char *profile;
-    dm_device_direction_t direction;
-
-    pa_hashmap *playback_pcms;
-    pa_hashmap *capture_pcms;
-
-    bool use_internal_codec;
-};
-
-/*
-    Structure to represent each device profile (subtype).
-    Even if both-way device(earjack, sco..) ,one device_profile.
-*/
-struct pa_tz_profile {
-    /* This can be null except bt device */
-    char *profile;
-    dm_device_direction_t direction;
-
-    /* Set by stream-manager
-     * If this is changed, will be notifacted */
-    dm_device_state_t playback_state;
-    dm_device_state_t capture_state;
-
-    /* Can get proper sink/source in hashmaps with key(=device_role) */
-    pa_hashmap *playback_devices;
-    pa_hashmap *capture_devices;
-
-    /* device belongs to */
-    pa_tz_device *device;
-
-    /* creation time */
-    pa_usec_t creation_time;
-
-    /* Will be true, if this profile uses internal codec(card),
-     * false, if this profile uses external card(bt-a2dp, usb */
-    bool use_internal_codec;
-    /* If this is sco profile, this can be used to */
-    bool sco_opened;
-};
-
 typedef struct _hook_call_data_for_conn_changed {
     uint32_t event_id;
     bool is_connected;
     pa_tz_device *device;
 } pa_tz_device_hook_data_for_conn_changed;
 
-typedef struct _hook_call_data_for_profile_changed {
-    uint32_t event_id;
-    pa_tz_device_profile_changed_t changed;
-    pa_tz_device *device;
-} pa_tz_device_hook_data_for_profile_changed;
-
 typedef struct _hook_call_data_for_state_changed {
     uint32_t event_id;
     bool activated;
@@ -155,8 +96,6 @@ void pa_tz_device_new_data_set_use_internal_codec(pa_tz_device_new_data *data, b
 void pa_tz_device_new_data_add_sink(pa_tz_device_new_data *data, const char *role, pa_sink *sink);
 void pa_tz_device_new_data_add_source(pa_tz_device_new_data *data, const char *role, pa_source *source);
 void pa_tz_device_new_data_done(pa_tz_device_new_data *data);
-/* For multi profile device */
-void pa_tz_device_new_data_add_profile(pa_tz_device_new_data *data, pa_tz_profile_new_data *profile_data, bool as_active);
 
 /* Create tizen device instance,
  * device connected hook will be fired */
@@ -172,28 +111,6 @@ int pa_tz_device_remove_source(pa_tz_device *device, pa_source *source);
 int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role);
 int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role);
 
-/* For multi profile device */
-int pa_tz_device_add_profile(pa_tz_device *device, pa_tz_profile_new_data *pdata, bool as_active);
-int pa_tz_device_remove_profile(pa_tz_device *device, const char *profile);
-int pa_tz_device_profile_add_sink(pa_tz_device *device, const char *profile, const char *role, pa_sink *sink);
-int pa_tz_device_profile_add_source(pa_tz_device *device, const char *profile, const char *role, pa_source *source);
-int pa_tz_device_profile_remove_sink(pa_tz_device *device, const char *profile, pa_sink *sink);
-int pa_tz_device_profile_remove_source(pa_tz_device *device, const char *profile, pa_source *source);
-int pa_tz_device_profile_remove_sink_with_role(pa_tz_device *device, const char *profile, const char *role);
-int pa_tz_device_profile_remove_source_with_role(pa_tz_device *device, const char *profile, const char *role);
-pa_sink* pa_tz_device_profile_get_sink(pa_tz_device *device, const char *profile, const char *role);
-pa_source* pa_tz_device_profile_get_source(pa_tz_device *device, const char *profile, const char *role);
-
-/* This APIs can be used with pa_tz_device_new_data_add_profile or
- * pa_tz_device_add_profile */
-void pa_tz_profile_new_data_init(pa_tz_profile_new_data *profile_data);
-void pa_tz_profile_new_data_set_direction(pa_tz_profile_new_data *profile_data, dm_device_direction_t direction);
-void pa_tz_profile_new_data_set_profile(pa_tz_profile_new_data *profile_data, const char *profile);
-void pa_tz_profile_new_data_set_use_internal_codec(pa_tz_profile_new_data *profile_data, bool use_internal_codec);
-void pa_tz_profile_new_data_add_sink(pa_tz_profile_new_data *profile_data, const char *role, pa_sink *sink);
-void pa_tz_profile_new_data_add_source(pa_tz_profile_new_data *profile_data, const char *role, pa_source *source);
-void pa_tz_profile_new_data_done(pa_tz_profile_new_data *profile_data);
-
 /* Exported API for other modules */
 pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role);
 pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role);
@@ -203,17 +120,11 @@ uint32_t pa_tz_device_get_id(pa_tz_device *device);
 char* pa_tz_device_get_type(pa_tz_device *device);
 char* pa_tz_device_get_name(pa_tz_device *device);
 char* pa_tz_device_get_system_id(pa_tz_device *device);
-char* pa_tz_device_get_profile(pa_tz_device *device);
 dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device);
 pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device);
 bool pa_tz_device_is_use_internal_codec(pa_tz_device *device);
-unsigned pa_tz_device_get_profile_num(pa_tz_device *device);
-bool pa_tz_device_have_profile(pa_tz_device *device, const char *profile);
-int pa_tz_device_get_bt_avail_mode(pa_tz_device *device);
 
-/* Only for BT device
- * Check device type and check also sco profile
- * with pa_tz_device_have_profile */
+/* Only for BT SCO device */
 int pa_tz_device_sco_open(pa_tz_device *device);
 int pa_tz_device_sco_close(pa_tz_device *device);
 int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec);