Tizen Native API
5.0
|
The Radio APIs provide functions for accessing the radio.
#include <radio.h>
The Radio API provides support for using the Radio. The API allows :
A radio handle (radio_h) is created by calling the radio_create() function and can be started by using the radio_start() function. It provides functions to start (radio_scan_start()) and stop (radio_scan_stop()) radio signal scanning. The radio frequency seek up and seek down can be done asynchronously by calling the radio_seek_up() and radio_seek_down() functions respectively. It also provides functions to get (radio_get_frequency()) and set (radio_set_frequency()) frequency for the given radio handle.
The radio API is controlled by a state machine. The following diagram shows the life cycle and the states of the Radio.
FUNCTION | PRE-STATE | POST-STATE | SYNC TYPE |
---|---|---|---|
radio_create() | NONE | READY | SYNC |
radio_destroy() | READY | NONE | SYNC |
radio_start() | READY | PLAYING | SYNC |
radio_stop() | PLAYING | READY | SYNC |
radio_scan_start() | READY or PLAYING | SCANNING | ASYNC |
radio_scan_stop() | SCANNING | READY or PLAYING | ASYNC |
radio_seek_up() | PLAYING | PLAYING | ASYNC |
radio_seek_down() | PLAYING | PLAYING | ASYNC |
This API also gives notifications for radio's state change events by a callback mechanism.
The callback mechanism is used to notify the application about radio events.
REGISTER | UNREGISTER | CALLBACK | DESCRIPTION |
---|---|---|---|
radio_set_scan_completed_cb() | radio_unset_scan_completed_cb() | radio_scan_completed_cb() | This callback is invoked when the scan is completed |
radio_set_interrupted_cb() | radio_unset_interrupted_cb() | radio_interrupted_cb() | This callback is used to notify when the radio is interrupted |
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | radio_create (radio_h *radio) |
Creates a radio handle. | |
int | radio_destroy (radio_h radio) |
Destroys the radio handle and releases all its resources. | |
int | radio_get_state (radio_h radio, radio_state_e *state) |
Gets the radio's current state. | |
int | radio_start (radio_h radio) |
Starts playing the radio. | |
int | radio_stop (radio_h radio) |
Stops playing the radio. | |
int | radio_seek_up (radio_h radio, radio_seek_completed_cb callback, void *user_data) |
Seeks up the effective frequency of the radio, asynchronously. | |
int | radio_seek_down (radio_h radio, radio_seek_completed_cb callback, void *user_data) |
Seeks down the effective frequency of the radio, asynchronously. | |
int | radio_set_frequency (radio_h radio, int frequency) |
Sets the radio frequency. | |
int | radio_get_frequency (radio_h radio, int *frequency) |
Gets the current frequency of the radio. | |
int | radio_get_signal_strength (radio_h radio, int *strength) |
Gets the current signal strength of the radio. | |
int | radio_scan_start (radio_h radio, radio_scan_updated_cb callback, void *user_data) |
Starts scanning radio signals, asynchronously. | |
int | radio_scan_stop (radio_h radio, radio_scan_stopped_cb callback, void *user_data) |
Stops scanning radio signals, asynchronously. | |
int | radio_set_mute (radio_h radio, bool muted) |
Sets the radio's mute status. | |
int | radio_is_muted (radio_h radio, bool *muted) |
Gets the radio's mute status. | |
int | radio_set_scan_completed_cb (radio_h radio, radio_scan_completed_cb callback, void *user_data) |
Sets a callback function to be invoked when the scan finishes. | |
int | radio_unset_scan_completed_cb (radio_h radio) |
Unsets the scan completed callback function. | |
int | radio_set_interrupted_cb (radio_h radio, radio_interrupted_cb callback, void *user_data) |
Sets a callback function to be invoked when the radio is interrupted. | |
int | radio_unset_interrupted_cb (radio_h radio) |
Unsets the interrupted callback function. | |
int | radio_get_frequency_range (radio_h radio, int *min_freq, int *max_freq) |
Gets the min, max frequency of the region. | |
int | radio_get_channel_spacing (radio_h radio, int *channel_spacing) |
Gets channel spacing. | |
int | radio_set_volume (radio_h radio, float volume) |
Sets the radio's volume. | |
int | radio_get_volume (radio_h radio, float *volume) |
Gets the radio's current volume. | |
Typedefs | |
typedef struct radio_s * | radio_h |
Radio type handle. | |
typedef void(* | radio_scan_updated_cb )(int frequency, void *user_data) |
Called when the scan information is updated. | |
typedef void(* | radio_scan_stopped_cb )(void *user_data) |
Called when the radio scan is stopped. | |
typedef void(* | radio_scan_completed_cb )(void *user_data) |
Called when the radio scan is completed. | |
typedef void(* | radio_seek_completed_cb )(int frequency, void *user_data) |
Called when the radio seek is completed. | |
typedef void(* | radio_interrupted_cb )(radio_interrupted_code_e code, void *user_data) |
Called when the radio is interrupted. |
typedef struct radio_s* radio_h |
Radio type handle.
typedef void(* radio_interrupted_cb)(radio_interrupted_code_e code, void *user_data) |
Called when the radio is interrupted.
[in] | code | The interrupted error code |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* radio_scan_completed_cb)(void *user_data) |
Called when the radio scan is completed.
[in] | user_data | The user data passed from the callback registration function |
typedef void(* radio_scan_stopped_cb)(void *user_data) |
Called when the radio scan is stopped.
[in] | user_data | The user data passed from the callback registration function |
typedef void(* radio_scan_updated_cb)(int frequency, void *user_data) |
Called when the scan information is updated.
[in] | frequency | The tuned radio frequency [87500 ~ 108000] (kHz) |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* radio_seek_completed_cb)(int frequency, void *user_data) |
Called when the radio seek is completed.
[in] | frequency | The current frequency [87500 ~ 108000] (kHz) |
[in] | user_data | The user data passed from the callback registration function |
enum radio_error_e |
Enumeration of error codes for the radio.
enum radio_state_e |
int radio_create | ( | radio_h * | radio | ) |
Creates a radio handle.
[out] | radio | A new handle to radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_OUT_OF_MEMORY | Out of memory |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_destroy | ( | radio_h | radio | ) |
Destroys the radio handle and releases all its resources.
[in] | radio | The handle to radio to be destroyed |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_channel_spacing | ( | radio_h | radio, |
int * | channel_spacing | ||
) |
Gets channel spacing.
[in] | radio | The handle to radio |
[out] | channel_spacing | The channel spacing value |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_frequency | ( | radio_h | radio, |
int * | frequency | ||
) |
Gets the current frequency of the radio.
[in] | radio | The handle to radio |
[out] | frequency | The current frequency [87500 ~ 108000] (kHz) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_frequency_range | ( | radio_h | radio, |
int * | min_freq, | ||
int * | max_freq | ||
) |
Gets the min, max frequency of the region.
[in] | radio | The handle to radio |
[out] | min_freq | The min frequency [87500 ~ 108000] (kHz) |
[out] | max_freq | The max frequency [87500 ~ 108000] (kHz) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_signal_strength | ( | radio_h | radio, |
int * | strength | ||
) |
Gets the current signal strength of the radio.
[in] | radio | The handle to radio |
[out] | strength | The current signal strength [-128 ~ 128] (dBm) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_state | ( | radio_h | radio, |
radio_state_e * | state | ||
) |
Gets the radio's current state.
[in] | radio | The handle to radio |
[out] | state | The current state of the radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_get_volume | ( | radio_h | radio, |
float * | volume | ||
) |
Gets the radio's current volume.
The range of volume is from 0
to 1.0
, inclusive (1.0 = 100%). This function gets the radio volume, not the system volume. To get the system volume, use the Sound Manager API.
[in] | radio | The handle to radio |
[out] | volume | The current volume [0.0 ~ 1.0](1.0 = 100%) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_is_muted | ( | radio_h | radio, |
bool * | muted | ||
) |
Gets the radio's mute status.
If the mute status is true
, no sounds are played. If false
, sounds are played.
[in] | radio | The handle to radio |
[out] | muted | The current mute status: (true = mute, false = not muted) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_scan_start | ( | radio_h | radio, |
radio_scan_updated_cb | callback, | ||
void * | user_data | ||
) |
Starts scanning radio signals, asynchronously.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_scan_stop | ( | radio_h | radio, |
radio_scan_stopped_cb | callback, | ||
void * | user_data | ||
) |
Stops scanning radio signals, asynchronously.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid state |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_seek_down | ( | radio_h | radio, |
radio_seek_completed_cb | callback, | ||
void * | user_data | ||
) |
Seeks down the effective frequency of the radio, asynchronously.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_seek_up | ( | radio_h | radio, |
radio_seek_completed_cb | callback, | ||
void * | user_data | ||
) |
Seeks up the effective frequency of the radio, asynchronously.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_set_frequency | ( | radio_h | radio, |
int | frequency | ||
) |
Sets the radio frequency.
[in] | radio | The handle to radio |
[in] | frequency | The frequency to set [87500 ~ 108000] (kHz) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_set_interrupted_cb | ( | radio_h | radio, |
radio_interrupted_cb | callback, | ||
void * | user_data | ||
) |
Sets a callback function to be invoked when the radio is interrupted.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_set_mute | ( | radio_h | radio, |
bool | muted | ||
) |
Sets the radio's mute status.
If the mute status is true
, no sounds will be played. If false
, sounds will be played. Until this function is called, by default the radio is not muted.
[in] | radio | The handle to radio |
[in] | muted | The new mute status: (true = mute, false = not muted) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_set_scan_completed_cb | ( | radio_h | radio, |
radio_scan_completed_cb | callback, | ||
void * | user_data | ||
) |
Sets a callback function to be invoked when the scan finishes.
[in] | radio | The handle to radio |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_set_volume | ( | radio_h | radio, |
float | volume | ||
) |
Sets the radio's volume.
Setting this volume adjusts the radio's instance volume, not the system volume. The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. To change system volume, use the Sound Manager API. Finally, it does not support to set other value into each channel currently.
[in] | radio | The handle to radio |
[in] | volume | The volume to set [0.0 ~ 1.0](1.0 = 100%) |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_start | ( | radio_h | radio | ) |
Starts playing the radio.
[in] | radio | The handle to radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_SOUND_POLICY | Sound policy error |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
RADIO_ERROR_NO_ANTENNA | No Antenna error |
int radio_stop | ( | radio_h | radio | ) |
Stops playing the radio.
[in] | radio | The handle to radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid state |
RADIO_ERROR_INVALID_STATE | Invalid radio state |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_unset_interrupted_cb | ( | radio_h | radio | ) |
Unsets the interrupted callback function.
[in] | radio | The handle to radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |
int radio_unset_scan_completed_cb | ( | radio_h | radio | ) |
Unsets the scan completed callback function.
[in] | radio | The handle to radio |
0
on success, otherwise a negative error value RADIO_ERROR_NONE | Successful |
RADIO_ERROR_INVALID_PARAMETER | Invalid parameter |
RADIO_ERROR_INVALID_OPERATION | Invalid operation |
RADIO_ERROR_NOT_SUPPORTED | Not supported |