Add new internal APIs to add/remove device id to stream_info and to get device state... 53/132153/1 accepted/tizen/unified/20170605.150756 submit/tizen/20170602.051157
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 1 Jun 2017 08:23:34 +0000 (17:23 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 1 Jun 2017 08:25:32 +0000 (17:25 +0900)
 - sound_manager_add_device_id_for_stream_routing()
 - sound_manager_remove_device_id_for_stream_routing()
 - sound_manager_get_device_state_by_id()

[Version] 0.4.3
[Issue Type] New internal API

Change-Id: Ic3943ba95ccf0d121d1f7c3c47086ab4ac59b698
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/sound_manager_internal.h
include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager_internal.c
src/sound_manager_private.c
test/sound_manager_test.c

index 4245e31..3f0cdcc 100644 (file)
@@ -242,6 +242,73 @@ int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_i
 
 /**
  * @internal
+ * @brief Adds the device id to the stream information for the stream routing.
+ * @since_tizen 4.0
+ *
+ * @remarks    Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
+ *     to get the device id.\n
+ *     #SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the @a stream_info.\n
+ *     The available types of the @a stream_info for this function are #SOUND_STREAM_TYPE_VOIP and #SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY.
+ *
+ * @param[in]  stream_info     The handle of stream information
+ * @param[in]  device_id       The device id
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
+ * @pre Call sound_manager_create_stream_information() before calling this function.
+ * @post You can apply this setting by calling sound_manager_apply_stream_routing().
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_remove_device_id_for_stream_routing()
+ * @see sound_manager_apply_stream_routing()
+ */
+int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
+
+/**
+ * @internal
+ * @brief Removes the device id to the stream information for the stream routing.
+ * @since_tizen 4.0
+ *
+ * @remarks    Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
+ *     to get the device id.\n
+ *
+ * @param[in]  stream_info     The handle of stream information
+ * @param[in]  device          The device id
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Call sound_manager_create_stream_information() and sound_manager_add_device_for_stream_routing() before calling this function.
+ * @post You can apply this setting by calling sound_manager_apply_stream_routing().
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_add_device_id_for_stream_routing()
+ * @see sound_manager_apply_stream_routing()
+ */
+int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
+
+/**
+ * @internal
+ * @brief Gets the state of the device by id.
+ * @since_tizen 4.0
+ * @param[in]  device_id       The device id
+ * @param[out] state   The state of the device
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see sound_manager_get_device_list()
+ * @see sound_manager_get_next_device()
+ * @see sound_manager_get_prev_device()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
+
+/**
+ * @internal
  * @brief Gets the internal stream information handle for VoIP session.
  * @since_tizen 3.0
  *
index a380cf2..67daccf 100644 (file)
@@ -297,6 +297,10 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic
 
 int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device);
 
+int _add_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id);
+
+int _remove_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id);
+
 int _apply_stream_routing(sound_stream_info_s *stream_info);
 
 int _create_virtual_stream(sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream);
index 4f9d678..691ffe4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.4.2
+Version:    0.4.3
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index e1d3765..9cc1f3b 100644 (file)
@@ -173,6 +173,49 @@ int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_i
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
+int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       ret = _add_device_id_for_stream_routing(stream_h, device_id);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       ret = _remove_device_id_for_stream_routing(stream_h, device_id);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state)
+{
+       int ret = MM_ERROR_NONE;
+       MMSoundDevice_t device = NULL;
+
+       LOGI(">> enter");
+
+       if ((ret = mm_sound_get_device_by_id(device_id, &device))) {
+               LOGE("failed to mm_sound_get_device_by_id()");
+               goto LEAVE;
+       }
+
+       ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state);
+
+       mm_sound_free_device(device);
+LEAVE:
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
 /* This function is only for audio-io session backward compatibility */
 int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info)
 {
@@ -329,9 +372,9 @@ int sound_manager_set_filter(sound_stream_type_e stream_type, sound_filter_e fil
        LOGI(">> enter");
 
        if ((ret = _convert_stream_type(stream_type, &stream_type_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
        if ((ret = _convert_filter(filter, &filter_str, &filter_params_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
 
        switch (filter) {
        case SOUND_FILTER_NONE:
@@ -350,7 +393,7 @@ int sound_manager_set_filter(sound_stream_type_e stream_type, sound_filter_e fil
                break;
        }
 
-finish:
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -362,12 +405,12 @@ int sound_manager_unset_filter(sound_stream_type_e stream_type)
        LOGI(">> enter");
 
        if ((ret = _convert_stream_type(stream_type, &stream_type_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
 
        ret = mm_sound_unset_filter(stream_type_str);
        LOGI("stream_type[%s]", stream_type_str);
 
-finish:
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -381,11 +424,11 @@ int sound_manager_set_filter_preset(sound_stream_type_e stream_type, sound_filte
        LOGI(">> enter");
 
        if ((ret = _convert_stream_type(stream_type, &stream_type_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
        if ((ret = _convert_filter(filter, &filter_str, &filter_params_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
        if ((ret = _convert_filter_preset(preset, &control_str)) != MM_ERROR_NONE)
-               goto finish;
+               goto LEAVE;
 
        switch (filter) {
        case SOUND_FILTER_NONE:
@@ -402,6 +445,6 @@ int sound_manager_set_filter_preset(sound_stream_type_e stream_type, sound_filte
                break;
        }
 
-finish:
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
index 5e99b55..e64a783 100644 (file)
@@ -1804,20 +1804,9 @@ int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h)
        return ret;
 }
 
-int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
+static int __check_manual_route_type(sound_stream_info_s *stream_info)
 {
-       int ret = MM_ERROR_NONE;
-       int i = 0;
-       int j = 0;
-       bool added_successfully = false;
-       char *device_type_str = NULL;
-       int device_id = 0;
-       mm_sound_device_type_e mm_sound_device_type;
-       mm_sound_device_io_direction_e device_direction;
-       sound_device_type_e device_type;
-
        SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
-       SM_NULL_ARG_CHECK_FOR_PRIV(device);
 
        if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
            stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
@@ -1825,16 +1814,16 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic
                return MM_ERROR_POLICY_INTERNAL;
        }
 
-       if ((ret = mm_sound_get_device_id(device, &device_id)))
-               return ret;
-       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
-               return ret;
-       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
-               return ret;
-       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
-               return ret;
-       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
-               return ret;
+       return MM_ERROR_NONE;
+}
+
+static int __add_device_to_stream_info(sound_stream_info_s *stream_info, int device_id, mm_sound_device_io_direction_e device_direction, char *device_type_str)
+{
+       int i, j;
+       bool added_successfully = false;
+
+       SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+       SM_NULL_ARG_CHECK_FOR_PRIV(device_type_str);
 
        if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
@@ -1882,42 +1871,16 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic
                return MM_ERROR_POLICY_INTERNAL;
        }
 
-       LOGI("*** add device(type[%s],id[%d]), ret(0x%x)", device_type_str, device_id, ret);
-
        return MM_ERROR_NONE;
 }
 
-int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
+static int __remove_device_to_stream_info(sound_stream_info_s *stream_info, int device_id, mm_sound_device_io_direction_e device_direction, char *device_type_str)
 {
-       int ret = MM_ERROR_NONE;
-       int i = 0;
-       int j = 0;
+       int i, j;
        bool removed_successfully = false;
-       char *device_type_str = NULL;
-       int device_id = 0;
-       mm_sound_device_type_e mm_sound_device_type;
-       mm_sound_device_io_direction_e device_direction;
-       sound_device_type_e device_type;
 
        SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
-       SM_NULL_ARG_CHECK_FOR_PRIV(device);
-
-       if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
-           stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
-               LOGE("route type is not manual or manual-ext");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       if ((ret = mm_sound_get_device_id(device, &device_id)))
-               return ret;
-       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
-               return ret;
-       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
-               return ret;
-       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
-               return ret;
-       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
-               return ret;
+       SM_NULL_ARG_CHECK_FOR_PRIV(device_type_str);
 
        if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
@@ -1957,11 +1920,151 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       LOGI("*** remove device[type:%s, id:%d], ret(0x%x)", device_type_str, device_id, ret);
+       return MM_ERROR_NONE;
+}
+
+int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
+{
+       int ret = MM_ERROR_NONE;
+       char *device_type_str = NULL;
+       int device_id = 0;
+       mm_sound_device_type_e mm_sound_device_type;
+       mm_sound_device_io_direction_e device_direction;
+       sound_device_type_e device_type;
+
+       SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+       SM_NULL_ARG_CHECK_FOR_PRIV(device);
+
+       if ((ret = __check_manual_route_type(stream_info)))
+               return ret;
+
+       if ((ret = mm_sound_get_device_id(device, &device_id)))
+               return ret;
+       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
+               return ret;
+       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
+               return ret;
+       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
+               return ret;
+       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
+               return ret;
+
+       if ((ret = __add_device_to_stream_info(stream_info, device_id, device_direction, device_type_str)))
+               return ret;
+
+       LOGI("*** added device[type:%s, id:%d]", device_type_str, device_id);
+
+       return MM_ERROR_NONE;
+}
+
+int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
+{
+       int ret = MM_ERROR_NONE;
+       char *device_type_str = NULL;
+       int device_id = 0;
+       mm_sound_device_type_e mm_sound_device_type;
+       mm_sound_device_io_direction_e device_direction;
+       sound_device_type_e device_type;
+
+       SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+       SM_NULL_ARG_CHECK_FOR_PRIV(device);
+
+       if ((ret = __check_manual_route_type(stream_info)))
+               return ret;
+
+       if ((ret = mm_sound_get_device_id(device, &device_id)))
+               return ret;
+       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
+               return ret;
+       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
+               return ret;
+       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
+               return ret;
+       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
+               return ret;
+
+       if ((ret = __remove_device_to_stream_info(stream_info, device_id, device_direction, device_type_str)))
+               return ret;
+
+       LOGI("*** removed device[type:%s, id:%d]", device_type_str, device_id);
 
        return MM_ERROR_NONE;
 }
 
+int _add_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id)
+{
+       int ret = MM_ERROR_NONE;
+       char *device_type_str = NULL;
+       mm_sound_device_type_e mm_sound_device_type;
+       mm_sound_device_io_direction_e device_direction;
+       sound_device_type_e device_type;
+       MMSoundDevice_t device = NULL;
+
+       SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+       SM_NULL_ARG_CHECK_FOR_PRIV(device);
+
+       if ((ret = __check_manual_route_type(stream_info)))
+               return ret;
+
+       if ((ret = mm_sound_get_device_by_id(device_id, &device)))
+               return ret;
+       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
+               goto LEAVE;
+       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
+               goto LEAVE;
+       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
+               goto LEAVE;
+       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
+               goto LEAVE;
+
+       if ((ret = __add_device_to_stream_info(stream_info, device_id, device_direction, device_type_str)))
+               goto LEAVE;
+
+       LOGI("*** added device by id[type:%s, id:%d]", device_type_str, device_id);
+
+LEAVE:
+       if (device)
+               mm_sound_free_device(device);
+       return ret;
+}
+
+int _remove_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id)
+{
+       int ret = MM_ERROR_NONE;
+       char *device_type_str = NULL;
+       mm_sound_device_type_e mm_sound_device_type;
+       mm_sound_device_io_direction_e device_direction;
+       sound_device_type_e device_type;
+       MMSoundDevice_t device = NULL;
+
+       SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+       SM_NULL_ARG_CHECK_FOR_PRIV(device);
+
+       if ((ret = __check_manual_route_type(stream_info)))
+               return ret;
+
+       if ((ret = mm_sound_get_device_by_id(device_id, &device)))
+               return ret;
+       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)))
+               goto LEAVE;
+       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)))
+               goto LEAVE;
+       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)))
+               goto LEAVE;
+       if ((ret = mm_sound_get_device_io_direction(device, &device_direction)))
+               goto LEAVE;
+
+       if ((ret = __remove_device_to_stream_info(stream_info, device_id, device_direction, device_type_str)))
+               goto LEAVE;
+
+       LOGI("*** removed device by id[type:%s, id:%d]", device_type_str, device_id);
+
+LEAVE:
+       if (device)
+               mm_sound_free_device(device);
+       return ret;
+}
+
 int _apply_stream_routing(sound_stream_info_s *stream_info)
 {
        int i = 0;
@@ -1971,6 +2074,8 @@ int _apply_stream_routing(sound_stream_info_s *stream_info)
        if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
            stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
                LOGE("route type is not manual or manual-ext");
+               /* Differ from others, it uses SOUND_INTERNAL error.
+                * ACR process is required prior to changing error value. */
                return MM_ERROR_SOUND_INTERNAL;
        }
 
index e95dadc..ce2f39e 100644 (file)
@@ -69,6 +69,8 @@ enum {
        CURRENT_STATUS_CREATE_STREAM_INFO,
        CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING,
        CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING,
+       CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING,
+       CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING,
        CURRENT_STATUS_APPLY_STREAM_ROUTING,
        CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
        CURRENT_STATUS_ACQUIRE_FOCUS,
@@ -227,6 +229,10 @@ void _interpret_main_menu(char *cmd)
                g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
        else if (strncmp(cmd, "rds", 3) == 0)
                g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
+       else if (strncmp(cmd, "adi", 3) == 0)
+               g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
+       else if (strncmp(cmd, "rdi", 3) == 0)
+               g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
        else if (strncmp(cmd, "aps", 3) == 0)
                g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
        else if (strncmp(cmd, "sso", 3) == 0)
@@ -340,6 +346,8 @@ void display_sub_basic()
        g_print("ads. Add Device for Stream Routing\t");
        g_print("rds. Remove Device for Stream Routing\t");
        g_print("aps. Apply devices for Stream Routing\n");
+       g_print("adi. *Add Device ID for Stream Routing\t");
+       g_print("rdi. *Remove Device ID for Stream Routing\n");
        g_print("afc. Acquire Focus\t");
        g_print("rfc. Release Focus\t");
        g_print("gfs. Get Focus State\n");
@@ -447,6 +455,10 @@ static void displaymenu()
                g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
        else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING)
                g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
+       else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING)
+               g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
+       else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING)
+               g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
        else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING)
                g_print("*** press enter to apply devices for stream routing\n");
        else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION)
@@ -1244,16 +1256,15 @@ static void interpret(char *cmd)
                if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
                        g_print("success to get current device list\n");
                        while (!sound_manager_get_next_device(g_device_list, &device)) {
-                               if (!(ret = sound_manager_get_device_type(device, &type))) {
-                                       if (selected_type == type) {
-                                               need_to_go = true;
-                                               break;
-                                       }
-                               } else {
+                               if ((ret = sound_manager_get_device_type(device, &type))) {
                                        g_print("fail to get type of device, ret(0x%x)\n", ret);
                                        reset_menu_state();
                                        break;
                                }
+                               if (selected_type == type) {
+                                       need_to_go = true;
+                                       break;
+                               }
                        }
                        if (need_to_go) {
                                ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device);
@@ -1314,16 +1325,15 @@ static void interpret(char *cmd)
                if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
                        g_print("success to get current device list\n");
                        while (!sound_manager_get_next_device(g_device_list, &device)) {
-                               if (!(ret = sound_manager_get_device_type(device, &type))) {
-                                       if (selected_type == type) {
-                                               need_to_go = true;
-                                               break;
-                                       }
-                               } else {
+                               if ((ret = sound_manager_get_device_type(device, &type))) {
                                        g_print("fail to get type of device, ret(0x%x)\n", ret);
                                        reset_menu_state();
                                        break;
                                }
+                               if (selected_type == type) {
+                                       need_to_go = true;
+                                       break;
+                               }
                        }
                        if (need_to_go) {
                                ret = sound_manager_remove_device_for_stream_routing(g_stream_info_h, device);
@@ -1346,6 +1356,157 @@ static void interpret(char *cmd)
                }
                break;
        }
+       case CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING: {
+               int ret = SOUND_MANAGER_ERROR_NONE;
+               int device_type = 0;
+               sound_device_h device = NULL;
+               sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+               sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
+               bool need_to_go = false;
+               int device_id = 0;
+
+               device_type = atoi(cmd);
+               switch (device_type) {
+               case 0: /* built-in mic */
+                       selected_type = SOUND_DEVICE_BUILTIN_MIC;
+                       break;
+               case 1: /* built-in spk */
+                       selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+                       break;
+               case 2: /* built-in rcv */
+                       selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+                       break;
+               case 3: /* audio-jack */
+                       selected_type = SOUND_DEVICE_AUDIO_JACK;
+                       break;
+               case 4: /* bt a2dp */
+                       selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
+                       break;
+               case 5: /* bt sco */
+                       selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
+                       break;
+               case 6: /* usb */
+                       selected_type = SOUND_DEVICE_USB_AUDIO;
+                       break;
+               default:
+                       g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
+                       reset_menu_state();
+                       break;
+               }
+               if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
+                       g_print("success to get current device list\n");
+                       while (!sound_manager_get_next_device(g_device_list, &device)) {
+                               if ((ret = sound_manager_get_device_type(device, &type))) {
+                                       g_print("fail to get type of device, ret(0x%x)\n", ret);
+                                       reset_menu_state();
+                                       break;
+                               }
+                               if (selected_type == type) {
+                                       if ((ret = sound_manager_get_device_id(device, &device_id))) {
+                                               g_print("fail to get device id, ret(0x%x)\n", ret);
+                                               reset_menu_state();
+                                               break;
+                                       }
+                                       need_to_go = true;
+                                       break;
+                               }
+                       }
+                       if (need_to_go) {
+                               ret = sound_manager_add_device_id_for_stream_routing(g_stream_info_h, device_id);
+                               if (ret)
+                                       g_print("failed to sound_manager_add_device_id_for_stream_routing(), ret(0x%x)\n", ret);
+                       } else
+                               g_print("the device is not available now\n");
+                       reset_menu_state();
+
+                       if (!(ret = sound_manager_free_device_list(g_device_list))) {
+                               g_print("success to free device list\n");
+                               g_device_list = NULL;
+                       } else {
+                               g_print("fail to free device list, ret[0x%x]\n", ret);
+                       }
+               } else {
+                       g_print("fail to get current device list, ret(0x%x)\n", ret);
+                       reset_menu_state();
+               }
+               break;
+       }
+       case CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING: {
+               int ret = SOUND_MANAGER_ERROR_NONE;
+               int device_type = 0;
+               sound_device_h device = NULL;
+               sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+               sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
+               bool need_to_go = false;
+               int device_id = 0;
+
+               device_type = atoi(cmd);
+               switch (device_type) {
+               case 0: /* built-in mic */
+                       selected_type = SOUND_DEVICE_BUILTIN_MIC;
+                       break;
+               case 1: /* built-in spk */
+                       selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+                       break;
+               case 2: /* built-in rcv */
+                       selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+                       break;
+               case 3: /* audio-jack */
+                       selected_type = SOUND_DEVICE_AUDIO_JACK;
+                       break;
+               case 4: /* bt a2dp */
+                       selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
+                       break;
+               case 5: /* bt sco */
+                       selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
+                       break;
+               case 6: /* usb */
+                       selected_type = SOUND_DEVICE_USB_AUDIO;
+                       break;
+               default:
+                       g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
+                       reset_menu_state();
+                       break;
+               }
+               if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
+                       g_print("success to get current device list\n");
+                       while (!sound_manager_get_next_device(g_device_list, &device)) {
+                               if ((ret = sound_manager_get_device_type(device, &type))) {
+                                       g_print("fail to get type of device, ret(0x%x)\n", ret);
+                                       reset_menu_state();
+                                       break;
+                               }
+                               if (selected_type == type) {
+                                       if ((ret = sound_manager_get_device_id(device, &device_id))) {
+                                               g_print("fail to get device id, ret(0x%x)\n", ret);
+                                               reset_menu_state();
+                                               break;
+                                       }
+                                       need_to_go = true;
+                                       break;
+                               }
+                       }
+                       if (need_to_go) {
+                               ret = sound_manager_remove_device_id_for_stream_routing(g_stream_info_h, device_id);
+                               if (ret)
+                                       g_print("failed to sound_manager_remove_device_id_for_stream_routing(), ret(0x%x)\n", ret);
+                               else
+                                       g_print("the device is not available now\n");
+                               reset_menu_state();
+                       } else {
+                               g_print("fail to get current device list, ret(0x%x)\n", ret);
+                               reset_menu_state();
+                       }
+
+                       if (!(ret = sound_manager_free_device_list(g_device_list))) {
+                               g_print("success to free device list\n");
+                               g_device_list = NULL;
+                       } else {
+                               g_print("fail to free device list, ret[0x%x]\n", ret);
+                       }
+               }
+               break;
+       }
        case CURRENT_STATUS_APPLY_STREAM_ROUTING: {
                int ret = SOUND_MANAGER_ERROR_NONE;
                ret = sound_manager_apply_stream_routing(g_stream_info_h);