Tizen Native API

The Device API provides functions to query the information of sound devices.

Required Header

#include <sound_manager.h>

Overview

The Sound Manager Device API allows you to:

  • query the basic information of connected sound devices.
  • handle the sound device's connection and information change notification.

The list of currently connected sound device can be obtained by calling sound_manager_get_current_device_list(). To get the handle of each sound device, call sound_manager_get_next_device() and sound_manager_get_prev_device().

Device information, such as "type", "IO direction", "state", "ID", "name", can be obtained by calling corresponding APIs.

Functions

int sound_manager_get_current_device_list (sound_device_mask_e device_mask, sound_device_list_h *device_list)
 Gets the list consisting of connected devices.
int sound_manager_get_next_device (sound_device_list_h device_list, sound_device_h *device)
 Gets the next item of the device list.
int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device_h *device)
 Gets the previous item of the device list.
int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type)
 Gets the type of the device.
int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction)
 Gets the io direction of the device.
int sound_manager_get_device_id (sound_device_h device, int *id)
 Gets the id of the device.
int sound_manager_get_device_name (sound_device_h device, char **name)
 Gets the name of the device.
int sound_manager_get_device_state (sound_device_h device, sound_device_state_e *state)
 Gets the state of the device.
int sound_manager_set_device_connected_cb (sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data)
 Registers a callback function to be invoked when the state of connection of a sound device was changed.
int sound_manager_unset_device_connected_cb (void)
 Unregisters the callback function which is called when the state of connection of a sound device was changed.
int sound_manager_set_device_information_changed_cb (sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data)
 Registers a callback function to be invoked when the information of a sound device was changed.
int sound_manager_unset_device_information_changed_cb (void)
 Unregisters the callback function which is called when the information of a sound device was changed.

Typedefs

typedef void * sound_device_h
 sound device handle
typedef void * sound_device_list_h
 sound device list handle
typedef void(* sound_device_connected_cb )(sound_device_h device, bool is_connected, void *user_data)
 Called when the state of connection of a sound device was changed.
typedef void(* sound_device_information_changed_cb )(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
 Called when the information of a sound device was changed.

Typedef Documentation

typedef void(* sound_device_connected_cb)(sound_device_h device, bool is_connected, void *user_data)

Called when the state of connection of a sound device was changed.

Since :
2.3.1
Parameters:
[in]sound_device_hThe sound_device
[in]is_connectedThe state of device connection
[in]user_dataThe user data passed from the callback registration function
Precondition:
You should register this callback using sound_manager_set_device_connected_cb().
See also:
sound_manager_set_device_connected_cb()
sound_manager_unset_device_connected_cb()
typedef void* sound_device_h

sound device handle

Since :
2.3.1
typedef void(* sound_device_information_changed_cb)(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)

Called when the information of a sound device was changed.

Since :
2.3.1
Parameters:
[in]sound_device_hThe sound_device
[in]changed_infoThe entry of sound device information
[in]user_dataThe user data passed from the callback registration function
Precondition:
You should register this callback using sound_manager_set_device_information_changed_cb().
See also:
sound_manager_set_device_information_changed_cb()
sound_manager_unset_device_information_changed_cb()
typedef void* sound_device_list_h

sound device list handle

Since :
2.3.1

Enumeration Type Documentation

Enumeration for changed information of sound device.

Since :
2.3.1
Enumerator:
SOUND_DEVICE_CAHNGED_INFO_STATE 

State of the device was changed

SOUND_DEVICE_CHANGED_INFO_IO_DIRECTION 

IO direction of the device was changed

Enumeration for sound device direction.

Since :
2.3.1
Enumerator:
SOUND_DEVICE_IO_DIRECTION_IN 

Input device

SOUND_DEVICE_IO_DIRECTION_OUT 

Output device

SOUND_DEVICE_IO_DIRECTION_BOTH 

Input/output device (both directions are available)

Enumeration for sound device mask.

Since :
2.3.1
Enumerator:
SOUND_DEVICE_IO_DIRECTION_IN_MASK 

Mask for input devices

SOUND_DEVICE_IO_DIRECTION_OUT_MASK 

Mask for output devices

SOUND_DEVICE_IO_DIRECTION_BOTH_MASK 

Mask for input/output devices (both directions are available)

SOUND_DEVICE_TYPE_INTERNAL_MASK 

Mask for built-in devices

SOUND_DEVICE_TYPE_EXTERNAL_MASK 

Mask for external devices

SOUND_DEVICE_STATE_DEACTIVATED_MASK 

Mask for deactivated devices

SOUND_DEVICE_STATE_ACTIVATED_MASK 

Mask for activated devices

SOUND_DEVICE_ALL_MASK 

Mask for all devices

Enumeration for sound device state.

Since :
2.3.1
Enumerator:
SOUND_DEVICE_STATE_DEACTIVATED 

Deactivated state

SOUND_DEVICE_STATE_ACTIVATED 

Activated state

Enumeration for sound device type.

Since :
2.3.1
Enumerator:
SOUND_DEVICE_BUILTIN_SPEAKER 

Built-in speaker

SOUND_DEVICE_BUILTIN_RECEIVER 

Built-in receiver

SOUND_DEVICE_BUILTIN_MIC 

Built-in mic

SOUND_DEVICE_AUDIO_JACK 

Audio jack that can be connected to wired accessory such as headphone, headset, and so on

SOUND_DEVICE_BLUETOOTH 

Bluetooth

SOUND_DEVICE_HDMI 

HDMI

SOUND_DEVICE_MIRRORING 

MIRRORING

SOUND_DEVICE_USB_AUDIO 

USB Audio


Function Documentation

Gets the list consisting of connected devices.

Since :
2.3.1
Parameters:
[in]device_maskThe mask value
[out]device_listThe list of connected devices
Remarks:
Use sound_manager_get_next_device() to get the first node of the list.
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_NO_DATANo data
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_name()
sound_manager_get_device_state()
int sound_manager_get_device_id ( sound_device_h  device,
int *  id 
)

Gets the id of the device.

Since :
2.3.1
Parameters:
[in]deviceThe device item
[out]idThe id of the device
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_name()
sound_manager_get_device_state()

Gets the io direction of the device.

Since :
2.3.1
Parameters:
[in]deviceThe device item
[out]io_directionThe io direction of the device
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_id()
sound_manager_get_device_name()
sound_manager_get_device_state()
int sound_manager_get_device_name ( sound_device_h  device,
char **  name 
)

Gets the name of the device.

Since :
2.3.1
Parameters:
[in]deviceThe device item
[out]nameThe name of the device
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_state()

Gets the state of the device.

Since :
2.3.1
Parameters:
[in]deviceThe device item
[out]stateThe state of the device
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_name()

Gets the type of the device.

Since :
2.3.1
Parameters:
[in]deviceThe device item
[out]typeThe type of the device
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_prev_device()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_name()
sound_manager_get_device_state()

Gets the next item of the device list.

Since :
2.3.1
Parameters:
[in]device_listThe list of connected devices
[out]deviceThe device item
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_NO_DATANo data
See also:
sound_manager_get_current_device_list()
sound_manager_get_prev_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_name()
sound_manager_get_device_state()

Gets the previous item of the device list.

Since :
2.3.1
Parameters:
[in]device_listThe list of connected devices
[out]deviceThe device item
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_NO_DATANo data
See also:
sound_manager_get_current_device_list()
sound_manager_get_next_device()
sound_manager_get_device_type()
sound_manager_get_device_io_direction()
sound_manager_get_device_id()
sound_manager_get_device_name()
sound_manager_get_device_state()
int sound_manager_set_device_connected_cb ( sound_device_mask_e  device_mask,
sound_device_connected_cb  callback,
void *  user_data 
)

Registers a callback function to be invoked when the state of connection of a sound device was changed.

Since :
2.3.1
Parameters:
[in]device_maskThe mask value
[in]callbackThe interrupted callback function
[in]user_dataThe user data to be passed to the callback function
Remarks:
The initial state of sound devices connected is deactivated.
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
Postcondition:
sound_device_connected_cb() will be invoked.
See also:
sound_manager_unset_device_connected_cb()
sound_device_connected_cb()

Registers a callback function to be invoked when the information of a sound device was changed.

Since :
2.3.1
Parameters:
[in]device_maskThe mask value
[in]callbackThe interrupted callback function
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
Postcondition:
sound_device_information_changed_cb() will be invoked.
See also:
sound_manager_unset_device_information_changed_cb()
sound_device_information_changed_cb()

Unregisters the callback function which is called when the state of connection of a sound device was changed.

Since :
2.3.1
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_set_device_connected_cb()

Unregisters the callback function which is called when the information of a sound device was changed.

Since :
2.3.1
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_set_device_information_changed_cb()