It will be used for CSharp API.
[Version] 0.5.12
[Issue Type] New internal API
Change-Id: Iadbda94e2b02fe20d64a0b26845ed6f337604511
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
/*
-* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2015 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
+/**
+ * @internal
+ * @brief Checks if the device is running.
+ * @since_tizen 5.0
+ * @param[in] device_id The device id
+ * @param[out] is_running Whether the device is running or not: (@c true = running, @c false = not running)
+ * @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_is_device_running_by_id(int device_id, bool *is_running);
+
/**
* @internal
* @brief Creates a virtual stream handle.
/*
-* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2015 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @internal
- * @brief Disable session backward compatibility.
- * @since_tizen 3.0
- *
- * @remarks Multimedia framework support backward compatibility of legacy sound session. \n
- * If a process does not want legacy sound session behavior in each multimedia framework, \n
- * this function can be used explicitly not to support that.
- *
+ * @brief Checks if the device is running.
+ * @since_tizen 5.0
+ * @param[in] device_id The device id
+ * @param[out] is_running Whether the device is running or not: (@c true = running, @c false = not running)
* @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_id()
+ * @see sound_manager_free_device_list()
*/
-int sound_manager_disable_session_backward_compatibility(void);
+int sound_manager_is_device_running_by_id(int device_id, bool *is_running);
/**
* @internal
void _update_focus_status(unsigned int index, unsigned int acquired_focus_status);
+int _is_device_running_by_id(int device_id, bool *is_running);
+
int _get_supported_sample_formats(int device_id, sound_sample_format_e **formats, unsigned int *num);
int _set_sample_format(int device_id, sound_sample_format_e format);
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.5.11
+Version: 0.5.12
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_is_device_running_by_id(int device_id, bool *is_running)
+{
+ int ret = MM_ERROR_NONE;
+
+ LOGI(">> enter");
+
+ ret = _is_device_running_by_id(device_id, is_running);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream)
{
int ret = MM_ERROR_NONE;
#define PA_DEVICE_MANAGER_OBJECT_PATH "/org/pulseaudio/DeviceManager"
#define PA_DEVICE_MANAGER_INTERFACE "org.pulseaudio.DeviceManager"
+#define PA_DEVICE_MANAGER_METHOD_NAME_IS_DEVICE_RUNNING_BY_ID "IsDeviceRunningById"
#define PA_DEVICE_MANAGER_METHOD_NAME_GET_SUPPORTED_SAMPLE_FORMATS "GetSupportedSampleFormats"
#define PA_DEVICE_MANAGER_METHOD_NAME_SET_SAMPLE_FORMAT "SetSampleFormat"
#define PA_DEVICE_MANAGER_METHOD_NAME_GET_SAMPLE_FORMAT "GetSampleFormat"
return;
}
+int _is_device_running_by_id(int device_id, bool *is_running)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *result = NULL;
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+ gboolean _is_running;
+
+ assert(is_running);
+
+ if ((ret = __get_dbus_connection(&conn)))
+ return ret;
+
+ result = g_dbus_connection_call_sync(conn,
+ PA_BUS_NAME,
+ PA_DEVICE_MANAGER_OBJECT_PATH,
+ PA_DEVICE_MANAGER_INTERFACE,
+ PA_DEVICE_MANAGER_METHOD_NAME_IS_DEVICE_RUNNING_BY_ID,
+ g_variant_new("(i)", device_id),
+ G_VARIANT_TYPE("(b)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 2000,
+ NULL,
+ &err);
+ if (err) {
+ LOGE("g_dbus_connection_call_sync() for IS_DEVICE_RUNNING_BY_ID error (%s)", err->message);
+ ret = _convert_dbus_error(err->message);
+ g_error_free(err);
+ goto LEAVE;
+ } else {
+ g_variant_get(result, "(b)", &_is_running);
+ *is_running = (bool)_is_running;
+ LOGI("device(id:%d) is (%s)", device_id, *is_running ? "Running" : "Not running");
+ }
+
+LEAVE:
+ g_variant_unref(result);
+ g_object_unref(conn);
+
+ return ret;
+}
+
#define SM_SAMPLE_FORMAT_NUM 4 /* check declaration of sound_sample_format_e */
int _get_supported_sample_formats(int device_id, sound_sample_format_e **formats, unsigned int *num)
{
GVariant *result = NULL;
GDBusConnection *conn = NULL;
GError *err = NULL;
+ gboolean _enabled;
SM_NULL_ARG_CHECK_FOR_PRIV(enabled);
goto LEAVE;
}
- g_variant_get(result, "(b)", enabled);
+ g_variant_get(result, "(b)", &_enabled);
+ *enabled = (bool)_enabled;
g_variant_unref(result);
LEAVE:
case CURRENT_STATUS_GET_DEVICE_NEXT: {
sound_device_type_e type;
sound_device_io_direction_e io_direction;
- sound_device_state_e state;
+ bool is_running;
int id;
char *name;
int ret = SOUND_MANAGER_ERROR_NONE;
g_print("failed to get device id, ret[0x%x]\n", ret);
if ((ret = sound_manager_get_device_name(g_device, &name)))
g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state(g_device, &state)))
+ if ((ret = sound_manager_is_device_running(g_device, &is_running)))
g_print("failed to get device state, ret[0x%x]\n", ret);
if (!ret)
- g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%s]\n",
+ type, io_direction, id, name, is_running ? "Running" : "Not running");
} else {
g_print("failed to get next device, ret[0x%x]\n", ret);
}
case CURRENT_STATUS_GET_DEVICE_PREV: {
sound_device_type_e type;
sound_device_io_direction_e io_direction;
- sound_device_state_e state;
+ bool is_running;
int id;
char *name;
int ret = SOUND_MANAGER_ERROR_NONE;
g_print("failed to get device id, ret[0x%x]\n", ret);
if ((ret = sound_manager_get_device_name(g_device, &name)))
g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state(g_device, &state)))
+ if ((ret = sound_manager_is_device_running(g_device, &is_running)))
g_print("failed to get device state, ret[0x%x]\n", ret);
if (!ret)
- g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%s]\n",
+ type, io_direction, id, name, is_running ? "Running" : "Not running");
} else {
g_print("failed to get previous device, ret[0x%x]\n", ret);
}
case CURRENT_STATUS_GET_DEVICE_STATE_BY_ID: {
int ret = SOUND_MANAGER_ERROR_NONE;
int device_id;
- sound_device_state_e state;
+ bool is_running;
device_id = atoi(cmd);
- if ((ret = sound_manager_get_device_state_by_id(device_id, &state)))
- g_print("failed to get device state by id, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_is_device_running_by_id(device_id, &is_running)))
+ g_print("failed to is device running by id, ret[0x%x]\n", ret);
else
- g_print("device id[%d], state[%d] (0:deactivated, 1:activated)\n", device_id, state);
+ g_print("device id[%d], state[%s]\n", device_id, is_running ? "Running" : "Not running");
reset_menu_state();
break;