Tizen Native API
3.0
|
The Stream Policy API provides functions to control a sound stream.
Required Header
#include <sound_manager.h>
Overview
The Sound Manager Stream API allows you to:
- determine/control a sound stream policy
- handle the notification of a sound focus status change
The Sound Manager has predefined sound stream types (media, system, alarm, notification, emergency, voip, etc)
Functions | |
int | sound_manager_create_stream_information (sound_stream_type_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info) |
Creates a handle for stream information. | |
int | sound_manager_destroy_stream_information (sound_stream_info_h stream_info) |
Destroys the handle for stream information. | |
int | sound_manager_get_sound_type (sound_stream_info_h stream_info, sound_type_e *sound_type) |
Gets the sound type of the stream information. | |
int | sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device) |
Adds the device to the stream information for the stream routing. | |
int | sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device) |
Removes the device to the stream information for the stream routing. | |
int | sound_manager_apply_stream_routing (sound_stream_info_h stream_info) |
Applies the stream routing. | |
int | sound_manager_acquire_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info) |
Acquires the stream focus. | |
int | sound_manager_release_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info) |
Releases the acquired focus. | |
int | sound_manager_get_focus_state (sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording) |
Gets the state of focus. | |
int | sound_manager_set_focus_reacquisition (sound_stream_info_h stream_info, bool enable) |
Sets auto focus reacquisition property. | |
int | sound_manager_get_focus_reacquisition (sound_stream_info_h stream_info, bool *enabled) |
Gets auto focus reacquisition property. | |
int | sound_manager_is_stream_on_device (sound_stream_info_h stream_info, sound_device_h device, bool *is_on) |
Checks if the stream information is using the device. | |
int | sound_manager_get_current_media_playback_device_type (sound_device_type_e *device_type) |
Gets the current device type for media playback stream. | |
int | sound_manager_get_current_playback_focus (sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info) |
Gets the reason for the current acquired playback focus. | |
int | sound_manager_get_current_recording_focus (sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info) |
Gets the reason for the current acquired recording focus. | |
int | sound_manager_add_focus_state_watch_cb (sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data, int *id) |
Registers the watch callback function to be invoked when the focus state for each sound stream type is changed regardless of the process. | |
int | sound_manager_remove_focus_state_watch_cb (int id) |
Unregisters the focus state change watch callback. | |
Typedefs | |
typedef struct sound_stream_info_s * | sound_stream_info_h |
Sound stream information handle. | |
typedef void(* | sound_stream_focus_state_changed_cb )(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data) |
Called when the state of focus that belongs to the stream_info is changed. | |
typedef void(* | sound_stream_focus_state_watch_cb )(int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) |
Called when the focus state for each sound stream type is changed regardless of the process. |
Typedef Documentation
typedef void(* sound_stream_focus_state_changed_cb)(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data) |
Called when the state of focus that belongs to the stream_info is changed.
- Since :
- 3.0
- Remarks:
- This function is issued in the internal thread of the sound manager.
Therefore it is recommended not to call UI update function in this function.
- Parameters:
-
[in] stream_info The handle of stream information [in] focus_mask The changed focus mask [in] focus_state The changed focus state [in] reason The reason for state change of the focus [in] sound_behavior The requested sound behavior that should be followed, values of sound_behavior_e combined with bitwise 'or' [in] extra_info The extra information [in] user_data The user data passed from the callback registration function
- Precondition:
- You should register this callback using sound_manager_create_stream_information().
typedef void(* sound_stream_focus_state_watch_cb)(int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) |
Called when the focus state for each sound stream type is changed regardless of the process.
- Since :
- 3.0
- Remarks:
- This function is invoked by the internal thread of the sound manager.
Therefore it is recommended not to call functions which update the UI from this callback.
- Parameters:
-
[in] id The focus state change watch cb id [in] focus_mask The changed focus mask [in] focus_state The changed focus state [in] reason The reason for state change of the focus [in] extra_info The extra information [in] user_data The user data passed from the callback registration function
- Precondition:
- You should register this callback using sound_manager_add_focus_state_watch_cb().
typedef struct sound_stream_info_s* sound_stream_info_h |
Sound stream information handle.
- Since :
- 3.0
Enumeration Type Documentation
enum sound_behavior_e |
Enumeration for sound behavior.
- Since :
- 3.0
- Remarks:
- These values can be combined with bitwise 'or'.
Enumeration for change reason of sound stream focus state.
- Since :
- 3.0
- Enumerator:
enum sound_stream_type_e |
Enumeration for sound stream type.
- Since :
- 3.0
- Enumerator:
Function Documentation
int sound_manager_acquire_focus | ( | sound_stream_info_h | stream_info, |
sound_stream_focus_mask_e | focus_mask, | ||
int | sound_behavior, | ||
const char * | extra_info | ||
) |
Acquires the stream focus.
- Since :
- 3.0
- Remarks:
- Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
- Parameters:
-
[in] stream_info The handle of stream information [in] focus_mask The focus mask that user wants to acquire [in] sound_behavior The requesting sound behavior, values of sound_behavior_e combined with bitwise 'or' [in] extra_info The extra information for this request (optional, this can be NULL)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_INVALID_STATE Invalid state SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- Precondition:
- Call sound_manager_create_stream_information() with its parameter for sound_stream_focus_state_changed_cb before calling this function.
int sound_manager_add_device_for_stream_routing | ( | sound_stream_info_h | stream_info, |
sound_device_h | device | ||
) |
Adds the device to the stream information for the stream routing.
- Since :
- 3.0
- Remarks:
- Use sound_manager_get_device_list() and sound_manager_get_next_device() to get the device.
SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the stream_info.
The available types of the stream_info for this function are SOUND_STREAM_TYPE_VOIP and SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY.
- Parameters:
-
[in] stream_info The handle of stream information [in] device The device item from sound_device_list_h
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- Precondition:
- Call sound_manager_create_stream_information() before calling this function.
- Postcondition:
- You can apply this setting by calling sound_manager_apply_stream_routing().
int sound_manager_add_focus_state_watch_cb | ( | sound_stream_focus_mask_e | focus_mask, |
sound_stream_focus_state_watch_cb | callback, | ||
void * | user_data, | ||
int * | id | ||
) |
Registers the watch callback function to be invoked when the focus state for each sound stream type is changed regardless of the process.
- Since :
- 3.0
- Remarks:
- The registered callback is invoked by the internal thread of the sound manager.
Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
- Parameters:
-
[in] focus_mask The focus mask that user wants to watch [in] callback The focus state change watch callback function [in] user_data The user data to be passed to the callback function [out] id The focus state change watch callback id
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
int sound_manager_apply_stream_routing | ( | sound_stream_info_h | stream_info | ) |
Applies the stream routing.
- Since :
- 3.0
- Remarks:
- If the stream has not been made yet, this setting will be applied when the stream starts to play.
- Parameters:
-
[in] stream_info The handle of stream information
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_STATE Invalid state SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- Precondition:
- Call sound_manager_create_stream_information() and sound_manager_add_device_for_stream_routing() before calling this function.
int sound_manager_create_stream_information | ( | sound_stream_type_e | stream_type, |
sound_stream_focus_state_changed_cb | callback, | ||
void * | user_data, | ||
sound_stream_info_h * | stream_info | ||
) |
Creates a handle for stream information.
- Since :
- 3.0
- Remarks:
- The registered callback is issued in the internal thread of the sound manager.
Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
To apply the stream policy according to this stream information, this handle should be passed to other APIs
related to playback or recording.(e.g. player, wav-player, audio-io, etc.)
- Parameters:
-
[in] stream_type The type of stream [in] callback The focus state change callback function (optional, this can be NULL) [in] user_data The user data to be passed to the callback function (optional, this can be NULL) [out] stream_info The handle of stream information
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
int sound_manager_destroy_stream_information | ( | sound_stream_info_h | stream_info | ) |
Destroys the handle for stream information.
- Since :
- 3.0
- Remarks:
- Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
- Parameters:
-
[in] stream_info The handle of stream information
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
int sound_manager_get_current_media_playback_device_type | ( | sound_device_type_e * | device_type | ) |
Gets the current device type for media playback stream.
- Since :
- 3.0
- Parameters:
-
[out] device_type The output device type that a media playback stream can go out
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_NO_DATA No data
int sound_manager_get_current_playback_focus | ( | sound_stream_focus_change_reason_e * | acquired_by, |
int * | sound_behavior, | ||
char ** | extra_info | ||
) |
Gets the reason for the current acquired playback focus.
- Since :
- 3.0
- Remarks:
- If there is no acquired playback focus in this system, it'll return SOUND_MANAGER_ERROR_NO_DATA.
Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
The extra_info should be released using free().
- Parameters:
-
[out] acquired_by The reason for the current acquired playback focus [out] sound_behavior The requested sound behavior that should be followed, values of sound_behavior_e combined with bitwise 'or' [out] extra_info The extra information of the acquired playback focus (optional, this can be NULL)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_NO_DATA No data
int sound_manager_get_current_recording_focus | ( | sound_stream_focus_change_reason_e * | acquired_by, |
int * | sound_behavior, | ||
char ** | extra_info | ||
) |
Gets the reason for the current acquired recording focus.
- Since :
- 3.0
- Remarks:
- If there is no acquired recording focus in this system, it'll return SOUND_MANAGER_ERROR_NO_DATA.
Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
The extra_info should be released using free().
- Parameters:
-
[out] acquired_by The reason for the current acquired recording focus [out] sound_behavior The requested sound behavior that should be followed, values of sound_behavior_e combined with bitwise 'or' [out] extra_info The extra information of the acquired recording focus (optional, this can be NULL)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_NO_DATA No data
int sound_manager_get_focus_reacquisition | ( | sound_stream_info_h | stream_info, |
bool * | enabled | ||
) |
Gets auto focus reacquisition property.
- Since :
- 3.0
- Remarks:
- The default value is true.
- Parameters:
-
[in] stream_info The handle of stream information [out] enabled The value of focus auto reacquisition property : ( true
= enabled,false
= disabled)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- Precondition:
- Call sound_manager_create_stream_information() before calling this function.
int sound_manager_get_focus_state | ( | sound_stream_info_h | stream_info, |
sound_stream_focus_state_e * | state_for_playback, | ||
sound_stream_focus_state_e * | state_for_recording | ||
) |
Gets the state of focus.
- Since :
- 3.0
- Parameters:
-
[in] stream_info The handle of stream information [out] state_for_playback The state of playback focus [out] state_for_recording The state of recording focus
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- Precondition:
- Call sound_manager_create_stream_information() before calling this function.
int sound_manager_get_sound_type | ( | sound_stream_info_h | stream_info, |
sound_type_e * | sound_type | ||
) |
Gets the sound type of the stream information.
- Since :
- 3.0
- Remarks:
- In case of a stream_info made with SOUND_STREAM_TYPE_EMERGENCY, it'll return SOUND_MANAGER_ERROR_NO_DATA.
The reason is that there is no sound_type_e matched with this stream_info.
- Parameters:
-
[in] stream_info The handle of stream information [out] sound_type The sound type
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_NO_DATA No data
- Precondition:
- Call sound_manager_create_stream_information() before calling this function.
int sound_manager_is_stream_on_device | ( | sound_stream_info_h | stream_info, |
sound_device_h | device, | ||
bool * | is_on | ||
) |
Checks if the stream information is using the device.
- Since :
- 3.0
- Parameters:
-
[in] stream_info The handle of stream information [in] device The device item [out] is_on Whether the stream info is using the device or not : ( true
= use,false
= not use)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
int sound_manager_release_focus | ( | sound_stream_info_h | stream_info, |
sound_stream_focus_mask_e | focus_mask, | ||
int | sound_behavior, | ||
const char * | extra_info | ||
) |
Releases the acquired focus.
- Since :
- 3.0
- Remarks:
- Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
- Parameters:
-
[in] stream_info The handle of stream information [in] focus_mask The focus mask that user wants to release [in] sound_behavior The requesting sound behavior, values of sound_behavior_e combined with bitwise 'or' [in] extra_info The extra information for this request (optional, this can be NULL)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_INVALID_STATE Invalid state SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- Precondition:
- Call sound_manager_create_stream_information() and sound_manager_acquire_focus() before calling this function.
int sound_manager_remove_device_for_stream_routing | ( | sound_stream_info_h | stream_info, |
sound_device_h | device | ||
) |
Removes the device to the stream information for the stream routing.
- Since :
- 3.0
- Remarks:
- Use sound_manager_get_device_list() and sound_manager_get_next_device() to get the device.
- Parameters:
-
[in] stream_info The handle of stream information [in] device The device item from sound_device_list_h
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- Precondition:
- Call sound_manager_create_stream_information() and sound_manager_add_device_for_stream_routing() before calling this function.
- Postcondition:
- You can apply this setting by calling sound_manager_apply_stream_routing().
int sound_manager_remove_focus_state_watch_cb | ( | int | id | ) |
Unregisters the focus state change watch callback.
- Since :
- 3.0
- Remarks:
- Do not call this function within sound_stream_focus_state_changed_cb() or sound_stream_focus_state_watch_cb(),
otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.
- Parameters:
-
[in] id The focus state change watch callback id
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
int sound_manager_set_focus_reacquisition | ( | sound_stream_info_h | stream_info, |
bool | enable | ||
) |
Sets auto focus reacquisition property.
- Since :
- 3.0
- Remarks:
- The focus reacquisition is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacquisition setting by using this function and vice versa.
- Parameters:
-
[in] stream_info The handle of stream information [in] enable The auto focus reacquisition property to set : ( true
= enable,false
= disable)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
SOUND_MANAGER_ERROR_NONE Success SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- Precondition:
- Call sound_manager_create_stream_information() before calling this function.