*/
int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_info, int *index);
+/**
+ * @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.
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);
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
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)
{
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:
break;
}
-finish:
+LEAVE:
return _convert_sound_manager_error_code(__func__, ret);
}
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);
}
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:
break;
}
-finish:
+LEAVE:
return _convert_sound_manager_error_code(__func__, ret);
}
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) {
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++) {
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++) {
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;
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;
}
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,
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)
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");
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)
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);
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);
}
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);