int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool *enabled);
/**
+ * @brief Checks if the stream information is using the device.
+ * @since_tizen 3.0
+ *
+ * @param[in] stream_info The handle of stream information
+ * @param[in] device The device item
+ * @param[out] is_on Whether the stream info is using the device or not : (@c true = use, @c false = not use)
+ * @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_INTERNAL Internal error inside the sound system
+ * @see sound_manager_get_device_list()
+ * @see sound_manager_get_next_device()
+ * @see sound_manager_get_prev_device()
+ * @see sound_manager_get_device_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_is_stream_on_device(sound_stream_info_h stream_info, sound_device_h device, bool *is_on);
+
+/**
+ * @brief Gets the current device type for media playback stream.
+ * @since_tizen 3.0
+ *
+ * @param[out] device_type The output device type that a media playback stream can go out
+ * @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_NO_DATA No data
+ * @see sound_manager_get_device_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_get_device_name()
+ */
+int sound_manager_get_current_media_playback_device_type(sound_device_type_e *device_type);
+
+/**
* @brief Gets the reason for the current acquired playback focus.
* @since_tizen 3.0
*
int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_focus_change_reason_e *change_reason);
-int _convert_device_type_to_str(sound_device_type_e device_type_enum, char **device_type);
+int _convert_device_type_enum_to_str(sound_device_type_e device_type, char **device_type_str);
int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e *sound_device_type);
+int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_type_e *device_type);
+
int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction);
const char* _convert_api_name(native_api_e api_name);
int _get_current_volume_type(const char *direction, char **volume_type);
+int _get_current_media_routing_path(const char *direction, char **device_type);
+
void _update_focus_status(unsigned int index, unsigned int acquired_focus_status);
void _pa_context_state_cb(pa_context *c, void *userdata);
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.3.85
+Version: 0.3.86
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_is_stream_on_device(sound_stream_info_h stream_info, sound_device_h device, bool *is_on)
+{
+ int ret = MM_ERROR_NONE;
+ sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+ LOGI(">> enter");
+
+ SM_NULL_ARG_CHECK(stream_h);
+ SM_NULL_ARG_CHECK(device);
+ SM_NULL_ARG_CHECK(is_on);
+#if 0
+ ret = mm_sound_get_device_id(device, &device_id);
+ if (ret == MM_ERROR_NONE)
+ ret = _is_using_device(stream_h->index, device_id, is_on);
+
+ if (ret == MM_ERROR_NONE)
+ LOGI("stream info index(%u), device_id(%d), is_on(%d)", stream_h->index, device_id, *is_on);
+#endif
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_current_media_playback_device_type(sound_device_type_e *device_type)
+{
+ int ret = MM_ERROR_NONE;
+ char *device_type_str = NULL;
+
+ LOGI(">> enter");
+
+ SM_NULL_ARG_CHECK(device_type);
+
+ ret = _get_current_media_routing_path("out", &device_type_str);
+ if (ret == MM_ERROR_NONE)
+ ret = _convert_device_type_str_to_enum(device_type_str, device_type);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info)
{
int ret = MM_ERROR_NONE;
#define PA_STREAM_MANAGER_METHOD_NAME_GET_VOLUME_LEVEL "GetVolumeLevel"
#define PA_STREAM_MANAGER_METHOD_NAME_SET_VOLUME_LEVEL "SetVolumeLevel"
#define PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE "GetCurrentVolumeType"
+#define PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_MEDIA_ROUTING_PATH "GetCurrentMediaRoutingPath"
#define PA_STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS "UpdateFocusStatus"
#define VCONF_PATH_PREFIX_VOLUME "file/private/sound/volume/"
#define VCONF_PATH_MAX 64
return MM_ERROR_NONE;
}
-int _convert_device_type_to_str(sound_device_type_e device_type_enum, char **device_type)
+int _convert_device_type_enum_to_str(sound_device_type_e device_type, char **device_type_str)
{
- SM_NULL_ARG_CHECK_FOR_PRIV(device_type);
+ SM_NULL_ARG_CHECK_FOR_PRIV(device_type_str);
- switch (device_type_enum) {
+ switch (device_type) {
case SOUND_DEVICE_BUILTIN_SPEAKER:
- *device_type = "builtin-speaker";
+ *device_type_str = "builtin-speaker";
break;
case SOUND_DEVICE_BUILTIN_RECEIVER:
- *device_type = "builtin-receiver";
+ *device_type_str = "builtin-receiver";
break;
case SOUND_DEVICE_BUILTIN_MIC:
- *device_type = "builtin-mic";
+ *device_type_str = "builtin-mic";
break;
case SOUND_DEVICE_AUDIO_JACK:
- *device_type = "audio-jack";
+ *device_type_str = "audio-jack";
break;
case SOUND_DEVICE_BLUETOOTH_MEDIA:
- *device_type = "bt-a2dp";
+ *device_type_str = "bt-a2dp";
break;
case SOUND_DEVICE_BLUETOOTH_VOICE:
- *device_type = "bt-sco";
+ *device_type_str = "bt-sco";
break;
case SOUND_DEVICE_HDMI:
- *device_type = "hdmi";
+ *device_type_str = "hdmi";
break;
case SOUND_DEVICE_USB_AUDIO:
- *device_type = "usb-audio";
+ *device_type_str = "usb-audio";
break;
case SOUND_DEVICE_FORWARDING:
- *device_type = "forwarding";
+ *device_type_str = "forwarding";
break;
default:
- LOGE("could not find the device_type[%d] in this switch case statement", device_type_enum);
+ LOGE("could not find the device_type[%d] in this switch case statement", device_type);
return MM_ERROR_SOUND_INTERNAL;
}
- LOGI("device_type[%s]", *device_type);
+ LOGI("device_type[%s]", *device_type_str);
+
+ return MM_ERROR_NONE;
+}
+
+int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_type_e *device_type)
+{
+ SM_NULL_ARG_CHECK_FOR_PRIV(device_type_str);
+ SM_NULL_ARG_CHECK_FOR_PRIV(device_type);
+
+ if (!strncmp(device_type_str, "builtin-speaker", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+
+ } else if (!strncmp(device_type_str, "builtin-receiver", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+
+ } else if (!strncmp(device_type_str, "builtin-mic", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_BUILTIN_MIC;
+
+ } else if (!strncmp(device_type_str, "audio-jack", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_AUDIO_JACK;
+
+ } else if (!strncmp(device_type_str, "hdmi", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_HDMI;
+
+ } else if (!strncmp(device_type_str, "usb-audio", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_USB_AUDIO;
+
+ } else if (!strncmp(device_type_str, "bt-a2dp", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION;
+
+ } else if (!strncmp(device_type_str, "bt-sco", SOUND_DEVICE_TYPE_LEN)) {
+ *device_type = SOUND_DEVICE_BLUETOOTH_VOICE;
+
+ } else {
+ LOGE("not supported device_type(%s)", device_type_str);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
return MM_ERROR_NONE;
}
return ret;
}
+int _get_current_media_routing_path(const char *direction, char **device_type)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *result = NULL;
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+ const gchar *dbus_device_type = NULL;
+ const gchar *dbus_ret = NULL;
+
+ assert(direction);
+ assert(device_type);
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (!conn) {
+ LOGE("g_bus_get_sync() error (%s)", err->message);
+ g_error_free(err);
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ result = g_dbus_connection_call_sync(conn,
+ PA_BUS_NAME,
+ PA_STREAM_MANAGER_OBJECT_PATH,
+ PA_STREAM_MANAGER_INTERFACE,
+ PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_MEDIA_ROUTING_PATH,
+ g_variant_new("(s)", direction),
+ G_VARIANT_TYPE("(ss)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 2000,
+ NULL,
+ &err);
+ if (!result) {
+ LOGE("g_dbus_connection_call_sync() for GET_CURRENT_MEDIA_ROUTING_PATH error (%s)", err->message);
+ g_error_free(err);
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto LEAVE;
+ }
+
+ g_variant_get(result, "(&s&s)", &dbus_device_type, &dbus_ret);
+ LOGI("g_dbus_connection_call_sync() success, method return value is (%s, %s)", dbus_device_type, dbus_ret);
+ if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+ ret = MM_ERROR_NONE;
+ *device_type = strdup(dbus_device_type);
+ } else {
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+ g_variant_unref(result);
+LEAVE:
+ g_object_unref(conn);
+
+ return ret;
+}
+
void _update_focus_status(unsigned int index, unsigned int acquired_focus_status)
{
GVariant *result = NULL;
return ret;
if (ret == MM_ERROR_NONE)
_convert_device_type(mm_sound_device_type, &device_type);
- if ((ret = _convert_device_type_to_str(device_type, &device_type_str)))
+ 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 ret;
if (ret == MM_ERROR_NONE)
_convert_device_type(mm_sound_device_type, &device_type);
- if ((ret = _convert_device_type_to_str(device_type, &device_type_str)))
+ 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;
CURRENT_STATUS_GET_FOCUS_REACQUISITION,
CURRENT_STATUS_GET_REASON_FOR_P_FOCUS,
CURRENT_STATUS_GET_REASON_FOR_R_FOCUS,
+ CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE,
CURRENT_STATUS_CREATE_VIRTUAL_STREAM,
CURRENT_STATUS_START_VIRTUAL_STREAM,
CURRENT_STATUS_STOP_VIRTUAL_STREAM,
g_menu_state = CURRENT_STATUS_GET_REASON_FOR_P_FOCUS;
else if (strncmp(cmd, "grr", 3) == 0)
g_menu_state = CURRENT_STATUS_GET_REASON_FOR_R_FOCUS;
+ else if (strncmp(cmd, "gmp", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE;
else if (strncmp(cmd, "dsi", 3) == 0)
g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
else if (strncmp(cmd, "vcr", 3) == 0)
g_print("gfr. Get Focus Reacquisition\n");
g_print("grp. Get Reason for Current Acquired Playback Focus\t");
g_print("grr. Get Reason for Current Acquired Recording Focus\n");
+ g_print("gmp. Get Current Media Playback Routing Path\n");
g_print("sso. *Set option for stream routing\n");
g_print("vcr. *Create VStream\t");
g_print("vsr. *Start VStream\t");
g_print("*** press enter to get reason for current playback focus\n");
else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_R_FOCUS)
g_print("*** press enter to get reason for current recording focus\n");
+ else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE)
+ g_print("*** press enter to get current_media_playback_device type\n");
else if (g_menu_state == CURRENT_STATUS_CREATE_VIRTUAL_STREAM)
g_print("*** press enter to create virtual stream\n");
else if (g_menu_state == CURRENT_STATUS_START_VIRTUAL_STREAM)
if ((ret = sound_manager_get_device_type(device, &_type)))
g_print("failed to get device type, ret[0x%x]\n", ret);
else
- _convert_device_type_to_str(_type, type);
+ _convert_device_type_enum_to_str(_type, type);
if ((ret = sound_manager_get_device_id(device, id))) {
g_print("failed to get device id, ret[0x%x]\n", ret);
reset_menu_state();
break;
}
+ case CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ sound_device_type_e device_type;
+
+ ret = sound_manager_get_current_media_playback_device_type(&device_type);
+ if (ret)
+ g_print("fail to sound_manager_get_current_media_playback_device_type, ret(0x%x)\n", ret);
+ else
+ g_print("device_type(%d)\n", device_type);
+
+ reset_menu_state();
+ break;
+ }
case CURRENT_STATUS_CREATE_VIRTUAL_STREAM: {
int ret = SOUND_MANAGER_ERROR_NONE;
if (!g_stream_info_h || g_vstream_h) {