diff options
author | Jaechul Lee <jcsing.lee@samsung.com> | 2021-01-27 10:27:47 +0900 |
---|---|---|
committer | Jaechul Lee <jcsing.lee@samsung.com> | 2021-02-02 13:16:01 +0900 |
commit | 4951a4ddc4dab3fd08a77e1f4f86d98edcfeb291 (patch) | |
tree | 2c0fc6a0793c3fc2e734aaa9bb43ef0069f67521 /tizen-audio.h | |
parent | d7f5228919279736a8aa792a9d85d7435dd57d8b (diff) | |
download | audio-hal-sc7727-4951a4ddc4dab3fd08a77e1f4f86d98edcfeb291.tar.gz audio-hal-sc7727-4951a4ddc4dab3fd08a77e1f4f86d98edcfeb291.tar.bz2 audio-hal-sc7727-4951a4ddc4dab3fd08a77e1f4f86d98edcfeb291.zip |
Use hal interfacesubmit/tizen/20210204.010649submit/tizen/20210203.005915accepted/tizen/unified/20210204.134618
hal interfaces were added. Besides, structure and enum names were changed
for better readability. In case of enum, audio_return_t is changed to
audio_return_'e', and device_info_t is changed to device_info_'s'.
[Version] 0.1.35
[Issue Type] None
Change-Id: Idae678cf0a04838f3f150d74417b13d05ce77af0
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
Diffstat (limited to 'tizen-audio.h')
-rw-r--r-- | tizen-audio.h | 184 |
1 files changed, 38 insertions, 146 deletions
diff --git a/tizen-audio.h b/tizen-audio.h index f18afa4..5c662c4 100644 --- a/tizen-audio.h +++ b/tizen-audio.h @@ -21,6 +21,7 @@ #define footizenaudiofoo #include <stdint.h> +#include <hal/hal-audio-interface.h> /** * @file tizen-audio.h @@ -33,128 +34,6 @@ */ /** - * @brief Enumeration for return codes. - * @since_tizen 3.0 - */ -typedef enum audio_return { - AUDIO_RET_OK = 0, - AUDIO_ERR_UNDEFINED = (int32_t)0x80001000, - AUDIO_ERR_RESOURCE = (int32_t)0x80001001, - AUDIO_ERR_PARAMETER = (int32_t)0x80001002, - AUDIO_ERR_IOCTL = (int32_t)0x80001003, - AUDIO_ERR_INVALID_STATE = (int32_t)0x80001004, - AUDIO_ERR_INTERNAL = (int32_t)0x80001005, - /* add new enemerator here */ - AUDIO_ERR_NOT_IMPLEMENTED = (int32_t)0x80001100, -} audio_return_t ; - -/** - * @brief Enumeration for audio direction. - * @since_tizen 3.0 - */ -typedef enum audio_direction { - AUDIO_DIRECTION_IN, /**< Capture */ - AUDIO_DIRECTION_OUT, /**< Playback */ -} audio_direction_t; - -/** - * @brief Device information including type, direction and id. - * @since_tizen 3.0 - */ -typedef struct device_info { - const char *type; - uint32_t direction; - uint32_t id; -} device_info_t; - -/** - * @brief Volume information including type, gain and direction. - * @since_tizen 3.0 - */ -typedef struct audio_volume_info { - const char *type; - const char *gain; - uint32_t direction; -} audio_volume_info_t ; - -/** - * @brief Route information including role and device. - * @since_tizen 3.0 - */ -typedef struct audio_route_info { - const char *role; - device_info_t *device_infos; - uint32_t num_of_devices; -} audio_route_info_t; - -/** - * @brief Route option including role, name and value. - * @since_tizen 3.0 - */ -typedef struct audio_route_option { - const char *role; - const char *name; - int32_t value; -} audio_route_option_t; - -/** - * @brief Stream information including role, direction and index. - * @since_tizen 3.0 - */ -typedef struct audio_stream_info { - const char *role; - uint32_t direction; - uint32_t idx; -} audio_stream_info_t ; - -/** - * @brief Called when audio hal implementation needs to send a message. - * @since_tizen 3.0 - * @param[in] name The message name - * @param[in] value The message value - * @param[in] user_data The user data passed from the callback registration function - * - * @see audio_add_message_cb() - * @see audio_remove_message_cb() - */ -typedef void (*message_cb)(const char *name, int value, void *user_data); - -/* Overall */ -typedef struct audio_interface { - /* Initialization & de-initialization */ - audio_return_t (*init)(void **audio_handle); - audio_return_t (*deinit)(void *audio_handle); - /* Volume */ - audio_return_t (*get_volume_level_max)(void *audio_handle, audio_volume_info_t *info, uint32_t *level); - audio_return_t (*get_volume_level)(void *audio_handle, audio_volume_info_t *info, uint32_t *level); - audio_return_t (*set_volume_level)(void *audio_handle, audio_volume_info_t *info, uint32_t level); - audio_return_t (*get_volume_value)(void *audio_handle, audio_volume_info_t *info, uint32_t level, double *value); - audio_return_t (*get_volume_mute)(void *audio_handle, audio_volume_info_t *info, uint32_t *mute); - audio_return_t (*set_volume_mute)(void *audio_handle, audio_volume_info_t *info, uint32_t mute); - audio_return_t (*set_volume_ratio)(void *audio_handle, audio_stream_info_t *info, double ratio); - /* Routing */ - audio_return_t (*update_route)(void *audio_handle, audio_route_info_t *info); - audio_return_t (*update_route_option)(void *audio_handle, audio_route_option_t *option); - /* Stream */ - audio_return_t (*notify_stream_connection_changed)(void *audio_handle, audio_stream_info_t *info, uint32_t is_connected); - /* PCM */ - audio_return_t (*pcm_open)(void *audio_handle, const char *card, const char *device, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods, void **pcm_handle); - audio_return_t (*pcm_start)(void *audio_handle, void *pcm_handle); - audio_return_t (*pcm_stop)(void *audio_handle, void *pcm_handle); - audio_return_t (*pcm_close)(void *audio_handle, void *pcm_handle); - audio_return_t (*pcm_avail)(void *audio_handle, void *pcm_handle, uint32_t *avail); - audio_return_t (*pcm_write)(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames); - audio_return_t (*pcm_read)(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames); - audio_return_t (*pcm_get_fd)(void *audio_handle, void *pcm_handle, int *fd); - audio_return_t (*pcm_recover)(void *audio_handle, void *pcm_handle, int revents); - audio_return_t (*pcm_get_params)(void *audio_handle, void *pcm_handle, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods); - audio_return_t (*pcm_set_params)(void *audio_handle, void *pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods); - /* Message callback */ - audio_return_t (*add_message_cb)(void *audio_handle, message_cb callback, void *user_data); - audio_return_t (*remove_message_cb)(void *audio_handle, message_cb callback); -} audio_interface_t; - -/** * @brief Initializes audio hal. * @since_tizen 3.0 * @param[out] audio_handle The audio hal handle @@ -164,7 +43,7 @@ typedef struct audio_interface { * @retval #AUDIO_RET_OK Success * @see audio_deinit() */ -audio_return_t audio_init(void **audio_handle); +audio_return_e audio_init(void **audio_handle); /** * @brief De-initializes audio hal. @@ -176,7 +55,7 @@ audio_return_t audio_init(void **audio_handle); * @retval #AUDIO_RET_OK Success * @see audio_init() */ -audio_return_t audio_deinit(void *audio_handle); +audio_return_e audio_deinit(void *audio_handle); /** * @brief Gets the maximum volume level supported for a particular volume information. @@ -192,7 +71,7 @@ audio_return_t audio_deinit(void *audio_handle); * @see audio_get_volume_level() * @see audio_get_volume_value() */ -audio_return_t audio_get_volume_level_max(void *audio_handle, audio_volume_info_t *info, uint32_t *level); +audio_return_e audio_get_volume_level_max(void *audio_handle, audio_volume_info_s *info, uint32_t *level); /** * @brief Gets the volume level specified for a particular volume information. @@ -208,7 +87,7 @@ audio_return_t audio_get_volume_level_max(void *audio_handle, audio_volume_info_ * @see audio_get_volume_level_max() * @see audio_get_volume_value() */ -audio_return_t audio_get_volume_level(void *audio_handle, audio_volume_info_t *info, uint32_t *level); +audio_return_e audio_get_volume_level(void *audio_handle, audio_volume_info_s *info, uint32_t *level); /** * @brief Sets the volume level specified for a particular volume information. @@ -224,7 +103,7 @@ audio_return_t audio_get_volume_level(void *audio_handle, audio_volume_info_t *i * @see audio_get_volume_level_max() * @see audio_get_volume_value() */ -audio_return_t audio_set_volume_level(void *audio_handle, audio_volume_info_t *info, uint32_t level); +audio_return_e audio_set_volume_level(void *audio_handle, audio_volume_info_s *info, uint32_t level); /** * @brief Gets the volume value specified for a particular volume information and level. @@ -241,7 +120,7 @@ audio_return_t audio_set_volume_level(void *audio_handle, audio_volume_info_t *i * @see audio_get_volume_level() * @see audio_get_volume_level_max() */ -audio_return_t audio_get_volume_value(void *audio_handle, audio_volume_info_t *info, uint32_t level, double *value); +audio_return_e audio_get_volume_value(void *audio_handle, audio_volume_info_s *info, uint32_t level, double *value); /** * @brief Gets the volume mute specified for a particular volume information. @@ -255,7 +134,7 @@ audio_return_t audio_get_volume_value(void *audio_handle, audio_volume_info_t *i * @retval #AUDIO_RET_OK Success * @see audio_set_volume_mute() */ -audio_return_t audio_get_volume_mute(void *audio_handle, audio_volume_info_t *info, uint32_t *mute); +audio_return_e audio_get_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t *mute); /** * @brief Sets the volume mute specified for a particular volume information. @@ -269,7 +148,20 @@ audio_return_t audio_get_volume_mute(void *audio_handle, audio_volume_info_t *in * @retval #AUDIO_RET_OK Success * @see audio_get_volume_mute() */ -audio_return_t audio_set_volume_mute(void *audio_handle, audio_volume_info_t *info, uint32_t mute); +audio_return_e audio_set_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t mute); + +/** + * @brief Sets the volume ratio specified for a particular volume information. (optional) + * @since_tizen 5.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[in] ratio The volume ratio to be set (Min.:0.0 ~ Max.:1.0, default:1.0) + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + */ +audio_return_e audio_set_volume_ratio(void *audio_handle, audio_stream_info_s *info, double ratio); /** * @brief Updates the audio routing according to audio route information. @@ -282,7 +174,7 @@ audio_return_t audio_set_volume_mute(void *audio_handle, audio_volume_info_t *in * @retval #AUDIO_RET_OK Success * @see audio_update_route_option() */ -audio_return_t audio_update_route(void *audio_handle, audio_route_info_t *info); +audio_return_e audio_update_route(void *audio_handle, audio_route_info_s *info); /** * @brief Updates audio routing option according to audio route option. @@ -298,7 +190,7 @@ audio_return_t audio_update_route(void *audio_handle, audio_route_info_t *info); * @retval #AUDIO_RET_OK Success * @see audio_update_route() */ -audio_return_t audio_update_route_option(void *audio_handle, audio_route_option_t *option); +audio_return_e audio_update_route_option(void *audio_handle, audio_route_option_s *option); /** * @brief Gets notified when a stream is connected and disconnected. @@ -313,7 +205,7 @@ audio_return_t audio_update_route_option(void *audio_handle, audio_route_option_ * otherwise a negative error value * @retval #AUDIO_RET_OK Success */ -audio_return_t audio_notify_stream_connection_changed(void *audio_handle, audio_stream_info_t *info, uint32_t is_connected); +audio_return_e audio_notify_stream_connection_changed(void *audio_handle, audio_stream_info_s *info, uint32_t is_connected); /** * @brief Opens a PCM device. @@ -332,7 +224,7 @@ audio_return_t audio_notify_stream_connection_changed(void *audio_handle, audio_ * @retval #AUDIO_RET_OK Success * @see audio_pcm_close() */ -audio_return_t audio_pcm_open(void *audio_handle, const char *card, const char *device, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods, void **pcm_handle); +audio_return_e audio_pcm_open(void *audio_handle, const char *card, const char *device, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods, void **pcm_handle); /** * @brief Starts a PCM device. @@ -349,7 +241,7 @@ audio_return_t audio_pcm_open(void *audio_handle, const char *card, const char * * @see audio_pcm_stop() * @see audio_pcm_recover() */ -audio_return_t audio_pcm_start(void *audio_handle, void *pcm_handle); +audio_return_e audio_pcm_start(void *audio_handle, void *pcm_handle); /** * @brief Stops a PCM device. @@ -362,7 +254,7 @@ audio_return_t audio_pcm_start(void *audio_handle, void *pcm_handle); * @retval #AUDIO_RET_OK Success * @see audio_pcm_start() */ -audio_return_t audio_pcm_stop(void *audio_handle, void *pcm_handle); +audio_return_e audio_pcm_stop(void *audio_handle, void *pcm_handle); /** * @brief Closes a PCM device. @@ -375,7 +267,7 @@ audio_return_t audio_pcm_stop(void *audio_handle, void *pcm_handle); * @retval #AUDIO_RET_OK Success * @see audio_pcm_open() */ -audio_return_t audio_pcm_close(void *audio_handle, void *pcm_handle); +audio_return_e audio_pcm_close(void *audio_handle, void *pcm_handle); /** * @brief Gets available number of frames. @@ -390,7 +282,7 @@ audio_return_t audio_pcm_close(void *audio_handle, void *pcm_handle); * @see audio_pcm_write() * @see audio_pcm_read() */ -audio_return_t audio_pcm_avail(void *audio_handle, void *pcm_handle, uint32_t *avail); +audio_return_e audio_pcm_avail(void *audio_handle, void *pcm_handle, uint32_t *avail); /** * @brief Writes frames to a PCM device. @@ -406,7 +298,7 @@ audio_return_t audio_pcm_avail(void *audio_handle, void *pcm_handle, uint32_t *a * @see audio_pcm_avail() * @see audio_pcm_recover() */ -audio_return_t audio_pcm_write(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames); +audio_return_e audio_pcm_write(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames); /** * @brief Reads frames from a PCM device. @@ -422,7 +314,7 @@ audio_return_t audio_pcm_write(void *audio_handle, void *pcm_handle, const void * @see audio_pcm_avail() * @see audio_pcm_recover() */ -audio_return_t audio_pcm_read(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames); +audio_return_e audio_pcm_read(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames); /** * @brief Gets poll descriptor for a PCM handle. @@ -437,7 +329,7 @@ audio_return_t audio_pcm_read(void *audio_handle, void *pcm_handle, void *buffer * @see audio_pcm_open() * @see audio_pcm_recover() */ -audio_return_t audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd); +audio_return_e audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd); /** * @brief Recovers the PCM state. @@ -454,7 +346,7 @@ audio_return_t audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd); * @see audio_pcm_read() * @see audio_pcm_get_fd() */ -audio_return_t audio_pcm_recover(void *audio_handle, void *pcm_handle, int revents); +audio_return_e audio_pcm_recover(void *audio_handle, void *pcm_handle, int revents); /** * @brief Gets parameters of a PCM device. @@ -471,7 +363,7 @@ audio_return_t audio_pcm_recover(void *audio_handle, void *pcm_handle, int reven * @retval #AUDIO_RET_OK Success * @see audio_pcm_set_params() */ -audio_return_t audio_pcm_get_params(void *audio_handle, void *pcm_handle, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods); +audio_return_e audio_pcm_get_params(void *audio_handle, void *pcm_handle, uint32_t direction, void **sample_spec, uint32_t *period_size, uint32_t *periods); /** * @brief Sets hardware and software parameters of a PCM device. @@ -488,7 +380,7 @@ audio_return_t audio_pcm_get_params(void *audio_handle, void *pcm_handle, uint32 * @retval #AUDIO_RET_OK Success * @see audio_pcm_set_params() */ -audio_return_t audio_pcm_set_params(void *audio_handle, void *pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods); +audio_return_e audio_pcm_set_params(void *audio_handle, void *pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods); /** * @brief Adds the message callback function. @@ -500,7 +392,7 @@ audio_return_t audio_pcm_set_params(void *audio_handle, void *pcm_handle, uint32 * @see message_cb() * @see audio_remove_message_cb() */ -audio_return_t audio_add_message_cb(void *audio_handle, message_cb callback, void *user_data); +audio_return_e audio_add_message_cb(void *audio_handle, message_cb callback, void *user_data); /** * @brief Removes the message callback function. @@ -511,7 +403,7 @@ audio_return_t audio_add_message_cb(void *audio_handle, message_cb callback, voi * @see message_cb() * @see audio_add_message_cb() */ -audio_return_t audio_remove_message_cb(void *audio_handle, message_cb callback); +audio_return_e audio_remove_message_cb(void *audio_handle, message_cb callback); /** * @} |