From 51cc71483b2e8b30ca1988e7c16c2628a8e2f286 Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Mon, 18 Jan 2021 14:39:09 +0900 Subject: [PATCH] Initial release [Version] 0.0.1 [Issue Type] Initial release Change-Id: Ic184535d458b23604b14aead33f76324a8fb4277 Signed-off-by: Jaechul Lee --- CMakeLists.txt | 48 ++++ LICENSE.APLv2 | 202 ++++++++++++++++ NOTICE | 3 + hal-api-audio.manifest | 5 + hal-api-audio.pc.in | 14 ++ include/hal-audio-interface.h | 178 ++++++++++++++ include/hal-audio.h | 420 ++++++++++++++++++++++++++++++++++ packaging/hal-api-audio.spec | 54 +++++ src/hal-api-audio.c | 236 +++++++++++++++++++ 9 files changed, 1160 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE.APLv2 create mode 100644 NOTICE create mode 100644 hal-api-audio.manifest create mode 100644 hal-api-audio.pc.in create mode 100644 include/hal-audio-interface.h create mode 100644 include/hal-audio.h create mode 100644 packaging/hal-api-audio.spec create mode 100644 src/hal-api-audio.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2be8b16 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-api-audio C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") +SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.1.0") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(PKG_MODULES hal-api-common) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_EXE_LINKER_FLAGS "-pie") + +SET(SRCS src/hal-api-audio.c) + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,--as-needed -Wl,--rpath=${LIBDIR}/hal) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) + +INSTALL(DIRECTORY include/ DESTINATION include/hal + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "include/*.h") + +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) + diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..ccdad52 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE file for Apache License terms and conditions. diff --git a/hal-api-audio.manifest b/hal-api-audio.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/hal-api-audio.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/hal-api-audio.pc.in b/hal-api-audio.pc.in new file mode 100644 index 0000000..24b04f1 --- /dev/null +++ b/hal-api-audio.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@/hal +libdir=@LIBDIR@/hal +includedir=@INCLUDEDIR@/hal + +Name: @PROJECT_NAME@ +Description: @PROJECT_NAME@ interface +Version: @VERSION@ +Requires: +Libs: -L${libdir} -l@PROJECT_NAME@ +Cflags: -I${includedir} +CXXflags: -I${includedir} + diff --git a/include/hal-audio-interface.h b/include/hal-audio-interface.h new file mode 100644 index 0000000..da1280c --- /dev/null +++ b/include/hal-audio-interface.h @@ -0,0 +1,178 @@ +/* + * HAL (Hardware Abstract Layer) interface API for Audio + * + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_AUDIO_INTERFACE__ +#define __HAL_AUDIO_INTERFACE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file hal-audio.h + * @brief This file contains the Audio Hardware Abstraction Layer Interfaces. + */ + +/** + * @addtogroup TIZEN_AUDIO_HAL_MODULE + * @{ + */ + +/** + * @brief Enumeration for return codes. + * @since_tizen 6.5 + */ +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 enumerator here */ + AUDIO_ERR_NOT_IMPLEMENTED = (int32_t)0x80001100, +} audio_return_e ; + +/** + * @brief Enumeration for audio direction. + * @since_tizen 6.5 + */ +typedef enum audio_direction { + AUDIO_DIRECTION_IN, /**< Capture */ + AUDIO_DIRECTION_OUT, /**< Playback */ +} audio_direction_e; + +/** + * @brief Device information including type, direction and id. + * @since_tizen 6.5 + */ +typedef struct device_info { + const char *type; + uint32_t direction; + uint32_t id; +} device_info_s; + +/** + * @brief Volume information including type, gain and direction. + * @since_tizen 6.5 + */ +typedef struct audio_volume_info { + const char *type; + const char *gain; + uint32_t direction; +} audio_volume_info_s ; + +/** + * @brief Route information including role and device. + * @since_tizen 6.5 + */ +typedef struct audio_route_info { + const char *role; + device_info_s *device_infos; + uint32_t num_of_devices; +} audio_route_info_s; + +/** + * @brief Route option including role, name and value. + * @since_tizen 6.5 + */ +typedef struct audio_route_option { + const char *role; + const char *name; + int32_t value; +} audio_route_option_s; + +/** + * @brief Stream information including role, direction and index. + * @since_tizen 6.5 + */ +typedef struct audio_stream_info { + const char *role; + uint32_t direction; + uint32_t idx; +} audio_stream_info_s ; + +/** + * @brief Ducking information including target role, duration and ratio. + * @since_tizen 6.5 + */ +typedef struct audio_ducking_info { + const char *target_role; + uint32_t duration; + double ratio; +} audio_ducking_info_s; + +/** + * @brief Called when audio hal implementation needs to send a message. + * @since_tizen 6.5 + * @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); + +typedef struct _hal_backend_media_audio_funcs { + /* Initialization & de-initialization */ + audio_return_e (*init)(void **audio_handle); + audio_return_e (*deinit)(void *audio_handle); + /* Volume */ + audio_return_e (*get_volume_level_max)(void *audio_handle, audio_volume_info_s *info, uint32_t *level); + audio_return_e (*get_volume_level)(void *audio_handle, audio_volume_info_s *info, uint32_t *level); + audio_return_e (*set_volume_level)(void *audio_handle, audio_volume_info_s *info, uint32_t level); + audio_return_e (*get_volume_value)(void *audio_handle, audio_volume_info_s *info, uint32_t level, double *value); + audio_return_e (*get_volume_mute)(void *audio_handle, audio_volume_info_s *info, uint32_t *mute); + audio_return_e (*set_volume_mute)(void *audio_handle, audio_volume_info_s *info, uint32_t mute); + audio_return_e (*set_volume_ratio)(void *audio_handle, audio_stream_info_s *info, double ratio); + audio_return_e (*notify_ducking_activation_changed)(void *audio_handle, audio_ducking_info_s *info, uint32_t is_activated); /* optional */ + /* Routing */ + audio_return_e (*update_route)(void *audio_handle, audio_route_info_s *info); + audio_return_e (*update_route_option)(void *audio_handle, audio_route_option_s *option); + /* Stream */ + audio_return_e (*notify_stream_connection_changed)(void *audio_handle, audio_stream_info_s *info, uint32_t is_connected); + /* PCM */ + audio_return_e (*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 (*pcm_start)(void *audio_handle, void *pcm_handle); + audio_return_e (*pcm_stop)(void *audio_handle, void *pcm_handle); + audio_return_e (*pcm_close)(void *audio_handle, void *pcm_handle); + audio_return_e (*pcm_avail)(void *audio_handle, void *pcm_handle, uint32_t *avail); + audio_return_e (*pcm_write)(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames); + audio_return_e (*pcm_read)(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames); + audio_return_e (*pcm_get_fd)(void *audio_handle, void *pcm_handle, int *fd); + audio_return_e (*pcm_recover)(void *audio_handle, void *pcm_handle, int revents); + audio_return_e (*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 (*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_e (*add_message_cb)(void *audio_handle, message_cb callback, void *user_data); + audio_return_e (*remove_message_cb)(void *audio_handle, message_cb callback); +} hal_backend_audio_funcs_s; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_AUDIO_INTERFACE__ */ + diff --git a/include/hal-audio.h b/include/hal-audio.h new file mode 100644 index 0000000..13767da --- /dev/null +++ b/include/hal-audio.h @@ -0,0 +1,420 @@ +/* + * HAL (Hardware Abstract Layer) API for Audio + * + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_AUDIO__ +#define __HAL_AUDIO__ + +#include "hal-audio-interface.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initializes audio hal. + * @since_tizen 6.5 + * @param[out] audio_handle The audio hal handle + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_deinit() + */ +audio_return_e hal_audio_init(void **audio_handle); + +/** + * @brief De-initializes audio hal. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_init() + */ +audio_return_e hal_audio_deinit(void *audio_handle); + +/** + * @brief Gets the maximum volume level supported for a particular volume information. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[out] level The maximum volume level + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_set_volume_level() + * @see audio_get_volume_level() + * @see audio_get_volume_value() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[out] level The current volume level + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_set_volume_level() + * @see audio_get_volume_level_max() + * @see audio_get_volume_value() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[in] level The volume level to be set + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_get_volume_level() + * @see audio_get_volume_level_max() + * @see audio_get_volume_value() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[in] level The volume level + * @param[out] value The volume value (range is from 0.0 to 1.0 inclusive, 1.0 = 100%) + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_set_volume_level() + * @see audio_get_volume_level() + * @see audio_get_volume_level_max() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[out] mute The volume mute state : (@c 0 = unmute, @c 1 = mute) + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_set_volume_mute() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[in] mute The volume mute state to be set : (@c 0 = unmute, @c 1 = mute) + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_get_volume_mute() + */ +audio_return_e hal_audio_set_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t mute); + +/** + * @brief Sets the volume level ratio + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio volume information + * @param[in] ratio + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_get_volume_mute() + */ +audio_return_e hal_audio_set_volume_ratio(void *audio_handle, audio_stream_info_s *info, double ratio); + +/** + * @brief Gets notified when a ducking is activated and deactivated. (optional) + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The ducking information including target role, duration and ratio + * @param[in] is_activated The activation state (@c true = activated, @c false = deactivated) + * + * @remarks This information can be used for volume controls. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + */ +audio_return_e hal_audio_notify_ducking_activation_changed(void *audio_handle, audio_ducking_info_s *info, uint32_t is_activated); + +/** + * @brief Updates the audio routing according to audio route information. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The audio route information including role and devices + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_update_route_option() + */ +audio_return_e hal_audio_update_route(void *audio_handle, audio_route_info_s *info); + +/** + * @brief Updates audio routing option according to audio route option. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] option The option that can be used for audio routing including role, name and value + * + * @remarks This option can be used for audio routing.\n + * It is recommended to apply this option for routing per each role. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_update_route() + */ +audio_return_e hal_audio_update_route_option(void *audio_handle, audio_route_option_s *option); + +/** + * @brief Gets notified when a stream is connected and disconnected. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] info The stream information including role, direction, index + * @param[in] is_connected The connection state of this stream (@c true = connected, @c false = disconnected) + * + * @remarks This information can be used for audio routing, volume controls and so on. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + */ +audio_return_e hal_audio_notify_stream_connection_changed(void *audio_handle, audio_stream_info_s *info, uint32_t is_connected); + +/** + * @brief Opens a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] card The card of PCM + * @param[in] device The device of PCM + * @param[in] direction The direction of PCM + * @param[in] sample_spec The sample specification + * @param[in] period_size The period size + * @param[in] periods The periods + * @param[out] pcm_handle The PCM handle + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_close() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle to be started + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_avail() + * @see audio_pcm_write() + * @see audio_pcm_read() + * @see audio_pcm_stop() + * @see audio_pcm_recover() + */ +audio_return_e hal_audio_pcm_start(void *audio_handle, void *pcm_handle); + +/** + * @brief Stops a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle to be stopped + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_start() + */ +audio_return_e hal_audio_pcm_stop(void *audio_handle, void *pcm_handle); + +/** + * @brief Closes a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle to be closed + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_open() + */ +audio_return_e hal_audio_pcm_close(void *audio_handle, void *pcm_handle); + +/** + * @brief Gets available number of frames. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[out] avail The available number of frames + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_write() + * @see audio_pcm_read() + */ +audio_return_e hal_audio_pcm_avail(void *audio_handle, void *pcm_handle, uint32_t *avail); + +/** + * @brief Writes frames to a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[in] buffer The buffer containing frames + * @param[in] frames The number of frames to be written + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_avail() + * @see audio_pcm_recover() + */ +audio_return_e hal_audio_pcm_write(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames); + +/** + * @brief Reads frames from a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[out] buffer The buffer containing frames + * @param[in] frames The number of frames to be read + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_avail() + * @see audio_pcm_recover() + */ +audio_return_e hal_audio_pcm_read(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames); + +/** + * @brief Gets poll descriptor for a PCM handle. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[out] fd The poll descriptor + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_open() + * @see audio_pcm_recover() + */ +audio_return_e hal_audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd); + +/** + * @brief Recovers the PCM state. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[in] revents The returned event from pollfd + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_start() + * @see audio_pcm_write() + * @see audio_pcm_read() + * @see audio_pcm_get_fd() + */ +audio_return_e hal_audio_pcm_recover(void *audio_handle, void *pcm_handle, int revents); + +/** + * @brief Gets parameters of a PCM device. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[in] direction The direction of PCM + * @param[out] sample_spec The sample specification + * @param[out] period_size The period size + * @param[out] periods The periods + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_set_params() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] pcm_handle The PCM handle + * @param[in] direction The direction of PCM + * @param[in] sample_spec The sample specification + * @param[in] period_size The period size + * @param[in] periods The periods + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #AUDIO_RET_OK Success + * @see audio_pcm_set_params() + */ +audio_return_e hal_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. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] message_cb The message callback function + * @param[in] user_data The user data passed to the callback function + * + * @see message_cb() + * @see audio_remove_message_cb() + */ +audio_return_e hal_audio_add_message_cb(void *audio_handle, message_cb callback, void *user_data); + +/** + * @brief Removes the message callback function. + * @since_tizen 6.5 + * @param[in] audio_handle The audio hal handle + * @param[in] message_cb The message callback function to be removed + * + * @see message_cb() + * @see audio_add_message_cb() + */ +audio_return_e hal_audio_remove_message_cb(void *audio_handle, message_cb callback); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_AUDIO__ */ + diff --git a/packaging/hal-api-audio.spec b/packaging/hal-api-audio.spec new file mode 100644 index 0000000..cc87706 --- /dev/null +++ b/packaging/hal-api-audio.spec @@ -0,0 +1,54 @@ +Name: hal-api-audio +Summary: TIZEN Audio HAL +Version: 0.0.1 +Release: 0 +Group: System/Libraries +License: Apache-2.0 +URL: http://tizen.org +Source0: hal-api-audio-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(hal-api-common) + +%description +TIZEN Audio HAL + +%package devel +Summary: %{name} interface +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +%{name} interface development package for product vendor developer + +%prep +%setup -q -n %{name}-%{version} +%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir} + +%build +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE -DSYSCONFDIR=\\\"%{_sysconfdir}\\\"" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" + +make %{?jobs:-j%jobs} + +%install + +%make_install + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%files +%defattr(-,root,root,-) +%manifest hal-api-audio.manifest +%defattr(-,root,root,-) +%{_libdir}/hal/*.so* +%license LICENSE.APLv2 + +%files devel +%defattr(-,root,root,-) +%{_includedir}/hal/*.h +%{_libdir}/pkgconfig/*.pc diff --git a/src/hal-api-audio.c b/src/hal-api-audio.c new file mode 100644 index 0000000..495bf49 --- /dev/null +++ b/src/hal-api-audio.c @@ -0,0 +1,236 @@ +#include +#include + +#include "hal-audio.h" + +#define AUDIO_RETURN_VAL_IF_FAIL(expr, val) do { \ + if (!(expr)) { \ + return val; \ + } \ +} while (0) + +static hal_backend_audio_funcs_s *g_hal_audio_funcs = NULL; + +audio_return_e hal_audio_init(void **audio_handle) +{ + audio_return_e ret; + + if (g_hal_audio_funcs) + return AUDIO_RET_OK; + + ret = hal_common_get_backend(HAL_MODULE_AUDIO, (void **)&g_hal_audio_funcs); + + AUDIO_RETURN_VAL_IF_FAIL(ret == 0, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->init, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->init(audio_handle); +} + +audio_return_e hal_audio_deinit(void *audio_handle) +{ + audio_return_e ret; + + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->deinit, AUDIO_ERR_NOT_IMPLEMENTED); + + ret = g_hal_audio_funcs->deinit(audio_handle); + + hal_common_put_backend(HAL_MODULE_AUDIO, (void *)g_hal_audio_funcs); + + g_hal_audio_funcs = NULL; + + return ret; +} + +audio_return_e hal_audio_get_volume_level_max(void *audio_handle, audio_volume_info_s *info, uint32_t *level) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->get_volume_level_max, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->get_volume_level_max(audio_handle, info, level); +} + +audio_return_e hal_audio_get_volume_level(void *audio_handle, audio_volume_info_s *info, uint32_t *level) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->get_volume_level, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->get_volume_level(audio_handle, info, level); +} + +audio_return_e hal_audio_set_volume_level(void *audio_handle, audio_volume_info_s *info, uint32_t level) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->set_volume_level, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->set_volume_level(audio_handle, info, level); +} + +audio_return_e hal_audio_get_volume_value(void *audio_handle, audio_volume_info_s *info, uint32_t level, double *value) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->get_volume_value, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->get_volume_value(audio_handle, info, level, value); +} + + +audio_return_e hal_audio_get_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t *mute) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->get_volume_mute, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->get_volume_mute(audio_handle, info, mute); +} + +audio_return_e hal_audio_set_volume_mute(void *audio_handle, audio_volume_info_s *info, uint32_t mute) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->set_volume_mute, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->set_volume_mute(audio_handle, info, mute); +} + +audio_return_e hal_audio_set_volume_ratio(void *audio_handle, audio_stream_info_s *info, double ratio) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->set_volume_ratio, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->set_volume_ratio(audio_handle, info, ratio); +} + +audio_return_e hal_audio_notify_ducking_activation_changed(void *audio_handle, audio_ducking_info_s *info, uint32_t is_activated) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->notify_ducking_activation_changed, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->notify_ducking_activation_changed(audio_handle, info, is_activated); +} + +audio_return_e hal_audio_update_route(void *audio_handle, audio_route_info_s *info) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->update_route, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->update_route(audio_handle, info); +} + +audio_return_e hal_audio_update_route_option(void *audio_handle, audio_route_option_s *option) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->update_route_option, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->update_route_option(audio_handle, option); +} + +audio_return_e hal_audio_notify_stream_connection_changed(void *audio_handle, audio_stream_info_s *info, uint32_t is_connected) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->notify_stream_connection_changed, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->notify_stream_connection_changed(audio_handle, info, is_connected); +} + +audio_return_e hal_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_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_open, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_open(audio_handle, card, device, direction, sample_spec, period_size, periods, pcm_handle); +} + +audio_return_e hal_audio_pcm_start(void *audio_handle, void *pcm_handle) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_start, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_start(audio_handle, pcm_handle); +} + +audio_return_e hal_audio_pcm_stop(void *audio_handle, void *pcm_handle) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_stop, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_stop(audio_handle, pcm_handle); +} + +audio_return_e hal_audio_pcm_close(void *audio_handle, void *pcm_handle) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_close, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_close(audio_handle, pcm_handle); +} + +audio_return_e hal_audio_pcm_avail(void *audio_handle, void *pcm_handle, uint32_t *avail) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_avail, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_avail(audio_handle, pcm_handle, avail); +} + +audio_return_e hal_audio_pcm_write(void *audio_handle, void *pcm_handle, const void *buffer, uint32_t frames) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_write, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_write(audio_handle, pcm_handle, buffer, frames); +} + +audio_return_e hal_audio_pcm_read(void *audio_handle, void *pcm_handle, void *buffer, uint32_t frames) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_read, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_read(audio_handle, pcm_handle, buffer, frames); +} + +audio_return_e hal_audio_pcm_get_fd(void *audio_handle, void *pcm_handle, int *fd) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_get_fd, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_get_fd(audio_handle, pcm_handle, fd); +} + +audio_return_e hal_audio_pcm_recover(void *audio_handle, void *pcm_handle, int revents) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_recover, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_recover(audio_handle, pcm_handle, revents); +} + +audio_return_e hal_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_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_get_params, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_get_params(audio_handle, pcm_handle, direction, sample_spec, period_size, periods); +} + +audio_return_e hal_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_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->pcm_set_params, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->pcm_set_params(audio_handle, pcm_handle, direction, sample_spec, period_size, periods); +} + +audio_return_e hal_audio_add_message_cb(void *audio_handle, message_cb callback, void *user_data) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->add_message_cb, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->add_message_cb(audio_handle, callback, user_data); +} + +audio_return_e hal_audio_remove_message_cb(void *audio_handle, message_cb callback) +{ + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs, AUDIO_ERR_INTERNAL); + AUDIO_RETURN_VAL_IF_FAIL(g_hal_audio_funcs->remove_message_cb, AUDIO_ERR_NOT_IMPLEMENTED); + + return g_hal_audio_funcs->remove_message_cb(audio_handle, callback); +} -- 2.34.1