SOUND_DEVICE_STATE_ACTIVATED, /**< Activated state */
} sound_device_state_e;
+/**
+ * @brief Enumeration for Bluetooth sound device modes.
+ * @since_tizen 3.0
+ *
+ * @remarks This enumeration is only for Bluetooth devices.\n
+ * These values can be combined with bitwise 'or'.
+ */
+
+typedef enum {
+ SOUND_DEVICE_BLUETOOTH_MODE_MEDIA = 0x01, /**< Media mode (for music, system, and so on) */
+ SOUND_DEVICE_BLUETOOTH_MODE_VOICE = 0x02, /**< Voice mode (for call, voip, voice-recognition, and so on) */
+} sound_device_bluetooth_mode_e;
+
/**
* @brief Enumeration for sound device mask.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum {
- SOUND_DEVICE_CHANGED_INFO_STATE, /**< State of the device was changed */
- SOUND_DEVICE_CHANGED_INFO_IO_DIRECTION, /**< IO direction of the device was changed */
+ SOUND_DEVICE_CHANGED_INFO_STATE, /**< State of the device was changed */
+ SOUND_DEVICE_CHANGED_INFO_IO_DIRECTION, /**< IO direction of the device was changed */
+ SOUND_DEVICE_CHANGED_INFO_BT_AVAIL_MODES /**< Available modes of a Bluetooth device were changed (Since 3.0) */
} sound_device_changed_info_e;
/**
*/
int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state);
+/**
+ * @brief Gets the available modes of a Bluetooth device.
+ * @since_tizen 3.0
+ *
+ * @remarks This function is only for Bluetooth devices.
+ *
+ * @param[in] device The device of #SOUND_DEVICE_BLUETOOTH type
+ * @param[out] modes The available modes of the Bluetooth device, values of #sound_device_bluetooth_mode_e combined with bitwise 'or'
+ * @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_current_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_get_bt_device_avail_modes(sound_device_h device, int *modes);
+
/**
* @brief Registers a callback function to be invoked when the state of connection of a sound device was changed.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
#include <stdlib.h>
#include <sound_manager.h>
+#include <sound_manager_private.h>
#include <sound_manager_internal.h>
#include <mm_sound.h>
#include <pthread.h>
#include <glib.h>
#define MAX_STRING_LEN 2048
+#define NOT_AVAIL "N/A";
enum {
CURRENT_STATUS_MAINMENU,
sound_stream_info_h g_stream_info_h = NULL;
virtual_sound_stream_h g_vstream_h = NULL;
+static const char *g_device_direction_str[] = {"IN", "OUT", "BOTH"};
+static const char *g_device_state_str[] = {"De-Activated", "Activated"};
+static const char *g_device_avail_modes_str[] = {
+ [SOUND_DEVICE_BLUETOOTH_MODE_MEDIA] = "Media",
+ [SOUND_DEVICE_BLUETOOTH_MODE_VOICE] = "Voice",
+ [SOUND_DEVICE_BLUETOOTH_MODE_MEDIA | SOUND_DEVICE_BLUETOOTH_MODE_VOICE] = "Media & Voice"
+};
+
void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data)
{
int ret = SOUND_MANAGER_ERROR_NONE;
g_print("***your session has been interrupted by (%d)\n", code);
}
-void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
+/* If failed to get some property, just give some default value */
+void _get_device_props_simple(sound_device_h device, int *id, char **type, char **name,
+ const char **direc, const char **state, const char **avail_modes)
{
- sound_device_type_e type;
- sound_device_io_direction_e io_direction;
- sound_device_state_e state;
- int id;
- char *name;
- int ret = SOUND_MANAGER_ERROR_NONE;
+ int ret;
+ sound_device_type_e _type;
+ sound_device_io_direction_e _direc;
+ sound_device_state_e _state;
+ int _avail_modes;
+
+ 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(_type, type);
+ }
+
+ if ((ret = sound_manager_get_device_id(device, id))) {
+ g_print("failed to get device id, ret[0x%x]\n", ret);
+ *id = -1;
+ }
- g_print("***device connected callback is called, is_connected[%d]\n", is_connected);
+ if (_type == SOUND_DEVICE_BLUETOOTH || _type == SOUND_DEVICE_USB_AUDIO) {
+ if ((ret = sound_manager_get_device_name(device, name))) {
+ g_print("failed to get device name, ret[0x%x]\n", ret);
+ *name = NOT_AVAIL;
+ }
+ } else {
+ *name = "";
+ }
- if ((ret = sound_manager_get_device_type(device, &type)))
- g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
+ if ((ret = sound_manager_get_device_io_direction(device, &_direc))) {
g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id(device, &id)))
- g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name(device, &name)))
- g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state(device, &state)))
+ *direc = NOT_AVAIL;
+ } else {
+ *direc = g_device_direction_str[_direc];
+ }
+
+ if ((ret = sound_manager_get_device_state(device, &_state))) {
g_print("failed to get device state, ret[0x%x]\n", ret);
- if (!ret)
- g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ *state = NOT_AVAIL;
+ } else {
+ *state = g_device_state_str[_state];
+ }
+
+ if (_type == SOUND_DEVICE_BLUETOOTH) {
+ if ((ret = sound_manager_get_bt_device_avail_modes(device, &_avail_modes))) {
+ g_print("failed to get device avail_mode, ret[0x%x]\n", ret);
+ *avail_modes = NOT_AVAIL;
+ } else {
+ *avail_modes = g_device_avail_modes_str[_avail_modes];
+ }
+ } else {
+ *avail_modes = NOT_AVAIL;
+ }
+}
+
+void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
+{
+ int id = -1;
+ char *type, *name;
+ const char *direc, *state, *avail_modes;
+
+ _get_device_props_simple(device, &id, &type, &name, &direc, &state, &avail_modes);
+
+ g_print("[ Device #%d %s %s ] %s\n", id, type, name, is_connected ? "Connected" : "Disconnected");
+ g_print(" Direc[ %-4s ] State[ %-12s ] Avail-Modes[ %s ]\n", direc, state, avail_modes);
}
void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
{
- sound_device_type_e type;
- sound_device_io_direction_e io_direction;
- sound_device_state_e state;
- int id;
- char *name;
- int ret = SOUND_MANAGER_ERROR_NONE;
- g_print("***device information changed callback is called, changed_info[%d](0:STATE 1:IO_DIRECTION)\n", changed_info);
+ int id = -1;
+ char *type, *name;
+ const char *direc, *state, *avail_modes;
+ const char *changed_info_str[] = {"State", "Direction", "Avail-Mode"};
- if ((ret = sound_manager_get_device_type(device, &type)))
- g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
- g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id(device, &id)))
- g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name(device, &name)))
- g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state(device, &state)))
- g_print("failed to get device state, ret[0x%x]\n", ret);
- if (!ret)
- g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ _get_device_props_simple(device, &id, &type, &name, &direc, &state, &avail_modes);
+
+ g_print("[Device #%d %s %s] %s changed\n", id, type, name, changed_info_str[changed_info]);
+ g_print(" Direc[ %-4s ] State[ %-12s ] Avail-Modes[ %s ]\n", direc, state, avail_modes);
}
void reset_menu_state(void)