-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
-SET(Services
+SET(Services
"application"
"base"
"content"
*/
int sound_manager_get_host_volume(sound_type_e type, int *volume);
+/**
+ * @internal
+ * @brief Gets the sample format of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] format The sample format 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_get_device_sample_rate()
+ * @see sound_manager_get_device_channels()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_sample_format(sound_device_h device, sound_sample_format_e *format);
+
+/**
+ * @internal
+ * @brief Gets the sample rate of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] samplerate The sample rate 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_get_device_sample_format()
+ * @see sound_manager_get_device_channels()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_sample_rate(sound_device_h device, sound_sample_rate_e *samplerate);
+
+/**
+ * @internal
+ * @brief Gets the number of channels of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] channels The number of the channels 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_get_device_sample_format()
+ * @see sound_manager_get_device_sample_rate()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_channels(sound_device_h device, int *channels);
+
/**
* @}
*/
*/
int sound_manager_start_discover_remote_device(void);
+/**
+ * @internal
+ * @brief Stops discovering of published remote devices on the local network.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #SOUND_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @pre You should start discovering by sound_manager_start_discover_remote_device().
+ * @see sound_manager_start_discover_remote_device()
+ */
+int sound_manager_stop_discover_remote_device(void);
+
/**
* @internal
* @brief Sets acoustic echo cancellation reference device
*/
int sound_manager_get_echo_cancel_reference_device(sound_stream_info_h stream_info, int *device_id);
-
/**
* @internal
- * @brief Stops discovering of published remote devices on the local network.
- * @since_tizen 6.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/internet
+ * @brief Gets the host volume level specified for a particular sound type.
+ * @since_tizen 7.0
+ * @param[in] type The sound type
+ * @param[out] volume The current volume level
* @return @c 0 on success,
* otherwise a negative error value
* @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
- * @retval #SOUND_MANAGER_ERROR_PERMISSION_DENIED Permission denied
- * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @pre You should start discovering by sound_manager_start_discover_remote_device().
- * @see sound_manager_start_discover_remote_device()
*/
-int sound_manager_stop_discover_remote_device(void);
+int sound_manager_get_host_volume(sound_type_e type, int *volume);
+
+/**
+ * @internal
+ * @brief Gets the sample format of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] format The sample format 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_sample_format(sound_device_h device, sound_sample_format_e *format);
+
+/**
+ * @internal
+ * @brief Gets the sample rate of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] samplerate The sample rate 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_sample_rate(sound_device_h device, sound_sample_rate_e *samplerate);
+
+/**
+ * @internal
+ * @brief Gets the number of channels of the device.
+ * @since_tizen 7.0
+ *
+ * @param[in] device The device item
+ * @param[out] channels The number of the channels 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_type()
+ * @see sound_manager_get_device_io_direction()
+ * @see sound_manager_get_device_name()
+ * @see sound_manager_get_device_id()
+ * @see sound_manager_free_device_list()
+ */
+int sound_manager_get_device_channels(sound_device_h device, int *channels);
/**
* @}
int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *device_io_direction);
+int _convert_sample_rate_to_enum(unsigned int rate, sound_sample_rate_e *rate_e);
+
+int _convert_sample_rate_enum_to_uint(sound_sample_rate_e rate, unsigned int *sample_rate);
+
+int _convert_sample_format_str_to_enum(const char *format_str, sound_sample_format_e *format);
+
+int _convert_sample_format_enum_to_str(sound_sample_format_e format, const char **format_str);
+
const char* _convert_api_name(native_api_e api_name);
int _return_val_if_not_usb_device(sound_device_h device, int ret_val);
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.7.0
+Version: 0.7.1
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_get_device_sample_format(sound_device_h device, sound_sample_format_e *format)
+{
+ int ret = MM_ERROR_NONE;
+ int _format = 0;
+
+ SM_ARG_CHECK(device);
+ SM_ARG_CHECK(format);
+
+ LOGI("device[%p]", device);
+
+ if ((ret = mm_sound_get_device_sample_format(device, &_format)) != MM_ERROR_NONE)
+ return _convert_sound_manager_error_code(__func__, ret);
+
+ ret = _convert_sample_format_str_to_enum(pa_sample_format_to_string(_format), format);
+
+ LOGI("sample_format [%d]", *format);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_device_sample_rate(sound_device_h device, sound_sample_rate_e *samplerate)
+{
+ int ret = MM_ERROR_NONE;
+ int _samplerate = 0;
+
+ SM_ARG_CHECK(device);
+ SM_ARG_CHECK(samplerate);
+
+ LOGI("device[%p]", device);
+
+ if ((ret = mm_sound_get_device_sample_rate(device, &_samplerate)) != MM_ERROR_NONE)
+ return _convert_sound_manager_error_code(__func__, ret);
+
+ ret = _convert_sample_rate_to_enum(_samplerate, samplerate);
+
+ LOGI("sample_rate [%d]", *samplerate);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_device_channels(sound_device_h device, int *channels)
+{
+ int ret = MM_ERROR_NONE;
+
+ SM_ARG_CHECK(device);
+ SM_ARG_CHECK(channels);
+
+ LOGI("device[%p]", device);
+
+ ret = mm_sound_get_device_channels(device, channels);
+
+ LOGI("channels [%d]", *channels);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
int sound_manager_is_stream_on_device_by_id(sound_stream_info_h stream_info, int device_id, bool *is_on)
{
int ret = MM_ERROR_NONE;
}
}
-int _convert_sample_format_enum_to_str(sound_sample_format_e format, char **format_str)
+int _convert_sample_format_enum_to_str(sound_sample_format_e format, const char **format_str)
{
SM_ARG_CHECK(format_str);
GDBusConnection *conn = NULL;
GVariant *result = NULL;
GError *err = NULL;
- char *format_str = NULL;
+ const char *format_str = NULL;
if ((ret = __get_dbus_connection(&conn)) != SOUND_MANAGER_ERROR_NONE)
return ret;
#include <stdlib.h>
#include <sound_manager.h>
+#include <sound_manager_private.h>
#include <sound_manager_internal.h>
#include <mm_sound.h>
#include <pthread.h>
int g_device_conn_cb_id;
int g_device_running_cb_id;
+static const char g_running_str[] = { 'x', 'o' };
static const char *g_device_direction_str[] = {"IN", "OUT", "BOTH"};
static const char *g_device_type_str[] = {"builtin-speaker", "builtin-receiver", "builtin-mic",
"audio-jack", "bt-media", "hdmi",
/* If failed to get some property, just give some default value */
void _get_device_props_simple(sound_device_h device, int *id, const char **type, char **name,
- const char **direction, int *vendor_id, int *product_id, bool *is_running)
+ const char **direction, int *vendor_id, int *product_id, bool *is_running,
+ sound_sample_format_e *format, sound_sample_rate_e *samplerate, int *channels)
{
int ret;
sound_device_type_e _type;
} else {
*is_running = running;
}
+
+ if ((ret = sound_manager_get_device_sample_format(device, format)))
+ g_print("failed to get sample format, ret[0x%x]\n", ret);
+
+ if ((ret = sound_manager_get_device_sample_rate(device, samplerate)))
+ g_print("failed to get samplerate, ret[0x%x]\n", ret);
+
+ if ((ret = sound_manager_get_device_channels(device, channels)))
+ g_print("failed to get channels, ret[0x%x]\n", ret);
}
void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
char *name;
const char *type, *direction;
bool is_running = false;
+ sound_sample_format_e format;
+ sound_sample_rate_e samplerate = -1;
+ int channels = 0;
- _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &is_running);
+ _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &is_running, &format, &samplerate, &channels);
g_print("\n[ Device #%d %-20s ] %15s : ", id, type, is_connected ? "Connected" : "Disconnected");
- g_print("Direction[%-4s] Running[%d] Vendor/Product ID[%04x/%04x] Name[%s]\n",
- direction, is_running, vendor_id, product_id, name);
+ g_print("Direction[%-4s] Running[%d] Format[%d], Samplerate[%d] Channels[%d] Vendor/Product ID[%04x/%04x] Name[%s]\n",
+ direction, is_running, format, samplerate, channels, vendor_id, product_id, name);
}
void _device_running_changed_cb(sound_device_h device, bool is_running, void *user_data)
char *name;
const char *type, *direction;
bool _is_running = false;
+ sound_sample_format_e format;
+ sound_sample_rate_e samplerate = -1;
+ int channels = 0;
- _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &_is_running);
+ _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &_is_running, &format, &samplerate, &channels);
g_print("\n[ Device #%d %-20s ] running changed to [%d] : ", id, type, is_running);
- g_print("Direction [%-4s] Running[%d] Vendor/Product ID[%04x/%04x] Name[%s]\n",
- direction, is_running, vendor_id, product_id, name);
+ g_print("Direction[%-4s] Running[%d] Format[%d], Samplerate[%d] Channels[%d] Vendor/Product ID[%04x/%04x] Name[%s]\n",
+ direction, is_running, format, samplerate, channels, vendor_id, product_id, name);
}
void reset_menu_state(void)
sound_sample_format_e *formats;
sound_sample_rate_e *rates;
+ sound_sample_format_e format;
+ const char *format_str = NULL;
+ sound_sample_rate_e samplerate = -1;
+ unsigned int samplerate_num = 0;
+ int channels = 0;
+
if (!(ret = sound_manager_get_device_list(g_device_mask, &device_list))) {
g_print("success to get current device list\n");
while (!sound_manager_get_next_device(device_list, &device)) {
- _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &is_running);
+ _get_device_props_simple(device, &id, &type, &name, &direction, &vendor_id, &product_id, &is_running, &format, &samplerate, &channels);
+
+ if ((ret = _convert_sample_format_enum_to_str(format, &format_str)))
+ g_print("failed to convert format to string, ret[0x%x]\n", ret);
+ if ((ret = _convert_sample_rate_enum_to_uint(samplerate, &samplerate_num)))
+ g_print("failed to convert samplerate to uint, ret[0x%x]\n", ret);
+
g_print("[ Device #%d %-20s ] : ", id, type);
- g_print("Direction[%-4s] Running[%d] Vendor/Product ID[%04x/%04x] Name[%s] \n",
- direction, is_running, vendor_id, product_id, name);
+ g_print("Direction[%-4s] Running[%c] Format[%d][%s] SampleRate[%d][%u] Channels[%d] ID(Vendor/Product)[%04x/%04x] Name[%s] \n",
+ direction, g_running_str[is_running], format, format_str, samplerate, samplerate_num, channels, vendor_id, product_id, name);
if (!(ret = sound_manager_get_supported_sample_formats(device, &formats, &num))) {
g_print(" => [ ");