Sound Manager
The sound manager allows you to control the audio behavior of your application.
The main features of the Sound Manager API include:
-
Volume control
Control the output volume by managing the sound type and its volume level.
-
Sound session types
Set the sound session type, which specifies the behavior of your application sound across the system.
-
Sound device query
Using the query functions, you can get various information, such as the state of the sound devices.
Volume Control
You can manage the volume level of a particular sound type. With the Sound Manager API, you can set and get a volume level and a maximum volume level of a particular sound type.
Normally, if there is an active output stream, the sound_manager_get_current_sound_type() function returns the sound type of that stream, and if not, it returns an error message. However, you can set a particular sound type as current using the sound_manager_set_current_sound_type() function. This enables other applications, such as a volume application, to manage the volume level of the particular sound type even though it is not currently playing.
Note |
---|
Setting the current sound type affects the entire system. When no longer needed, unset the current sound type using the sound_manager_unset_current_sound_type() function. |
Sound Session Types
The Sound Manager API offers 5 different sound session types: media, alarm, notification, emergency and VOIP. According to these types, your application's audio works in a specific way to mix with sounds of other applications or to respond to an audio interruption made by another application.
The alarm, notification, emergency, and VOIP sessions are prioritized over the media session. For example, when an alarm is activated while you are playing a media file, the system pauses the media session, and the alarm session gets the permission to play its sound.
You can set options for how to start a new media session or respond to an audio interruption during an active media session using the sound_session_option_for_start_e (in mobile and wearable applications) and sound_session_option_for_during_play_e (in mobile and wearable applications) enumerators. A media session is not able to interrupt or block the other types of sound sessions, no matter what options you have set.
You can also set options for resuming the media session when the interruption ends by using the sound_session_option_for_resumption_e enumerator (in mobile and wearable applications). The sound system notifies the media session when the interruption ends, and you are able to resume your session.
Sound Device Query
The audio behavior of your application must differ in accordance with the various sound devices that are connected.
Use the sound_manager_get_current_device_list() function to get the list handle of the currently connected sound devices. With the sequential search of this device list, you can get the device handle of each device on the list. You can use the sound_manager_get_next_device() and sound_manager_get_prev_device() functions for a sequential search of the device list.
With the device handle, you can query the sound device information with the following functions:
- sound_manger_get_device_type(): To get the device type.
- sound_manager_get_device_io_direction(): To get the device IO direction.
- sound_manager_get_device_id(): To get the device ID.
- sound_manager_get_device_name(): To get the device name.
- sound_manager_get_device_state(): To get the device state.
To get a notification when the sound device connection or information has changed, register the sound_manager_set_device_connected_cb() and sound_manager_set_device_information_changed_cb() callbacks. The initial state of the connected sound device is deactivated.
When getting a sound device list or setting callbacks, use the sound_device_mask_e enumerator (in mobile and wearable applications) to specify the sound devices that you want. With a combination of the masks, you can to narrow down the sound devices to those you actually need.