*/
int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
+/**
+ * @internal
+ * @brief Sets the preferred built-in device id for the stream routing.
+ * @since_tizen 5.5
+ *
+ * @remarks This function is to set a specific built-in device id when the system has multiple devices of the same built-in device type.
+ * When there's only one device for a built-in device type in the system, nothing will happen even if this function succeeds in operation.
+ * If the device type of @a device_id is not supported by @a stream_info, #SOUND_MANAGER_ERROR_POLICY will be returned.
+ *
+ * @param[in] stream_info The handle of stream information
+ * @param[in] io_direction The IO direction of the device
+ * @param[in] device_id The preferred device id (this can be #SOUND_MANAGER_STREAM_NO_PREFERRED_DEVICE to unset)
+ * @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
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @pre Call sound_manager_create_stream_information() before calling this function.
+ * @pre Get a device by calling sound_manager_get_device_list() and sound_manager_get_next_device().
+ * @pre Get a device id by calling sound_manager_get_device_id().
+ * @post You can get preferred devices by calling sound_manager_get_stream_preferred_device().
+ * @post Call sound_manager_free_device_list() to free the devices.
+ * @see sound_manager_get_stream_preferred_device()
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_get_device_list()
+ * @see sound_manager_get_next_device()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_set_stream_preferred_device_id(sound_stream_info_h stream_info, sound_device_io_direction_e io_direction, int device_id);
+
/**
* @internal
* @brief Gets the state of the device by id.
*/
int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
+/**
+ * @internal
+ * @brief Sets the preferred built-in device id for the stream routing.
+ * @since_tizen 5.5
+ *
+ * @remarks This function is to set a specific built-in device id when the system has multiple devices of the same built-in device type.
+ * When there's only one device for a built-in device type in the system, nothing will happen even if this function succeeds in operation.
+ * If the device type of @a device_id is not supported by @a stream_info, #SOUND_MANAGER_ERROR_POLICY will be returned.
+ *
+ * @param[in] stream_info The handle of stream information
+ * @param[in] io_direction The IO direction of the device
+ * @param[in] device_id The preferred device id (this can be #SOUND_MANAGER_STREAM_NO_PREFERRED_DEVICE to unset)
+ * @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
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @pre Call sound_manager_create_stream_information() before calling this function.
+ * @pre Get a device by calling sound_manager_get_device_list() and sound_manager_get_next_device().
+ * @pre Get a device id by calling sound_manager_get_device_id().
+ * @post You can get preferred devices by calling sound_manager_get_stream_preferred_device().
+ * @post Call sound_manager_free_device_list() to free the devices.
+ * @see sound_manager_get_stream_preferred_device()
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_get_device_list()
+ * @see sound_manager_get_next_device()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_set_stream_preferred_device_id(sound_stream_info_h stream_info, sound_device_io_direction_e io_direction, int device_id);
+
/**
* @internal
* @brief Gets the state of the device by id.
int _set_preferred_device(sound_stream_info_s *stream_info, sound_device_io_direction_e direction, sound_device_h device);
+int _set_preferred_device_id(sound_stream_info_s *stream_info, sound_device_io_direction_e direction, int device_id);
+
int _get_preferred_device(sound_stream_info_s *stream_info, int *in_device_id, int *out_device_id);
#ifdef __cplusplus
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.5.35
+Version: 0.5.36
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_set_stream_preferred_device_id(sound_stream_info_h stream_info, sound_device_io_direction_e io_direction, int device_id)
+{
+ int ret = MM_ERROR_NONE;
+ sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+ SM_NULL_ARG_CHECK(stream_h);
+
+ ret = _set_preferred_device_id(stream_h, io_direction, 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;
return ret;
}
-
-int _set_preferred_device(sound_stream_info_s *stream_info, sound_device_io_direction_e direction, sound_device_h device)
+static int __invoke_ipc_set_preferred_device_id(sound_stream_info_s *stream_info, int device_id, sound_device_io_direction_e io_direction, sound_device_io_direction_e req_direction)
{
int ret = MM_ERROR_NONE;
GVariant *result = NULL;
GError *err = NULL;
const gchar *dbus_ret = NULL;
const gchar *direction_str;
- bool available = false;
- int device_id = 0;
- mm_sound_device_io_direction_e io_direction;
int i;
SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
- /* allow only auto route type */
- if ((ret = __check_auto_route_type(stream_info)))
- return ret;
-
- /* check if this device belongs to available devices of the stream info */
- /* In case device is null, it's for unsetting preferred device, device_id will be 0. */
- if (device) {
- if ((ret = __is_available_device(stream_info, device, &available)))
- return ret;
- if (!available)
- return MM_ERROR_POLICY_INTERNAL;
- if ((ret = mm_sound_get_device_id(device, &device_id)))
- return ret;
- if ((ret = mm_sound_get_device_io_direction(device, &io_direction)))
- return ret;
- if (!(io_direction & (direction + 1)) || ((int)io_direction < (int)(direction + 1))) {
- LOGE("device direction(0x%x), request direction(0x%x)", io_direction, (direction + 1));
- return MM_ERROR_INVALID_ARGUMENT;
- }
- }
-
if ((ret = __get_dbus_connection(&conn)))
return ret;
for (i = SOUND_DEVICE_IO_DIRECTION_IN; i < SOUND_DEVICE_IO_DIRECTION_BOTH; i++) {
- if (device) {
+ if (device_id) {
if (!(io_direction & (i + 1)))
continue;
} else {
- if (!((direction + 1) & (i + 1)))
+ if (!((req_direction + 1) & (i + 1)))
continue;
}
direction_str = (i == SOUND_DEVICE_IO_DIRECTION_IN) ? "in" : "out";
LEAVE:
g_object_unref(conn);
-
return ret;
}
+int _set_preferred_device(sound_stream_info_s *stream_info, sound_device_io_direction_e direction, sound_device_h device)
+{
+ int ret = MM_ERROR_NONE;
+ bool available = false;
+ int device_id = 0;
+ mm_sound_device_io_direction_e io_direction = MM_SOUND_DEVICE_IO_DIRECTION_IN;
+
+ SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+
+ /* allow only auto route type */
+ if ((ret = __check_auto_route_type(stream_info)))
+ return ret;
+
+ /* check if this device belongs to available devices of the stream info */
+ /* In case device is null, it's for unsetting preferred device, device_id will be 0. */
+ if (device) {
+ if ((ret = __is_available_device(stream_info, device, &available)))
+ return ret;
+ if (!available)
+ return MM_ERROR_POLICY_INTERNAL;
+ if ((ret = mm_sound_get_device_id(device, &device_id)))
+ return ret;
+ if ((ret = mm_sound_get_device_io_direction(device, &io_direction)))
+ return ret;
+ if (!(io_direction & (direction + 1)) || ((int)io_direction < (int)(direction + 1))) {
+ LOGE("device direction(0x%x), request direction(0x%x)", io_direction, (direction + 1));
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+ }
+
+ return __invoke_ipc_set_preferred_device_id(stream_info, device_id, io_direction, direction);
+}
+
+int _set_preferred_device_id(sound_stream_info_s *stream_info, sound_device_io_direction_e direction, int device_id)
+{
+ int ret = MM_ERROR_NONE;
+ bool available = false;
+ mm_sound_device_io_direction_e io_direction = MM_SOUND_DEVICE_IO_DIRECTION_IN;
+
+ SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
+
+ /* allow only auto route type */
+ if ((ret = __check_auto_route_type(stream_info)))
+ return ret;
+
+ /* check if this device belongs to available devices of the stream info */
+ /* In case device_id is 0, it's for unsetting preferred device. */
+ if (device_id) {
+ MMSoundDevice_t device = NULL;
+
+ if ((ret = mm_sound_get_device_by_id(device_id, &device))) {
+ LOGE("failed to mm_sound_get_device_by_id()");
+ return ret;
+ }
+ if ((ret = __is_available_device(stream_info, (sound_device_h)device, &available)))
+ goto device_free;
+ if (!available) {
+ ret = MM_ERROR_POLICY_INTERNAL;
+ goto device_free;
+ }
+ if ((ret = mm_sound_get_device_io_direction(device, &io_direction)))
+ goto device_free;
+ if (!(io_direction & (direction + 1)) || ((int)io_direction < (int)(direction + 1))) {
+ LOGE("device direction(0x%x), request direction(0x%x)", io_direction, (direction + 1));
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ }
+device_free:
+ mm_sound_free_device(device);
+ if (ret)
+ return ret;
+ }
+
+ return __invoke_ipc_set_preferred_device_id(stream_info, device_id, io_direction, direction);
+}
+
int _get_preferred_device(sound_stream_info_s *stream_info, int *in_device_id, int *out_device_id)
{
SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING,
CURRENT_STATUS_APPLY_STREAM_ROUTING,
CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE,
+ CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE_ID,
CURRENT_STATUS_GET_STREAM_PREFERRED_DEVICE,
CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
CURRENT_STATUS_ACQUIRE_FOCUS,
g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
else if (strncmp(cmd, "spd", MAX_CMD_LEN) == 0)
g_menu_state = CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE;
+ else if (strncmp(cmd, "spi", MAX_CMD_LEN) == 0)
+ g_menu_state = CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE_ID;
else if (strncmp(cmd, "gpd", MAX_CMD_LEN) == 0)
g_menu_state = CURRENT_STATUS_GET_STREAM_PREFERRED_DEVICE;
else if (strncmp(cmd, "afc", MAX_CMD_LEN) == 0)
g_print("aps. Apply devices for Stream Routing\t");
g_print("rad. Remove all devices for Stream Routing\n");
g_print("spd. Set preferred device\t");
+ g_print("spi. *Set preferred device id\t");
g_print("gpd. Get preferred device\n");
g_print("afc. Acquire Focus\t");
g_print("rfc. Release Focus\t");
g_print("*** press enter to apply devices for stream routing\n");
else if (g_menu_state == CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE)
g_print("*** input direction to set preferred device (0:out, 1:in, 2:both)\n");
- else if (g_menu_state == CURRENT_STATUS_GET_STREAM_PREFERRED_DEVICE)
+ else if (g_menu_state == CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE_ID) {
+ if (flag == 0)
+ g_print("*** input preferred device id(0:unset, 1 ~: device_id) and direction(0:out, 1:in, 2:both)\n");
+ flag = 1;
+ } else if (g_menu_state == CURRENT_STATUS_GET_STREAM_PREFERRED_DEVICE)
g_print("*** press enter to get preferred device\n");
else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION)
g_print("*** input option(name/value) for routing (0:option_1/0, 1:option_1/1, 2:option_2/0, 3:option_2:1)\n");
reset_menu_state();
break;
}
+ case CURRENT_STATUS_SET_STREAM_PREFERRED_DEVICE_ID: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ static int cnt = 0;
+ static int preferred_device_id = 0;
+ sound_device_io_direction_e direction;
+
+ if (cnt == 0) {
+ preferred_device_id = atoi(cmd);
+ cnt++;
+ } else if (cnt == 1) {
+ switch ( atoi(cmd)) {
+ case 0:
+ direction = SOUND_DEVICE_IO_DIRECTION_OUT;
+ break;
+ case 1:
+ direction = SOUND_DEVICE_IO_DIRECTION_IN;
+ break;
+ case 2:
+ direction = SOUND_DEVICE_IO_DIRECTION_BOTH;
+ break;
+ default:
+ g_print("invalid argument, try again..\n");
+ reset_menu_state();
+ goto end;
+ }
+ cnt = 0;
+
+ ret = sound_manager_set_stream_preferred_device_id(g_stream_info_h, direction, preferred_device_id);
+ if (ret)
+ g_print("failed to sound_manager_set_stream_preferred_device_id(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
+ }
+ break;
+ }
case CURRENT_STATUS_GET_STREAM_PREFERRED_DEVICE: {
int ret = SOUND_MANAGER_ERROR_NONE;
int in_device_id = 0;