Tizen Native API

The Volume API provides functions to check and control volumes.

Required Header

#include <sound_manager.h>

Overview

The Sound Manager Volume API allows you to:

  • check/control output volumes
  • handle a volume changed notification

The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice).

Current volume level of each type can be checked with sound_manager_get_volume(). To get the maximum supported volume level of each type, call sound_manager_get_max_volume(). The volume level of each type can be adjusted with sound_manager_set_volume().

The type of currently playing sound may be obtained by calling sound_manager_get_current_sound_type(). To set the type of the currently playing sound forcibly, call sound_manager_set_current_sound_type().

Functions

int sound_manager_get_max_volume (sound_type_e type, int *max)
 Gets the maximum volume level supported for a particular sound type.
int sound_manager_set_volume (sound_type_e type, int volume)
 Sets the volume level specified for a particular sound type.
int sound_manager_get_volume (sound_type_e type, int *volume)
 Gets the volume level specified for a particular sound type.
int sound_manager_set_current_sound_type (sound_type_e type)
 Sets the type of the sound being currently played.
int sound_manager_get_current_sound_type (sound_type_e *type)
 Gets the type of the sound being currently played.
int sound_manager_unset_current_sound_type (void)
 Unsets the type of the sound being currently played.
int sound_manager_set_volume_changed_cb (sound_manager_volume_changed_cb callback, void *user_data)
 Registers a callback function to be invoked when the volume level is changed.
int sound_manager_unset_volume_changed_cb (void)
 Unregisters the volume change callback.

Typedefs

typedef void(* sound_manager_volume_changed_cb )(sound_type_e type, unsigned int volume, void *user_data)
 Called when the system volume has changed.

Typedef Documentation

typedef void(* sound_manager_volume_changed_cb)(sound_type_e type, unsigned int volume, void *user_data)

Called when the system volume has changed.

Since :
2.3.1
Parameters:
[in]typeThe sound type of the changed volume
[in]volumeThe new volume value
[in]user_dataThe user data passed from the callback registration function
Precondition:
sound_manager_set_volume() will invoke this callback if you register it using sound_manager_set_volume_changed_cb().
See also:
sound_manager_set_volume_changed_cb()
sound_manager_unset_volume_changed_cb()

Enumeration Type Documentation

Enumeration for sound type.

Since :
2.3.1
Enumerator:
SOUND_TYPE_SYSTEM 

Sound type for system

SOUND_TYPE_NOTIFICATION 

Sound type for notifications

SOUND_TYPE_ALARM 

Sound type for alarm

SOUND_TYPE_MEDIA 

Sound type for media

SOUND_TYPE_VOICE 

Sound type for voice


Function Documentation

Gets the type of the sound being currently played.

Since :
2.3.1
Parameters:
[out]typeThe current sound type
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_PLAYING_SOUNDNo playing sound
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_set_current_sound_type()
sound_manager_unset_current_sound_type()
int sound_manager_get_max_volume ( sound_type_e  type,
int *  max 
)

Gets the maximum volume level supported for a particular sound type.

Since :
2.3.1
Parameters:
[in]typeThe sound type
[out]maxThe maximum volume level
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_set_volume()
sound_manager_get_volume()
int sound_manager_get_volume ( sound_type_e  type,
int *  volume 
)

Gets the volume level specified for a particular sound type.

Since :
2.3.1
Parameters:
[in]typeThe sound type
[out]volumeThe current volume level
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_max_volume()
sound_manager_set_volume()

Sets the type of the sound being currently played.

Since :
2.3.1
Parameters:
[in]typeThe sound type to set
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_sound_type()
sound_manager_unset_current_sound_type()
int sound_manager_set_volume ( sound_type_e  type,
int  volume 
)

Sets the volume level specified for a particular sound type.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/volume.set
Parameters:
[in]typeThe sound type
[in]volumeThe volume level to be set
Returns:
0 on success, otherwise a negative error value
Return values:
SOUND_MANAGER_ERROR_NONESuccess
SOUND_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
SOUND_MANAGER_ERROR_PERMISSION_DENIEDPermission denied
SOUND_MANAGER_ERROR_INTERNALInternal error inside the sound system
See also:
sound_manager_get_max_volume()
sound_manager_get_volume()
int sound_manager_set_volume_changed_cb ( sound_manager_volume_changed_cb  callback,
void *  user_data 
)

Registers a callback function to be invoked when the volume level is changed.

Since :
2.3.1
Parameters:
[in]callbackCallback function to indicate change in volume
[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_manager_volume_changed_cb() will be invoked.
See also:
sound_manager_unset_volume_changed_cb()
sound_manager_volume_changed_cb()

Unsets the type of the sound being currently played.

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_current_sound_type()
sound_manager_get_current_sound_type()

Unregisters the volume change callback.

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_volume_changed_cb()