From 8c1c37165c2d56a3c99fe18334fc493e69a82d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 7 Sep 2024 15:00:59 +0800 Subject: [PATCH 01/10] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- audio/v3_0/BUILD.gn | 2 ++ display/buffer/v1_0/BUILD.gn | 5 +++++ display/buffer/v1_1/BUILD.gn | 3 +++ display/buffer/v1_2/BUILD.gn | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/audio/v3_0/BUILD.gn b/audio/v3_0/BUILD.gn index e7f3a018..baaf34b8 100644 --- a/audio/v3_0/BUILD.gn +++ b/audio/v3_0/BUILD.gn @@ -31,6 +31,8 @@ if (defined(ohos_lite)) { "IAudioRender.idl", ] + branch_protector_ret = "pac_ret" + language = "c" subsystem_name = "hdf" part_name = "drivers_interface_audio" diff --git a/display/buffer/v1_0/BUILD.gn b/display/buffer/v1_0/BUILD.gn index f6cddedd..249dec9c 100644 --- a/display/buffer/v1_0/BUILD.gn +++ b/display/buffer/v1_0/BUILD.gn @@ -27,6 +27,8 @@ hdi("display_buffer") { "platformsdk_indirect", ] + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" @@ -58,5 +60,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } diff --git a/display/buffer/v1_1/BUILD.gn b/display/buffer/v1_1/BUILD.gn index e9dde500..647b046f 100644 --- a/display/buffer/v1_1/BUILD.gn +++ b/display/buffer/v1_1/BUILD.gn @@ -21,6 +21,9 @@ hdi("display_buffer") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" diff --git a/display/buffer/v1_2/BUILD.gn b/display/buffer/v1_2/BUILD.gn index 436b6843..f3975441 100644 --- a/display/buffer/v1_2/BUILD.gn +++ b/display/buffer/v1_2/BUILD.gn @@ -25,6 +25,9 @@ hdi("display_buffer") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" @@ -64,5 +67,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_2") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } -- Gitee From e6935ab7b17c6de14f5065f15dee5efeea7bd778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 7 Sep 2024 15:01:54 +0800 Subject: [PATCH 02/10] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- display/buffer/v1_1/BUILD.gn | 3 +++ 1 file changed, 3 insertions(+) diff --git a/display/buffer/v1_1/BUILD.gn b/display/buffer/v1_1/BUILD.gn index 647b046f..8dbaae28 100644 --- a/display/buffer/v1_1/BUILD.gn +++ b/display/buffer/v1_1/BUILD.gn @@ -61,5 +61,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_1") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } -- Gitee From 377a560c26d11e35e51a5790f0bcba007a456b17 Mon Sep 17 00:00:00 2001 From: cwx1272435 Date: Wed, 11 Sep 2024 07:53:06 +0000 Subject: [PATCH 03/10] Rectification of high-risk processes and increase configuration Signed-off-by: cwx1272435 --- memorytracker/v1_0/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/memorytracker/v1_0/BUILD.gn b/memorytracker/v1_0/BUILD.gn index cc8817ac..9976beb1 100644 --- a/memorytracker/v1_0/BUILD.gn +++ b/memorytracker/v1_0/BUILD.gn @@ -13,6 +13,7 @@ import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") hdi("memorytracker") { + branch_protector_ret = "pac_ret" module_name = "memory_tracker_interface_service" sources = [ "IMemoryTrackerInterface.idl", -- Gitee From 7071e28fc138aa0d5d6bdf0868db25504da93196 Mon Sep 17 00:00:00 2001 From: zhaohui91 Date: Fri, 6 Sep 2024 12:12:24 +0800 Subject: [PATCH 04/10] rli add pac cfi Signed-off-by: zhaohui91 --- ril/v1_2/BUILD.gn | 1 + ril/v1_3/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/ril/v1_2/BUILD.gn b/ril/v1_2/BUILD.gn index 776d7b11..5e0ad2e7 100644 --- a/ril/v1_2/BUILD.gn +++ b/ril/v1_2/BUILD.gn @@ -20,6 +20,7 @@ if (defined(ohos_lite)) { } } else { hdi("ril") { + branch_protector_ret = "pac_ret" module_name = "ril_service" imports = [ "ohos.hdi.ril.v1_1:ril" ] sources = [ diff --git a/ril/v1_3/BUILD.gn b/ril/v1_3/BUILD.gn index 6913ad6c..b7364167 100644 --- a/ril/v1_3/BUILD.gn +++ b/ril/v1_3/BUILD.gn @@ -20,6 +20,7 @@ if (defined(ohos_lite)) { } } else { hdi("ril") { + branch_protector_ret = "pac_ret" module_name = "ril_service" imports = [ "ohos.hdi.ril.v1_2:ril" ] sources = [ -- Gitee From 5fb2242adece100bf79e45ca7788e932366caa67 Mon Sep 17 00:00:00 2001 From: suxiaosu007 Date: Fri, 13 Sep 2024 16:55:48 +0800 Subject: [PATCH 05/10] =?UTF-8?q?cherry=20pick=2076b3512=20from=20https://?= =?UTF-8?q?gitee.com/suxiaosu007/drivers=5Finterface/pulls/1225=20?= =?UTF-8?q?=E9=AB=98=E9=A3=8E=E9=99=A9=E8=BF=9B=E7=A8=8Bcodec=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: suxiaosu007 --- codec/v1_0/BUILD.gn | 1 + codec/v2_0/BUILD.gn | 1 + codec/v3_0/BUILD.gn | 1 + 3 files changed, 3 insertions(+) diff --git a/codec/v1_0/BUILD.gn b/codec/v1_0/BUILD.gn index 6de4ce09..bd36cda5 100644 --- a/codec/v1_0/BUILD.gn +++ b/codec/v1_0/BUILD.gn @@ -27,6 +27,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" diff --git a/codec/v2_0/BUILD.gn b/codec/v2_0/BUILD.gn index d2112592..32499b36 100644 --- a/codec/v2_0/BUILD.gn +++ b/codec/v2_0/BUILD.gn @@ -28,6 +28,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" diff --git a/codec/v3_0/BUILD.gn b/codec/v3_0/BUILD.gn index 239c7676..ab0494da 100644 --- a/codec/v3_0/BUILD.gn +++ b/codec/v3_0/BUILD.gn @@ -28,6 +28,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" -- Gitee From e5955a474ed9b2991c82e619e79193cbe66e3fb8 Mon Sep 17 00:00:00 2001 From: w30052974 Date: Sat, 14 Sep 2024 11:11:09 +0800 Subject: [PATCH 06/10] nnrt hdi branch_protector_ret added Signed-off-by: w30052974 --- nnrt/v1_0/BUILD.gn | 1 + nnrt/v2_0/BUILD.gn | 1 + nnrt/v2_1/BUILD.gn | 1 + 3 files changed, 3 insertions(+) diff --git a/nnrt/v1_0/BUILD.gn b/nnrt/v1_0/BUILD.gn index e68e1f3a..587c08c4 100644 --- a/nnrt/v1_0/BUILD.gn +++ b/nnrt/v1_0/BUILD.gn @@ -14,6 +14,7 @@ import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", diff --git a/nnrt/v2_0/BUILD.gn b/nnrt/v2_0/BUILD.gn index 140d143d..096981a3 100644 --- a/nnrt/v2_0/BUILD.gn +++ b/nnrt/v2_0/BUILD.gn @@ -14,6 +14,7 @@ import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", diff --git a/nnrt/v2_1/BUILD.gn b/nnrt/v2_1/BUILD.gn index 1cfe5f26..5368d0bb 100644 --- a/nnrt/v2_1/BUILD.gn +++ b/nnrt/v2_1/BUILD.gn @@ -14,6 +14,7 @@ import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", -- Gitee From 3053149267bb7b66606a13764668d82b50a42479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=B9=8F=E8=BE=89?= Date: Sat, 14 Sep 2024 10:21:16 +0800 Subject: [PATCH 07/10] change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁鹏辉 --- audio/effect/v1_0/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/effect/v1_0/BUILD.gn b/audio/effect/v1_0/BUILD.gn index 7c9f1a81..fa3bce88 100644 --- a/audio/effect/v1_0/BUILD.gn +++ b/audio/effect/v1_0/BUILD.gn @@ -27,6 +27,8 @@ if (defined(ohos_lite)) { "IEffectModel.idl", ] + branch_protector_ret = "pac_ret" + language = "c" subsystem_name = "hdf" part_name = "drivers_interface_audio" -- Gitee From 40d03a3350ba5bf54768e318e8451e47cd4aa591 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Wed, 18 Sep 2024 10:47:14 +0800 Subject: [PATCH 08/10] f Signed-off-by: huangshengqing --- camera/metadata/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camera/metadata/BUILD.gn b/camera/metadata/BUILD.gn index 0e327f2e..75a71320 100644 --- a/camera/metadata/BUILD.gn +++ b/camera/metadata/BUILD.gn @@ -19,6 +19,8 @@ config("camera_metadata_config") { } ohos_shared_library("metadata") { + branch_protector_ret = "pac_ret" + install_enable = true cflags = [ "-fPIC", -- Gitee From eea492867d897072cc3f0499319815d15b5aeaf2 Mon Sep 17 00:00:00 2001 From: huangshengqing Date: Sat, 21 Sep 2024 11:52:02 +0800 Subject: [PATCH 09/10] f Signed-off-by: huangshengqing --- camera/metadata/src/camera_metadata_info.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/camera/metadata/src/camera_metadata_info.cpp b/camera/metadata/src/camera_metadata_info.cpp index 08f249c4..25f77d9a 100644 --- a/camera/metadata/src/camera_metadata_info.cpp +++ b/camera/metadata/src/camera_metadata_info.cpp @@ -940,8 +940,8 @@ int CameraMetadata::copyMetadataMemory(common_metadata_header_t *dst, camera_met int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *item, uint32_t dataCount, common_metadata_header_t *dst, const void *data) { - if (item == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize item is null"); + if (item == nullptr || dst == nullptr) { + METADATA_ERR_LOG("UpdateameraMetadataItemSize item is null or dst is null"); return CAM_META_FAILURE; } else if (item->data_type < META_TYPE_BYTE || item->data_type >= META_NUM_TYPES) { METADATA_ERR_LOG("UpdateameraMetadataItemSize invalid datatype:%{public}d", item->data_type); @@ -951,10 +951,6 @@ int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *it size_t dataPayloadSize = dataCount * OHOS_CAMERA_METADATA_TYPE_SIZE[item->data_type]; size_t oldItemSize = CalculateCameraMetadataItemDataSize(item->data_type, item->count); int32_t ret = CAM_META_SUCCESS; - if (item == nullptr || dst == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize item is null or dst is null"); - return CAM_META_FAILURE; - } if (dataSize != oldItemSize) { if (dst->data_capacity < (dst->data_count + dataSize - oldItemSize)) { METADATA_ERR_LOG("UpdateCameraMetadataItemByIndex data_capacity limit reached"); @@ -975,10 +971,12 @@ int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *it dst->data_count += dataSize; } } else if (dataSize != 0) { + item->data.offset = dst->data_count; ret = copyMetadataMemory(dst, item, dataPayloadSize, data); if (ret != CAM_META_SUCCESS) { return ret; } + dst->data_count += dataSize; } if (dataSize == 0) { ret = memcpy_s(item->data.value, dataPayloadSize, data, dataPayloadSize); -- Gitee From 2c8c6c68269ffb574298990cdf95cd0acc67ad85 Mon Sep 17 00:00:00 2001 From: xuxuehai Date: Wed, 25 Sep 2024 11:22:16 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8D=87=E7=BA=A74.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuxuehai --- audio/bundle.json | 13 +- audio/v4_0/AudioTypes.idl | 678 ++++++++++++++++++++++++++++++++++ audio/v4_0/BUILD.gn | 40 ++ audio/v4_0/IAudioAdapter.idl | 311 ++++++++++++++++ audio/v4_0/IAudioCallback.idl | 76 ++++ audio/v4_0/IAudioCapture.idl | 487 ++++++++++++++++++++++++ audio/v4_0/IAudioManager.idl | 98 +++++ audio/v4_0/IAudioRender.idl | 594 +++++++++++++++++++++++++++++ 8 files changed, 2289 insertions(+), 8 deletions(-) create mode 100644 audio/v4_0/AudioTypes.idl create mode 100644 audio/v4_0/BUILD.gn create mode 100644 audio/v4_0/IAudioAdapter.idl create mode 100644 audio/v4_0/IAudioCallback.idl create mode 100644 audio/v4_0/IAudioCapture.idl create mode 100644 audio/v4_0/IAudioManager.idl create mode 100644 audio/v4_0/IAudioRender.idl diff --git a/audio/bundle.json b/audio/bundle.json index 54b32b57..628cd2e9 100644 --- a/audio/bundle.json +++ b/audio/bundle.json @@ -12,10 +12,7 @@ "component": { "name": "drivers_interface_audio", "subsystem": "hdf", - "adapted_system_type": [ - "small", - "standard" - ], + "adapted_system_type": ["standard"], "rom": "675KB", "ram": "1024KB", "deps": { @@ -29,7 +26,7 @@ "build": { "sub_component": [ "//drivers/interface/audio/effect/v1_0:libeffect_proxy_1.0", - "//drivers/interface/audio/v3_0:libaudio_proxy_3.0" + "//drivers/interface/audio/v4_0:libaudio_proxy_4.0" ], "test": [ ], @@ -59,7 +56,7 @@ } }, { - "name": "//drivers/interface/audio/v3_0:libaudio_proxy_3.0", + "name": "//drivers/interface/audio/v4_0:libaudio_proxy_4.0", "header": { "header_files": [ ], @@ -67,7 +64,7 @@ } }, { - "name": "//drivers/interface/audio/v3_0:audio_idl_headers", + "name": "//drivers/interface/audio/v4_0:audio_idl_headers", "header": { "header_files": [ ], @@ -75,7 +72,7 @@ } }, { - "name": "//drivers/interface/audio/v3_0:libaudio_stub_3.0", + "name": "//drivers/interface/audio/v4_0:libaudio_stub_4.0", "header": { "header_files": [ ], diff --git a/audio/v4_0/AudioTypes.idl b/audio/v4_0/AudioTypes.idl new file mode 100644 index 00000000..f2ed451b --- /dev/null +++ b/audio/v4_0/AudioTypes.idl @@ -0,0 +1,678 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +/** + * @brief Enumerates the audio port type. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioPortDirection { + PORT_OUT = 1, /**< Output port */ + PORT_IN = 2, /**< Input port */ + PORT_OUT_IN = 3, /**< Input/output port, supporting both audio input and output */ +}; + +/** + * @brief Enumerates the pin of an audio adapter. + * + * @since 4.1 + * @version 3.0 + */ +enum AudioPortPin { + PIN_NONE = 0, /**< Invalid pin */ + PIN_OUT_SPEAKER = 1 << 0, /**< Speaker output pin */ + PIN_OUT_HEADSET = 1 << 1, /**< Wired headset pin for output */ + PIN_OUT_LINEOUT = 1 << 2, /**< Line-out pin */ + PIN_OUT_HDMI = 1 << 3, /**< HDMI output pin */ + PIN_OUT_USB = 1 << 4, /**< USB output pin */ + PIN_OUT_USB_EXT = 1 << 5, /**< Extended USB output pin*/ + PIN_OUT_EARPIECE = 1 << 5 | 1 << 4, /**< Earpiece output pin */ + PIN_OUT_BLUETOOTH_SCO = 1 << 6, /**< Bluetooth SCO output pin */ + PIN_OUT_DAUDIO_DEFAULT = 1 << 7, /**< Daudio default output pin */ + PIN_OUT_HEADPHONE = 1 << 8, /**< Wired headphone output pin*/ + PIN_OUT_USB_HEADSET = 1 << 9, /**< ARM USB out pin */ + PIN_OUT_BLUETOOTH_A2DP = 1 << 10, /**< Bluetooth A2DP output pin */ + PIN_OUT_DP = 1 << 11, /**< Dp output pin */ + PIN_IN_MIC = 1 << 27 | 1 << 0, /**< Microphone input pin */ + PIN_IN_HS_MIC = 1 << 27 | 1 << 1, /**< Wired headset microphone pin for input */ + PIN_IN_LINEIN = 1 << 27 | 1 << 2, /**< Line-in pin */ + PIN_IN_USB_EXT = 1 << 27 | 1 << 3, /**< Extended USB input pin*/ + PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, /**< Bluetooth SCO headset input pin */ + PIN_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, /**< Daudio default input pin */ + PIN_IN_USB_HEADSET = 1 << 27 | 1 << 6, /**< ARM USB input pin */ +}; + +/** + * @brief Enumerates the audio category. + * + * @since 4.1 + * @version 3.0 + */ +enum AudioCategory { + AUDIO_IN_MEDIA = 0, /**< Media */ + AUDIO_IN_COMMUNICATION = 1, /**< Communications */ + AUDIO_IN_RINGTONE = 2, /**< Ringtone */ + AUDIO_IN_CALL = 3, /**< Call */ + AUDIO_MMAP_NOIRQ = 4, /**< Mmap mode */ + AUDIO_OFFLOAD = 5, /**< Offload */ + AUDIO_MULTI_CHANNEL = 6, /**< Multi channel */ + AUDIO_DP = 7, /**< Audio dp */ + AUDIO_MMAP_VOIP = 8, /**< Audio voip */ + AUDIO_IN_NAVIGATION = 9, /**< Audio navigation */ + AUDIO_DIRECT = 10,/**< Audio direct */ +}; + +/** + * @brief Enumerates the audio format. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioFormat { + AUDIO_FORMAT_TYPE_PCM_8_BIT = 1 << 0, /**< 8-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_16_BIT = 1 << 1, /**< 16-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0, /**< 24-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_32_BIT = 1 << 2, /**< 32-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_FLOAT = 1 << 2 | 1 << 0, /**< FLOAT PCM */ + AUDIO_FORMAT_TYPE_MP3 = 1 << 24, /**< MP3 */ + AUDIO_FORMAT_TYPE_AAC_MAIN = 1 << 24 | 1 << 0, /**< AAC main */ + AUDIO_FORMAT_TYPE_AAC_LC = 1 << 24 | 1 << 1, /**< AAC LC */ + AUDIO_FORMAT_TYPE_AAC_LD = 1 << 24 | 1 << 1 | 1 << 0, /**< AAC LD */ + AUDIO_FORMAT_TYPE_AAC_ELD = 1 << 24 | 1 << 2, /**< AAC ELD */ + AUDIO_FORMAT_TYPE_AAC_HE_V1 = 1 << 24 | 1 << 2 | 1 << 0, /**< AAC HE_V1 */ + AUDIO_FORMAT_TYPE_AAC_HE_V2 = 1 << 24 | 1 << 2 | 1 << 1, /**< AAC HE_V2 */ + AUDIO_FORMAT_TYPE_G711A = 1 << 25 | 1 << 0, /**< G711A */ + AUDIO_FORMAT_TYPE_G711U = 1 << 25 | 1 << 1, /**< G711u */ + AUDIO_FORMAT_TYPE_G726 = 1 << 25 | 1 << 1 | 1 << 0, /**< G726 */ +}; + +/** + * @brief Enumerates the audio channel mask. + * + * A mask describes an audio channel position. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioChannelMask { + AUDIO_CHANNEL_FRONT_LEFT = 1, /**< Front left channel */ + AUDIO_CHANNEL_FRONT_RIGHT = 2, /**< Front right channel */ + AUDIO_CHANNEL_MONO = 1, /**< Mono channel */ + AUDIO_CHANNEL_STEREO = 3, /**< Stereo channel, consisting of front left and front right channels */ +}; + +/** + * @brief Enumerates masks of audio sampling rates. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioSampleRatesMask { + AUDIO_SAMPLE_RATE_MASK_8000 = 1 << 0, /**< 8 kHz */ + AUDIO_SAMPLE_RATE_MASK_12000 = 1 << 1, /**< 12 kHz */ + AUDIO_SAMPLE_RATE_MASK_11025 = 1 << 2, /**< 11.025 kHz */ + AUDIO_SAMPLE_RATE_MASK_16000 = 1 << 3, /**< 16 kHz */ + AUDIO_SAMPLE_RATE_MASK_22050 = 1 << 4, /**< 22.050 kHz */ + AUDIO_SAMPLE_RATE_MASK_24000 = 1 << 5, /**< 24 kHz */ + AUDIO_SAMPLE_RATE_MASK_32000 = 1 << 6, /**< 32 kHz */ + AUDIO_SAMPLE_RATE_MASK_44100 = 1 << 7, /**< 44.1 kHz */ + AUDIO_SAMPLE_RATE_MASK_48000 = 1 << 8, /**< 48 kHz */ + AUDIO_SAMPLE_RATE_MASK_64000 = 1 << 9, /**< 64 kHz */ + AUDIO_SAMPLE_RATE_MASK_96000 = 1 << 10, /**< 96 kHz */ + AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295, /**< Invalid sampling rate */ +}; + +/** + * @brief Enumerates the passthrough data transmission mode of an audio port. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioPortPassthroughMode { + PORT_PASSTHROUGH_LPCM = 1 << 0, /**< Stereo PCM */ + PORT_PASSTHROUGH_RAW = 1 << 1, /**< HDMI passthrough */ + PORT_PASSTHROUGH_HBR2LBR = 1 << 2, /**< Blu-ray next-generation audio output with reduced specifications */ + PORT_PASSTHROUGH_AUTO = 1 << 3, /**< Mode automatically matched based on the HDMI EDID */ +}; + +/** + * @brief Defines formats of raw audio samples. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioSampleFormat { + /* 8 bits */ + AUDIO_SAMPLE_FORMAT_S8 = 0, /**< signed 8 bit sample */ + AUDIO_SAMPLE_FORMAT_S8P = 1, /**< signed 8 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U8 = 2, /**< unsigned 8 bit sample */ + AUDIO_SAMPLE_FORMAT_U8P = 3, /**< unsigned 8 bit planar sample */ + /* 16 bits */ + AUDIO_SAMPLE_FORMAT_S16 = 4, /**< signed 16 bit sample */ + AUDIO_SAMPLE_FORMAT_S16P = 5, /**< signed 16 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U16 = 6, /**< unsigned 16 bit sample */ + AUDIO_SAMPLE_FORMAT_U16P = 7, /**< unsigned 16 bit planar sample */ + /* 24 bits */ + AUDIO_SAMPLE_FORMAT_S24 = 8, /**< signed 24 bit sample */ + AUDIO_SAMPLE_FORMAT_S24P = 9, /**< signed 24 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U24 = 10, /**< unsigned 24 bit sample */ + AUDIO_SAMPLE_FORMAT_U24P = 11, /**< unsigned 24 bit planar sample */ + /* 32 bits */ + AUDIO_SAMPLE_FORMAT_S32 = 12, /**< signed 32 bit sample */ + AUDIO_SAMPLE_FORMAT_S32P = 13, /**< signed 32 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U32 = 14, /**< unsigned 32 bit sample */ + AUDIO_SAMPLE_FORMAT_U32P = 15, /**< unsigned 32 bit planar sample */ + /* 64 bits */ + AUDIO_SAMPLE_FORMAT_S64 = 16, /**< signed 64 bit sample */ + AUDIO_SAMPLE_FORMAT_S64P = 17, /**< signed 64 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U64 = 18, /**< unsigned 64 bit sample */ + AUDIO_SAMPLE_FORMAT_U64P = 19, /**< unsigned 64 bit planar sample */ + /* float double */ + AUDIO_SAMPLE_FORMAT_F32 = 20, /**< float 32 bit sample */ + AUDIO_SAMPLE_FORMAT_F32P = 21, /**< float 32 bit planar sample */ + AUDIO_SAMPLE_FORMAT_F64 = 22, /**< double 64 bit sample */ + AUDIO_SAMPLE_FORMAT_F64P = 23, /**< double 64 bit planar sample */ +}; + +/** + * @brief Enumerates channel modes for audio rendering. + * + * @attention The following modes are set for rendering dual-channel audios. Others are not supported. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioChannelMode { + AUDIO_CHANNEL_NORMAL = 0, /**< Normal mode. No processing is required. */ + AUDIO_CHANNEL_BOTH_LEFT = 1, /**< Two left channels */ + AUDIO_CHANNEL_BOTH_RIGHT = 2, /**< Two right channels */ + AUDIO_CHANNEL_EXCHANGE = 3, /**< Data exchange between the left and right channels. The left channel takes the audio + * stream of the right channel, and the right channel takes that of the left channel. + */ + AUDIO_CHANNEL_MIX = 4, /**< Mix of streams of the left and right channels */ + AUDIO_CHANNEL_LEFT_MUTE = 5, /**< Left channel muted. The stream of the right channel is output. */ + AUDIO_CHANNEL_RIGHT_MUTE = 6, /**< Right channel muted. The stream of the left channel is output. */ + AUDIO_CHANNEL_BOTH_MUTE = 7, /**< Both left and right channels are muted */ +}; + +/** + * @brief Enumerates the execution types of the DrainBuffer function. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioDrainNotifyType { + AUDIO_DRAIN_NORMAL_MODE = 0, /**< The DrainBuffer function returns after all data finishes playback. */ + AUDIO_DRAIN_EARLY_MODE = 1, /**< The DrainBuffer function returns before all the data of the current track + * finishes playback to reserve time for a smooth track switch by the audio service. + */ + +}; + +/** + * @brief Enumerates callback notification events. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioCallbackType { + AUDIO_NONBLOCK_WRITE_COMPLETED = 0, /**< The non-block write is complete. */ + AUDIO_DRAIN_COMPLETED = 1, /**< The draining is complete. */ + AUDIO_FLUSH_COMPLETED = 2, /**< The flush is complete. */ + AUDIO_RENDER_FULL = 3, /**< The render buffer is full.*/ + AUDIO_ERROR_OCCUR = 4, /**< An error occurs.*/ +}; + +/** + * @brief Describes AudioPortRole. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioPortRole { + AUDIO_PORT_UNASSIGNED_ROLE = 0, /**< Unassigned port role */ + AUDIO_PORT_SOURCE_ROLE = 1, /**< Assigned source role */ + AUDIO_PORT_SINK_ROLE = 2, /**< Assigned sink role */ +}; + +/** + * @brief Describes AudioPortType. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioPortType { + AUDIO_PORT_UNASSIGNED_TYPE = 0, /**< Unassigned port type */ + AUDIO_PORT_DEVICE_TYPE = 1, /**< Assigned device type */ + AUDIO_PORT_MIX_TYPE = 2, /**< Assigned mix type */ + AUDIO_PORT_SESSION_TYPE = 3, /**< Assigned session type */ +}; + +/** + * @brief Describes AudioSessionType. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioSessionType { + AUDIO_OUTPUT_STAGE_SESSION = 0, /**< Assigned output stage session */ + AUDIO_OUTPUT_MIX_SESSION = 1, /**< Assigned output mix session */ + AUDIO_ALLOCATE_SESSION = 2, /**< Assigned allocate session */ + AUDIO_INVALID_SESSION = 3, /**< Assigned invalid session */ +}; + +/** + * @brief Describes AudioDeviceType. + * + * @since 4.1 + * @version 3.0 + */ +enum AudioDeviceType { + AUDIO_LINEOUT = 1 << 0, /**< Assigned lineout device type */ + AUDIO_HEADPHONE = 1 << 1, /**< Assigned headphone device type */ + AUDIO_HEADSET = 1 << 2, /**< Assigned headset device type */ + AUDIO_USB_HEADSET = 1 << 3, /**< Assigned usb headset device type */ + AUDIO_USB_HEADPHONE = 1 << 4, /**< Assigned usb headphone device type */ + AUDIO_USBA_HEADSET = 1 << 5, /**< Assigned usba headset device type */ + AUDIO_USBA_HEADPHONE = 1 << 6, /**< Assigned usba headphone device type */ + AUDIO_PRIMARY_DEVICE = 1 << 7, /**< Assigned primary device type */ + AUDIO_USB_DEVICE = 1 << 8, /**< Assigned usb device type */ + AUDIO_A2DP_DEVICE = 1 << 9, /**< Assigned a2dp device type */ + AUDIO_HDMI_DEVICE = 1 << 10, /**< Assigned hdmi device type */ + AUDIO_ADAPTER_DEVICE = 1 << 11, /**< Assigned adapter device type */ + AUDIO_DP_DEVICE = 1 << 12, /**< Assigned dp device type */ + AUDIO_DEVICE_UNKNOWN, /**< Assigned unknown device type */ +}; + +/** + * @brief Describes AudioEventType. + * + * @since 4.1 + * @version 2.0 + */ +enum AudioEventType { + AUDIO_DEVICE_ADD = 1, /**< Assigned add device event type */ + AUDIO_DEVICE_REMOVE = 2, /**< Assigned remove device event type */ + AUDIO_LOAD_SUCCESS = 3, /**< Assigned load sucess event type */ + AUDIO_LOAD_FAILURE = 4, /**< Assigned load failure event type */ + AUDIO_UNLOAD = 5, /**< Assigned unload event type */ + AUDIO_SERVICE_VALID = 7, /**< Assigned valid service event type */ + AUDIO_SERVICE_INVALID = 8, /**< Assigned invalid service event type */ + AUDIO_CAPTURE_THRESHOLD = 9, /**< Assigned threshold capture event type */ + AUDIO_EVENT_UNKNOWN = 10, /**< Assigned unknown event type */ +}; + +/** + * @brief Enumerates the restricted key type of the parameters + * + * @since 4.1 + * @version 2.0 + */ +enum AudioExtParamKey { + AUDIO_EXT_PARAM_KEY_NONE = 0, /**< Distributed audio extra param key none */ + AUDIO_EXT_PARAM_KEY_VOLUME = 1, /**< Distributed audio extra param key volume event */ + AUDIO_EXT_PARAM_KEY_FOCUS = 2, /**< Distributed audio extra param key focus event */ + AUDIO_EXT_PARAM_KEY_BUTTON = 3, /**< Distributed audio extra param key media button event */ + AUDIO_EXT_PARAM_KEY_EFFECT = 4, /**< Distributed audio extra param key audio effect event */ + AUDIO_EXT_PARAM_KEY_STATUS = 5, /**< Distributed audio extra param key device status event */ + AUDIO_EXT_PARAM_KEY_USB_DEVICE = 101, /**< Check USB device type ARM or HIFI */ + AUDIO_EXT_PARAM_KEY_PERF_INFO = 201, /**< Distributed audio extra param key dsp load event */ + AUDIO_EXT_PARAM_KEY_MMI = 301, /**< Distributed audio extra param key Man-Machine interface Test */ + AUDIO_EXT_PARAM_KEY_LOWPOWER = 1000, /**< Low power event type */ +}; + +/** + * @brief Describes status of audio deivce.@link enum AudioDeviceType + * + * @since 4.1 + * @version 2.0 + */ +struct AudioDeviceStatus { + unsigned int pnpStatus; /**< Audio pnp status */ +}; + +/** + * @brief Describes the audio scene. + * + * @since 4.1 + * @version 2.0 + */ +union SceneDesc { + unsigned int id; /**< Audio scene ID */ +}; + +/** + * @brief Defines the audio port. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioPort { + enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */ + unsigned int portId; /**< Audio port ID */ + String portName; /**< Audio port name */ +}; + +/** + * @brief Defines the audio adapter descriptor. + * + * An audio adapter is a set of port drivers for a sound card, including the output and input ports. + * One port corresponds to multiple pins, and each pin belongs to a physical component (such as a + * speaker or a wired headset). + * + * @since 4.1 + * @version 2.0 + */ +struct AudioAdapterDescriptor { + String adapterName; /**< Name of the audio adapter */ + struct AudioPort[] ports; /**< List of ports supported by an audio adapter */ +}; + +/** + * @brief Defines the audio device descriptor. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioDeviceDescriptor { + unsigned int portId; /**< Audio port ID */ + enum AudioPortPin pins; /**< Pins of audio ports (input and output). For details, see {@link AudioPortPin}. */ + String desc; /**< Audio device name */ +}; + +/** + * @brief Defines the audio scene descriptor. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioSceneDescriptor { + union SceneDesc scene; /**< Describes the audio scene */ + struct AudioDeviceDescriptor desc; /**< Audio device descriptor */ +}; + +/** + * @brief Defines audio input type. + * + * @since 4.1 + * @version 3.0 + */ +enum AudioInputType { + AUDIO_INPUT_DEFAULT_TYPE = 0, /**< Assigned default input type */ + AUDIO_INPUT_MIC_TYPE = 1 << 0, /**< Assigned mic input type */ + AUDIO_INPUT_SPEECH_WAKEUP_TYPE = 1 << 1, /**< Assigned speech wakeup input type */ + AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, /**< Assigned voice communication input type */ + AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, /**< Assigned voice recognition input type */ + AUDIO_INPUT_VOICE_UPLINK_TYPE = 1 << 4, /**< Assigned voice uplink input type */ + AUDIO_INPUT_VOICE_DOWNLINK_TYPE = 1 << 5, /**< Assigned voice downlink input type */ + AUDIO_INPUT_VOICE_CALL_TYPE = 1 << 6, /**< Assigned voice call input type */ + AUDIO_INPUT_CAMCORDER_TYPE = 1 << 7, /**< Assigned camcorder input type */ + AUDIO_INPUT_EC_TYPE = 1 << 8, /**< Assigned EC input type */ + AUDIO_INPUT_NOISE_REDUCTION_TYPE = 1 << 9, /**< Assigned noise reduction input type */ +}; + +/** + * @brief Defines audio offload attributes. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioOffloadInfo +{ + unsigned int sampleRate; /**< Audio sampling rate */ + unsigned int channelCount; /**< Number of audio channels */ + unsigned long channelLayout; /**< Audio channel layout */ + unsigned int bitRate; /**< bitRate of compressed audio data */ + unsigned int bitWidth; /**< bitwidth of audio data */ + enum AudioFormat format; /**< Audio data format. */ + unsigned int offloadBufferSize; /**< buffersize for offload audio data */ + unsigned long duration; /** audio duration, unit is nanosecond*/ +}; + +/** + * @brief Defines audio Ecsampling attributes. + * + * @since 5.0 + * @version 1.0 + */ +struct EcSampleAttributes { + boolean ecInterleaved; /**< Interleaving flag of audio data */ + enum AudioFormat ecFormat; /**< Audio data format. For details, see {@link AudioFormat}. */ + unsigned int ecSampleRate; /**< Audio sampling rate */ + unsigned int ecChannelCount; /**< Number of audio channels */ + unsigned long ecChannelLayout; /**< Audio channel layout */ + unsigned int ecPeriod; /**< Audio sampling period */ + unsigned int ecFrameSize; /**< Frame size of the audio data */ + boolean ecIsBigEndian; /**< Big endian flag of audio data */ + boolean ecIsSignedData; /**< Signed or unsigned flag of audio data */ + unsigned int ecStartThreshold; /**< Audio start threshold. */ + unsigned int ecStopThreshold; /**< Audio stop threshold. */ + unsigned int ecSilenceThreshold; /**< Audio buffer threshold. */ +}; + +/** + * @brief Defines audio captureEc attributes. + * + * @since 5.0 + * @version 1.0 + */ +struct AudioCaptureFrameInfo { + byte[] frame; /**< Audio capture frame */ + unsigned long replyBytes; /**< The actual length of the audio capture frame */ + byte[] frameEc; /**< Audio capture ec frame */ + unsigned long replyBytesEc; /**< The actual length of the audio capture ec frame */ +}; + +/** + * @brief Defines audio len of captureEc frame. + * + * @since 5.0 + * @version 1.0 + */ +struct AudioFrameLen { + unsigned int frameLen; /**< The length of the audio capture frame */ + unsigned int frameEcLen; /**< The length of the audio capture ec frame */ +}; + +/** + * @brief Defines audio sampling attributes. + * + * @since 4.1 + * @version 3.0 + */ +struct AudioSampleAttributes { + enum AudioCategory type; /**< Audio type. For details, see {@link AudioCategory} */ + boolean interleaved; /**< Interleaving flag of audio data */ + enum AudioFormat format; /**< Audio data format. For details, see {@link AudioFormat}. */ + unsigned int sampleRate; /**< Audio sampling rate */ + unsigned int channelCount; /**< Number of audio channels. For example, for the mono channel, the value is 1, + * and for the stereo channel, the value is 2. + */ + unsigned long channelLayout; /**< Audio channel layout */ + unsigned int period; /**< Audio sampling period */ + unsigned int frameSize; /**< Frame size of the audio data */ + boolean isBigEndian; /**< Big endian flag of audio data */ + boolean isSignedData; /**< Signed or unsigned flag of audio data */ + unsigned int startThreshold; /**< Audio render start threshold. */ + unsigned int stopThreshold; /**< Audio render stop threshold. */ + unsigned int silenceThreshold; /**< Audio capture buffer threshold. */ + int streamId; /**< Audio Identifier of render or capture */ + int sourceType; /**< Audio sourceType of render or capture */ + struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ + struct EcSampleAttributes ecSampleAttributes; /**< ec config */ +}; + +/** + * @brief Defines the audio timestamp, which is a substitute for POSIX timespec. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioTimeStamp { + long tvSec; /**< Seconds */ + long tvNSec; /**< Nanoseconds */ +}; + +/** + * @brief Defines the sub-port capability. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioSubPortCapability { + unsigned int portId; /**< Sub-port ID */ + String desc; /**< Sub-port name */ + enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details, + * see {@link AudioPortPassthroughMode}. + */ +}; + +/** + * @brief Defines the audio port capability. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioPortCapability { + unsigned int deviceType; /**< Device type (output or input) */ + unsigned int deviceId; /**< Device ID used for device binding */ + boolean hardwareMode; /**< Whether to support device binding */ + unsigned int formatNum; /**< Number of the supported audio formats */ + enum AudioFormat[] formats; /**< Supported audio formats. For details, see {@link AudioFormat}. */ + unsigned int sampleRateMasks; /**< Supported audio sampling rates (8 kHz, 16 kHz, 32 kHz, and 48 kHz) */ + enum AudioChannelMask channelMasks; /**< Audio channel layout mask of the device. For details, + * see {@link AudioChannelMask}. + */ + unsigned int channelCount; /**< Supported maximum number of audio channels */ + struct AudioSubPortCapability[] subPorts; /**< List of supported sub-ports */ + enum AudioSampleFormat[] supportSampleFormats; /**< Supported audio sample formats. For details, + * see {@link AudioSampleFormat}. + */ +}; + +/** + * @brief Describes a mmap buffer. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioMmapBufferDescriptor { + byte[] memoryAddress; /**< Pointer to the mmap buffer */ + FileDescriptor memoryFd; /**< File descriptor of the mmap buffer */ + int totalBufferFrames; /**< Total size of the mmap buffer (unit: frame )*/ + int transferFrameSize; /**< Transfer size (unit: frame) */ + int isShareable; /**< Whether the mmap buffer can be shared among processes */ + unsigned int offset; /**< off set */ + String filePath; /**< file path */ +}; + +/** + * @brief Describes AudioDevExtInfo. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioDevExtInfo { + int moduleId; /**< Identifier of the module stream is attached to */ + enum AudioPortPin type; /**< Device type For details, see {@link AudioPortPin}. */ + String desc; /**< Address */ +}; + +/** + * @brief Describes AudioMixInfo. + * + * @since 4.1 + * @version 3.0 + */ +struct AudioMixExtInfo { + int moduleId; /**< Identifier of the module stream is attached to */ + int streamId; /**< Identifier of the capture or render passed by caller */ + int source; /**< Identifier of the source by capture or render */ +}; + +/** + * @brief Describes AudioSessionExtInfo. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioSessionExtInfo { + enum AudioSessionType sessionType; /**< Audio session type */ +}; + +/** + * @brief Describes AudioInfo. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioInfo { + struct AudioDevExtInfo device; /* Specific Device Ext info */ + struct AudioMixExtInfo mix; /* Specific mix info */ + struct AudioSessionExtInfo session; /* session specific info */ +}; + +/** + * @brief Describes AudioRouteNode. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioRouteNode { + int portId; /**< Audio port ID */ + enum AudioPortRole role; /**< Audio port as a sink or a source */ + enum AudioPortType type; /**< device, mix ... */ + struct AudioInfo ext; /**< The ext object */ +}; + +/** + * @brief Describes AudioRoute. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioRoute { + struct AudioRouteNode[] sources; /**< List of sources */ + struct AudioRouteNode[] sinks; /**< List of sinks */ +}; + +/** + * @brief Describes AudioEvent. + * + * @since 4.1 + * @version 2.0 + */ +struct AudioEvent { + unsigned int eventType; /**< @link enum AudioEventType */ + unsigned int deviceType; /**< @link enum AudioDeviceType */ +}; diff --git a/audio/v4_0/BUILD.gn b/audio/v4_0/BUILD.gn new file mode 100644 index 00000000..bf024567 --- /dev/null +++ b/audio/v4_0/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2024 Huawei Device 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. + +import("//build/config/components/hdi/hdi.gni") + +if (defined(ohos_lite)) { + group("libaudio_proxy_4.0") { + deps = [] + public_configs = [] + } +} else { + hdi("audio") { + module_name = "audio_service" + + sources = [ + "AudioTypes.idl", + "IAudioAdapter.idl", + "IAudioCallback.idl", + "IAudioCapture.idl", + "IAudioManager.idl", + "IAudioRender.idl", + ] + + branch_protector_ret = "pac_ret" + + language = "c" + subsystem_name = "hdf" + part_name = "drivers_interface_audio" + } +} diff --git a/audio/v4_0/IAudioAdapter.idl b/audio/v4_0/IAudioAdapter.idl new file mode 100644 index 00000000..f2ff1e07 --- /dev/null +++ b/audio/v4_0/IAudioAdapter.idl @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +import ohos.hdi.audio.v4_0.AudioTypes; +import ohos.hdi.audio.v4_0.IAudioRender; +import ohos.hdi.audio.v4_0.IAudioCapture; +import ohos.hdi.audio.v4_0.IAudioCallback; + +/** + * @brief Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks, + * and obtaining the port capability set. + * + * @see IAudioRender + * @see IAudioCapture + * @since 4.1 + * @version 2.0 + */ +interface IAudioAdapter { + /** + * @brief Initializes all ports of an audio adapter. + * + * Call this function before calling other driver functions to check whether the initialization is complete. + * If the initialization is not complete, wait for a while (for example, 100 ms) and perform the check again + * until the port initialization is complete. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @return Returns 0 if the initialization is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + InitAllPorts(); + + /** + * @brief Creates an IAudioRender object. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter to start. + * @param attrs Indicates the pointer to the audio sampling attributes to open. + * @param render Indicates the double pointer to the IAudioRender object. + * @return Returns 0 if the IAudioRender object is created successfully; + * returns a negative value otherwise. + * @see GetPortCapability + * @see DestroyRender + * + * @since 4.1 + * @version 2.0 + */ + CreateRender([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, + [out] IAudioRender render, [out] unsigned int renderId); + + /** + * @brief Destroys an IAudioRender object. + * + * @attention Do not destroy the object during audio rendering. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param render Indicates the pointer to the IAudioRender object to operate. + * @return Returns 0 if the IAudioRender object is destroyed; returns a negative value otherwise. + * @see CreateRender + * + * @since 4.1 + * @version 2.0 + */ + DestroyRender([in] unsigned int renderId); + + /** + * @brief Creates an IAudioCapture object. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter to start. + * @param attrs Indicates the pointer to the audio sampling attributes to open. + * @param capture Indicates the double pointer to the IAudioCapture object. + * @return Returns 0 if the IAudioCapture object is created successfully; + * returns a negative value otherwise. + * @see GetPortCapability + * @see DestroyCapture + * + * @since 4.1 + * @version 2.0 + */ + CreateCapture([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, + [out] IAudioCapture capture, [out] unsigned int captureId); + + /** + * @brief Destroys an IAudioCapture object. + * + * @attention Do not destroy the object during audio capturing. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param capture Indicates the pointer to the IAudioCapture object to operate. + * @return Returns 0 if the IAudioCapture object is destroyed; returns a negative value otherwise. + * @see CreateCapture + * + * @since 4.1 + * @version 2.0 + */ + DestroyCapture([in] unsigned int captureId); + + /** + * @brief Obtains the capability set of the port driver for the audio adapter. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param capability Indicates the pointer to the capability set to obtain. + * @return Returns 0 if the capability set is successfully obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetPortCapability([in] struct AudioPort port, [out] struct AudioPortCapability capability); + + /** + * @brief Sets the passthrough data transmission mode of the audio port driver. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param mode Indicates the passthrough transmission mode to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetPassthroughMode + * + * @since 4.1 + * @version 2.0 + */ + SetPassthroughMode([in] struct AudioPort port, [in] enum AudioPortPassthroughMode mode); + + /** + * @brief Obtains the passthrough data transmission mode of the audio port driver. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param mode Indicates the pointer to the passthrough transmission mode to obtain. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + * + * @since 4.1 + * @version 2.0 + */ + GetPassthroughMode([in] struct AudioPort port, [out] enum AudioPortPassthroughMode mode); + + /** + * @brief Get the device status of an adapter. + * + * @param adapter Indicates the audio adapter. + * @param status Indicates the status of device . + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetDeviceStatus([out] struct AudioDeviceStatus status); + + /** + * @brief Update audio route on several source and sink ports. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param route Indicates route information. + * @param routeHandle Indicates route handle. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + * + * @since 4.1 + * @version 2.0 + */ + UpdateAudioRoute([in] struct AudioRoute route, [out] int routeHandle); + + /** + * @brief Release an audio route. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param routeHandle Indicates route handle. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + * + * @since 4.1 + * @version 2.0 + */ + ReleaseAudioRoute([in] int routeHandle); + + /** + * @brief Sets the mute operation for the audio. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param mute Specifies whether to mute the audio. Value true means to mute the audio, + * and false means the opposite. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetMute + * + * @since 4.1 + * @version 2.0 + */ + SetMicMute([in] boolean mute); + + /** + * @brief Obtains the mute operation set for the audio. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param mute Indicates the pointer to the mute operation set for the audio. Value true means that + * the audio is muted, and false means the opposite. + * @return Returns 0 if the mute operation is obtained; returns a negative value otherwise. + * @see SetMute + * + * @since 4.1 + * @version 2.0 + */ + GetMicMute([out] boolean mute); + + /** + * @brief Sets the audio volume for voice call. + * + * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, + * 0.0 indicates that the audio is muted, and 1.0 indicates the maximum volume level (15). + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetVolume + * + * @since 4.1 + * @version 2.0 + */ + SetVoiceVolume([in] float volume); + + /** + * @brief Sets extra audio parameters. + * + * @param adapter Indicates the audio adapter. + * @param key Indicates what kind of parameter type will be set. + * @param condition Indicates the specific extend parameter condition of AudioExtParamKey. + * @param value Indicates the value of the specified condition. + * + * The format of condition is key=value. Separate multiple key-value pairs by semicolons (;). + * When key equals to AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME, the format of condition must be like this: + * "EVENT_TYPE=xxx;VOLUME_GROUP_ID=xxx;AUDIO_VOLUME_TYPE=xxx;" + * EVENT_TYPE indicates sub volume event type: SetVolume = 1; SetMute = 4; + * VOLUME_GROUP_ID indicates which volume group will be set; + * AUDIO_VOLUME_TYPE indicates which volume type will be set; + * + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + SetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [in] String value); + + /** + * @brief Get extra audio parameters. + * + * @param adapter Indicates the audio adapter. + * @param key Indicates what kind of parameter type will be get. + * @param condition Indicates the specific extend parameter condition of AudioExtParamKey. + * @param value Indicates the value of the specified condition. + * @param lenth Indicates the length of the value pointer. + * + * The format of condition is key=value. Separate multiple key-value pairs by semicolons (;). + * When key equals to AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME, the format of condition must be like this: + * "EVENT_TYPE=xxx;VOLUME_GROUP_ID=xxx;AUDIO_VOLUME_TYPE=xxx;" + * EVENT_TYPE indicates sub volume event type: GetVolume = 1; GetMinVolume = 2; GetMaxVolume = 3; IsStreamMute = 4; + * VOLUME_GROUP_ID indicates which volume group want get; + * AUDIO_VOLUME_TYPE indicates which volume type want get; + * + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [out] String value); + + /** + * @brief Register extra audio parameters observer. + * + * @param adapter Indicates the audio adapter. + * @param callback Indicates param observer. + * @param cookie Indicates the pointer to the callback parameters; + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + RegExtraParamObserver([in] IAudioCallback audioCallback, [in] byte cookie); +} +/** @} */ \ No newline at end of file diff --git a/audio/v4_0/IAudioCallback.idl b/audio/v4_0/IAudioCallback.idl new file mode 100644 index 00000000..87ee7d9f --- /dev/null +++ b/audio/v4_0/IAudioCallback.idl @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +import ohos.hdi.audio.v4_0.AudioTypes; + +/** + * @brief Called when an event defined in {@link AudioCallbackType} occurs. + * + * @param AudioCallbackType Indicates the occurred event that triggers this callback. + * @param reserved Indicates the pointer to a reserved field. + * @param cookie Indicates the pointer to the cookie for data transmission. + * @return Returns 0 if the callback is successfully executed; returns a negative value otherwise. + * @see RegCallback + * + * @since 4.1 + * @version 2.0 + */ +[callback] interface IAudioCallback { +/** + * @brief Called when an event defined in {@link AudioCallbackType} occurs. + * + * @param AudioCallbackType Indicates the occurred event that triggers this callback. + * @param reserved Indicates the pointer to a reserved field. + * @param cookie Indicates the pointer to the cookie for data transmission. + * @return Returns 0 if the callback is successfully executed; returns a negative value otherwise. + * @see RegCallback + * + * @since 4.1 + * @version 2.0 + */ + RenderCallback([in] enum AudioCallbackType type, [out] byte reserved, [out] byte cookie); + +/** + * @brief Register audio extra param callback that will be invoked during audio param event. + * + * @param key Indicates param change event. + * @param condition Indicates the param condition. + * @param value Indicates the param value. + * @param reserved Indicates reserved param. + * @param cookie Indicates the pointer to the callback parameters; + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + ParamCallback([in] enum AudioExtParamKey key, [in] String condition, [in] String value, [out] byte reserved, [in] byte cookie); +} diff --git a/audio/v4_0/IAudioCapture.idl b/audio/v4_0/IAudioCapture.idl new file mode 100644 index 00000000..b812a374 --- /dev/null +++ b/audio/v4_0/IAudioCapture.idl @@ -0,0 +1,487 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +import ohos.hdi.audio.v4_0.AudioTypes; + + +/** + * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, + * scenes, and volume, and capturing audio frames. + * @since 4.1 + * @version 4.0 + */ +interface IAudioCapture { + /** + * @brief Reads a frame of input data (uplink data) from the audio driver for capturing. + * + * @param capture Indicates the pointer to the IAudioCapture object to operate. + * @param frame Indicates the pointer to the input data to read. + * @param requestBytes Indicates the size of the input data, in bytes. + * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to read. + * @return Returns 0 if the input data is read successfully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + CaptureFrame([out] byte[] frame, [out] unsigned long replyBytes); + + /** + * @brief Reads a ec frame of input data (uplink data) from the audio driver for capturing. + * + * @param capture Indicates the pointer to the IAudioCapture object to operate. + * @param frameLen Indicates the pointer to the len of captureEc frame. + * @param frameInfo Indicates the pointer to the audio captureEc attributes. + * @return Returns 0 if the input data is read successfully; returns a negative value otherwise. + * + * @since 5.0 + * @version 1.0 + */ + CaptureFrameEc([in] struct AudioFrameLen frameLen, [out] struct AudioCaptureFrameInfo frameInfo); + + /** + * @brief Obtains the last number of input audio frames. + * + * @param capture Indicates the pointer to the IAudioCapture object to operate. + * @param frames Indicates the pointer to the last number of input audio frames. + * @param time Indicates the pointer to the timestamp associated with the frame. + * @return Returns 0 if the last number is obtained; returns a negative value otherwise. + * @see CaptureFrame + * + * @since 4.1 + * @version 2.0 + */ + GetCapturePosition([out] unsigned long frames, [out] struct AudioTimeStamp time); + + /** + * @brief Checks whether the configuration of an audio scene is supported. + * + * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene. + * @param supported Indicates the pointer to the variable specifying whether the configuration is supported. + * Value true means that the configuration is supported, and false means the opposite. + * @return Returns 0 if the result is obtained; returns a negative value otherwise. + * @see SelectScene + * + * @since 4.1 + * @version 2.0 + */ + CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); + + /** + * @brief Selects an audio scene. + * + *
    + *
  • To select a specific audio scene, you need to specify both the application scenario and output device. + * For example, to select a scene using a smartphone speaker as the output device, set scene according + * to the scenarios where the speaker is used. For example:
  • + *
      + *
    • For media playback, set the value to media_speaker.
    • + *
    • For a voice call, set the value to voice_speaker.
    • + *
    + *
  • To select only the application scenario, such as media playback, movie, or gaming, you can set + * scene to media, movie, or game, respectively.
  • + *
  • To select only the output device, such as media receiver, speaker, or headset, you can set + * scene to receiver, speaker, or headset, respectively.
  • + *
+ * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene to select. + * @return Returns 0 if the scene is selected successfully; returns a negative value otherwise. + * @see CheckSceneCapability + * + * @since 4.1 + * @version 2.0 + */ + SelectScene([in] struct AudioSceneDescriptor scene); + + /** + * @brief Sets the mute operation for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Specifies whether to mute the audio. Value true means to mute the audio, + * and false means the opposite. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetMute + * + * @since 4.1 + * @version 2.0 + */ + SetMute([in] boolean mute); + + /** + * @brief Obtains the mute operation set for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Indicates the pointer to the mute operation set for the audio. Value true means that + * the audio is muted, and false means the opposite. + * @return Returns 0 if the mute operation is obtained; returns a negative value otherwise. + * @see SetMute + * + * @since 4.1 + * @version 2.0 + */ + GetMute([out] boolean mute); + + /** + * @brief Sets the audio volume. + * + * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, + * 0.0 indicates that the audio is muted, and 1.0 indicates the maximum volume level (15). + * + * @param handle Indicates the audio handle. + * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetVolume + * + * @since 4.1 + * @version 2.0 + */ + SetVolume([in] float volume); + + /** + * @brief Obtains the audio volume. + * + * @param handle Indicates the audio handle. + * @param volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the volume is obtained; returns a negative value otherwise. + * @see SetVolume + * + * @since 4.1 + * @version 2.0 + */ + GetVolume([out] float volume); + + /** + * @brief Obtains the range of the audio gain. + * + * The audio gain can be expressed in one of the following two ways (depending on the chip platform), + * corresponding to two types of value ranges: + *
    + *
  • Actual audio gain values, for example, ranging from -50 to 6 dB
  • + *
  • Float numbers ranging from 0.0 to 1.0, where 0.0 means to mute the audio, + * and 1.0 means the maximum gain value, for example, 6 dB
  • + *
+ * @param handle Indicates the audio handle. + * @param min Indicates the pointer to the minimum value of the range. + * @param max Indicates the pointer to the maximum value of the range. + * @return Returns 0 if the range is obtained; returns a negative value otherwise. + * @see GetGain + * @see SetGain + * + * @since 4.1 + * @version 2.0 + */ + GetGainThreshold([out] float min, [out] float max); + + /** + * @brief Obtains the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the pointer to the audio gain. + * @return Returns 0 if the audio gain is obtained; returns a negative value otherwise. + * @see GetGainThreshold + * @see SetGain + * + * @since 4.1 + * @version 2.0 + */ + GetGain([out] float gain); + + /** + * @brief Sets the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the audio gain to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetGainThreshold + * @see GetGain + * + * @since 4.1 + * @version 2.0 + */ + SetGain([in] float gain); + + /** + * @brief Obtains the audio frame size, that is, the length (in bytes) of a frame. + * + * @param handle Indicates the audio handle. + * @param size Indicates the pointer to the audio frame size (in bytes). + * @return Returns 0 if the audio frame size is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameSize([out] unsigned long size); + + /** + * @brief Obtains the number of audio frames in the audio buffer. + * + * @param handle Indicates the audio handle. + * @param count Indicates the pointer to the number of audio frames in the audio buffer. + * @return Returns 0 if the number of audio frames is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameCount([out] unsigned long count); + + /** + * @brief Sets audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes to set, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetSampleAttributes + * + * @since 4.1 + * @version 2.0 + */ + SetSampleAttributes([in] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if audio sampling attributes are obtained; returns a negative value otherwise. + * @see SetSampleAttributes + * + * @since 4.1 + * @version 2.0 + */ + GetSampleAttributes([out] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains the data channel ID of the audio. + * + * @param handle Indicates the audio handle. + * @param channelId Indicates the pointer to the data channel ID. + * @return Returns 0 if the data channel ID is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetCurrentChannelId([out] unsigned int channelId); + + /** + * @brief Sets extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + SetExtraParams([in] String keyValueList); + + /** + * @brief Obtains extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetExtraParams([out] String keyValueList); + + /** + * @brief Requests a mmap buffer. + * + * @param handle Indicates the audio handle. + * @param reqSize Indicates the size of the request mmap buffer. + * @param desc Indicates the pointer to the mmap buffer descriptor. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); + + /** + * @brief Obtains the read/write position of the current mmap buffer. + * + * @param handle Indicates the audio handle. + * @param frames Indicates the pointer to the frame where the read/write starts. + * @param time Indicates the pointer to the timestamp associated with the frame where the read/write starts. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); + + /** + * @brief Add the audio effect which the effectid indicated. + * + * @param handle Indicates the audio handle. + * @param effectid Indicates the audio effect instance identifier which is going to be added. + * @return Returns 0 if the audio effect were added succesffully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + AddAudioEffect([in] unsigned long effectid); + + /** + * @brief Remove the audio effect which the effectid indicated. + * + * @param handle Indicates the audio handle. + * @param effectid Indicates the audio effect which is going to be removed. + * @return Returns 0 if the audio effect were removed succesffully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + RemoveAudioEffect([in] unsigned long effectid); + + /** + * @brief Get the buffer size of render or capturer + * + * @param handle Indicates the audio handle. + * @param bufferSize Indicates the buffer size (in bytes) queried from the vendor + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameBufferSize([out] unsigned long bufferSize); + + /** + * @brief Starts audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully started; + * returns a negative value otherwise. + * @see Stop + * + * @since 4.1 + * @version 2.0 + */ + Start(); + + /** + * @brief Stops audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully stopped; + * returns a negative value otherwise. + * @see Start + * + * @since 4.1 + * @version 2.0 + */ + Stop(); + + /** + * @brief Pauses audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully paused; + * returns a negative value otherwise. + * @see Resume + * + * @since 4.1 + * @version 2.0 + */ + Pause(); + + /** + * @brief Resumes audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully resumed; + * returns a negative value otherwise. + * @see Pause + * + * @since 4.1 + * @version 2.0 + */ + Resume(); + + /** + * @brief Flushes data in the audio buffer. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the flush is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + Flush(); + + /** + * @brief Sets or cancels the standby mode of the audio device. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the device is set to standby mode; returns a positive value if the standby mode is + * canceled; returns a negative value if the setting fails. + * + * @since 4.1 + * @version 2.0 + */ + TurnStandbyMode(); + + /** + * @brief Dumps information about the audio device. + * + * @param handle Indicates the audio handle. + * @param range Indicates the range of the device information to dump, which can be brief or full information. + * @param fd Indicates the file to which the device information will be dumped. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + AudioDevDump([in] int range, [in] int fd); + + /** + * @brief Query whether the vendor support pause and resume. + * + * @param handle Indicates the audio handle. + * @param supportPause Indicates the state whether the vendor supports pausing. Value true means that + * the vendor supports, and false means the opposite. + * @param supportResume Indicates the state whether the vendor supports resuming. Value true means that + * the vendor supports, and false means the opposite. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see IsSupportsPauseAndResume + * + * @since 4.1 + * @version 2.0 + */ + IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); +} diff --git a/audio/v4_0/IAudioManager.idl b/audio/v4_0/IAudioManager.idl new file mode 100644 index 00000000..fb5bb894 --- /dev/null +++ b/audio/v4_0/IAudioManager.idl @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +import ohos.hdi.audio.v4_0.AudioTypes; +import ohos.hdi.audio.v4_0.IAudioAdapter; + +/** + * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio + * adapter descriptor. + * + * @see IAudioAdapter + * @since 4.1 + * @version 2.0 + */ +interface IAudioManager { + /** + * @brief Obtains the list of all adapters supported by an audio driver. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param descs Indicates the double pointer to the audio adapter list. + * @param size Indicates the pointer to the length of the list. + * @return Returns 0 if the list is obtained successfully; returns a negative value otherwise. + * @see LoadAdapter + * + * @since 4.1 + * @version 2.0 + */ + GetAllAdapters([out] struct AudioAdapterDescriptor[] descs); + + /** + * @brief Loads the driver for an audio adapter. + * + * For example, to load a USB driver, you may need to load a dynamic-link library (*.so) in specific implementation. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter. + * @param adapter Indicates the double pointer to the audio adapter. + * @return Returns 0 if the driver is loaded successfully; returns a negative value otherwise. + * @see GetAllAdapters + * @see UnloadAdapter + * + * @since 4.1 + * @version 2.0 + */ + LoadAdapter([in] struct AudioAdapterDescriptor desc, [out] IAudioAdapter adapter); + + /** + * @brief Unloads the driver of an audio adapter. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param adapter Indicates the pointer to the audio adapter whose driver will be unloaded. + * @see LoadAdapter + * + * @since 4.1 + * @version 2.0 + */ + UnloadAdapter([in] String adapterName); + + /** + * @brief Release the IAudioManager Object. + * + * @param object Indicates the pointer to the audio adapter manager to operate. + * @return Returns true if the Object is released; returns false otherwise. + * + * @since 4.1 + * @version 2.0 + */ + ReleaseAudioManagerObject(); +} diff --git a/audio/v4_0/IAudioRender.idl b/audio/v4_0/IAudioRender.idl new file mode 100644 index 00000000..8a28327f --- /dev/null +++ b/audio/v4_0/IAudioRender.idl @@ -0,0 +1,594 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +/** + * @addtogroup HdiAudio + * @ + * + * @brief Provides unified APIs for audio services to access audio drivers. + * + * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to + * access different types of audio devices based on the audio IDs, thereby obtaining audio information, + * subscribing to or unsubscribing from audio data, enabling or disabling an audio, + * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. + * + * @since 4.1 + * @version 4.0 + */ + +package ohos.hdi.audio.v4_0; + +import ohos.hdi.audio.v4_0.AudioTypes; +import ohos.hdi.audio.v4_0.IAudioCallback; + +/** + * @brief Provides capabilities for audio rendering, including controlling the rendering, setting audio attributes, + * scenes, and volume, obtaining hardware latency, and rendering audio frames. + * + * @since 4.1 + * @version 2.0 + */ +interface IAudioRender { + /** + * @brief Obtains the estimated latency of the audio device driver. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param ms Indicates the pointer to the latency (in milliseconds) to be obtained. + * @return Returns 0 if the latency is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetLatency([out] unsigned int ms); + + /** + * @brief Writes a frame of output data (downlink data) into the audio driver for rendering. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param frame Indicates the pointer to the frame to write. + * @param requestBytes Indicates the size of the frame, in bytes. + * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to write. + * @return Returns 0 if the data is written successfully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + RenderFrame([in] byte[] frame, [out] unsigned long replyBytes); + + /** + * @brief Obtains the last number of output audio frames. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param frames Indicates the pointer to the last number of output audio frames. + * @param time Indicates the pointer to the timestamp associated with the frame. + * @return Returns 0 if the last number is obtained; returns a negative value otherwise. + * @see RenderFrame + * + * @since 4.1 + * @version 2.0 + */ + GetRenderPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); + + /** + * @brief Sets the audio rendering speed. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param speed Indicates the rendering speed to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetRenderSpeed + * + * @since 4.1 + * @version 2.0 + */ + SetRenderSpeed([in] float speed); + + /** + * @brief Obtains the current audio rendering speed. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param speed Indicates the pointer to the current rendering speed to obtain. + * @return Returns 0 if the speed is successfully obtained; returns a negative value otherwise. + * @see SetRenderSpeed + * + * @since 4.1 + * @version 2.0 + */ + GetRenderSpeed([out] float speed); + + /** + * @brief Sets the channel mode for audio rendering. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param mode Indicates the channel mode to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetChannelMode + * + * @since 4.1 + * @version 2.0 + */ + SetChannelMode([in] enum AudioChannelMode mode); + + /** + * @brief Obtains the current channel mode for audio rendering. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param mode Indicates the pointer to the channel mode to obtain. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetChannelMode + * + * @since 4.1 + * @version 2.0 + */ + GetChannelMode([out] enum AudioChannelMode mode); + + /** + * @brief Registers an audio callback that will be invoked during playback when buffer data writing or + * buffer drain is complete. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param callback Indicates the callback to register. + * @param cookie Indicates the pointer to the callback parameters. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see RegCallback + * + * @since 4.1 + * @version 2.0 + */ + RegCallback([in] IAudioCallback audioCallback, [in] byte cookie); + + /** + * @brief Drains the buffer. + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param type Indicates the pointer to the execution type of this function. For details, + * see {@link AudioDrainNotifyType}. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see RegCallback + * + * @since 4.1 + * @version 2.0 + */ + DrainBuffer([out] enum AudioDrainNotifyType type); + + /** + * @brief query whether the vendor supports draining buffer + * + * @param render Indicates the pointer to the IAudioRender object to operate. + * @param support indicates the state whether the vendor supports draining buffer. Value true means that + * the vendor supports, and false means the opposite. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see IsSupportsDrain + * + * @since 4.1 + * @version 2.0 + */ + IsSupportsDrain([out] boolean support); + + /** + * @brief Checks whether the configuration of an audio scene is supported. + * + * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene. + * @param supported Indicates the pointer to the variable specifying whether the configuration is supported. + * Value true means that the configuration is supported, and false means the opposite. + * @return Returns 0 if the result is obtained; returns a negative value otherwise. + * @see SelectScene + * + * @since 4.1 + * @version 2.0 + */ + CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); + + /** + * @brief Selects an audio scene. + * + *
    + *
  • To select a specific audio scene, you need to specify both the application scenario and output device. + * For example, to select a scene using a smartphone speaker as the output device, set scene according + * to the scenarios where the speaker is used. For example:
  • + *
      + *
    • For media playback, set the value to media_speaker.
    • + *
    • For a voice call, set the value to voice_speaker.
    • + *
    + *
  • To select only the application scenario, such as media playback, movie, or gaming, you can set + * scene to media, movie, or game, respectively.
  • + *
  • To select only the output device, such as media receiver, speaker, or headset, you can set + * scene to receiver, speaker, or headset, respectively.
  • + *
+ * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene to select. + * @return Returns 0 if the scene is selected successfully; returns a negative value otherwise. + * @see CheckSceneCapability + * + * @since 4.1 + * @version 2.0 + */ + SelectScene([in] struct AudioSceneDescriptor scene); + + /** + * @brief Sets the mute operation for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Specifies whether to mute the audio. Value true means to mute the audio, + * and false means the opposite. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetMute + * + * @since 4.1 + * @version 2.0 + */ + SetMute([in] boolean mute); + + /** + * @brief Obtains the mute operation set for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Indicates the pointer to the mute operation set for the audio. Value true means that + * the audio is muted, and false means the opposite. + * @return Returns 0 if the mute operation is obtained; returns a negative value otherwise. + * @see SetMute + * + * @since 4.1 + * @version 2.0 + */ + GetMute([out] boolean mute); + + /** + * @brief Sets the audio volume. + * + * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, + * 0.0 indicates that the audio is muted, and 1.0 indicates the maximum volume level (15). + * + * @param handle Indicates the audio handle. + * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetVolume + * + * @since 4.1 + * @version 2.0 + */ + SetVolume([in] float volume); + + /** + * @brief Obtains the audio volume. + * + * @param handle Indicates the audio handle. + * @param volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the volume is obtained; returns a negative value otherwise. + * @see SetVolume + * + * @since 4.1 + * @version 2.0 + */ + GetVolume([out] float volume); + + /** + * @brief Obtains the range of the audio gain. + * + * The audio gain can be expressed in one of the following two ways (depending on the chip platform), + * corresponding to two types of value ranges: + *
    + *
  • Actual audio gain values, for example, ranging from -50 to 6 dB
  • + *
  • Float numbers ranging from 0.0 to 1.0, where 0.0 means to mute the audio, + * and 1.0 means the maximum gain value, for example, 6 dB
  • + *
+ * @param handle Indicates the audio handle. + * @param min Indicates the pointer to the minimum value of the range. + * @param max Indicates the pointer to the maximum value of the range. + * @return Returns 0 if the range is obtained; returns a negative value otherwise. + * @see GetGain + * @see SetGain + * + * @since 4.1 + * @version 2.0 + */ + GetGainThreshold([out] float min, [out] float max); + + /** + * @brief Obtains the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the pointer to the audio gain. + * @return Returns 0 if the audio gain is obtained; returns a negative value otherwise. + * @see GetGainThreshold + * @see SetGain + * + * @since 4.1 + * @version 2.0 + */ + GetGain([out] float gain); + + /** + * @brief Sets the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the audio gain to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetGainThreshold + * @see GetGain + * + * @since 4.1 + * @version 2.0 + */ + SetGain([in] float gain); + + /** + * @brief Obtains the audio frame size, that is, the length (in bytes) of a frame. + * + * @param handle Indicates the audio handle. + * @param size Indicates the pointer to the audio frame size (in bytes). + * @return Returns 0 if the audio frame size is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameSize([out] unsigned long size); + + /** + * @brief Obtains the number of audio frames in the audio buffer. + * + * @param handle Indicates the audio handle. + * @param count Indicates the pointer to the number of audio frames in the audio buffer. + * @return Returns 0 if the number of audio frames is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameCount([out] unsigned long count); + + /** + * @brief Sets audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes to set, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetSampleAttributes + * + * @since 4.1 + * @version 2.0 + */ + SetSampleAttributes([in] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if audio sampling attributes are obtained; returns a negative value otherwise. + * @see SetSampleAttributes + * + * @since 4.1 + * @version 2.0 + */ + GetSampleAttributes([out] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains the data channel ID of the audio. + * + * @param handle Indicates the audio handle. + * @param channelId Indicates the pointer to the data channel ID. + * @return Returns 0 if the data channel ID is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetCurrentChannelId([out] unsigned int channelId); + + /** + * @brief Sets extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + SetExtraParams([in] String keyValueList); + + /** + * @brief Obtains extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetExtraParams([out] String keyValueList); + + /** + * @brief Requests a mmap buffer. + * + * @param handle Indicates the audio handle. + * @param reqSize Indicates the size of the request mmap buffer. + * @param desc Indicates the pointer to the mmap buffer descriptor. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); + + /** + * @brief Obtains the read/write position of the current mmap buffer. + * + * @param handle Indicates the audio handle. + * @param frames Indicates the pointer to the frame where the read/write starts. + * @param time Indicates the pointer to the timestamp associated with the frame where the read/write starts. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); + + /** + * @brief Add the audio effect which the effectid indicated. + * + * @param handle Indicates the audio handle. + * @param effectid Indicates the audio effect instance identifier which is going to be added. + * @return Returns 0 if the audio effect were added succesffully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + AddAudioEffect([in] unsigned long effectid); + + /** + * @brief Remove the audio effect which the effectid indicated. + * + * @param handle Indicates the audio handle. + * @param effectid Indicates the audio effect which is going to be removed. + * @return Returns 0 if the audio effect were removed succesffully; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + RemoveAudioEffect([in] unsigned long effectid); + + /** + * @brief Get the buffer size of render or capturer + * + * @param handle Indicates the audio handle. + * @param bufferSize Indicates the buffer size (in bytes) queried from the vendor + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + GetFrameBufferSize([out] unsigned long bufferSize); + + /** + * @brief Starts audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully started; + * returns a negative value otherwise. + * @see Stop + * + * @since 4.1 + * @version 2.0 + */ + Start(); + + /** + * @brief Stops audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully stopped; + * returns a negative value otherwise. + * @see Start + * + * @since 4.1 + * @version 2.0 + */ + Stop(); + + /** + * @brief Pauses audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully paused; + * returns a negative value otherwise. + * @see Resume + * + * @since 4.1 + * @version 2.0 + */ + Pause(); + + /** + * @brief Resumes audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully resumed; + * returns a negative value otherwise. + * @see Pause + * + * @since 4.1 + * @version 2.0 + */ + Resume(); + + /** + * @brief Flushes data in the audio buffer. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the flush is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + Flush(); + + /** + * @brief Sets or cancels the standby mode of the audio device. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the device is set to standby mode; returns a positive value if the standby mode is + * canceled; returns a negative value if the setting fails. + * + * @since 4.1 + * @version 2.0 + */ + TurnStandbyMode(); + + /** + * @brief Dumps information about the audio device. + * + * @param handle Indicates the audio handle. + * @param range Indicates the range of the device information to dump, which can be brief or full information. + * @param fd Indicates the file to which the device information will be dumped. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + AudioDevDump([in] int range, [in] int fd); + + /** + * @brief Query whether the vendor support pause and resume. + * + * @param handle Indicates the audio handle. + * @param supportPause Indicates the state whether the vendor supports pausing. Value true means that + * the vendor supports, and false means the opposite. + * @param supportResume Indicates the state whether the vendor supports resuming. Value true means that + * the vendor supports, and false means the opposite. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see IsSupportsPauseAndResume + * + * @since 4.1 + * @version 2.0 + */ + IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); + + /** + * @brief Set offload buffer size. + * + * @param handle Indicates the audio handle. + * @param size Indicates the buffer size which contains the audio data. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + SetBufferSize([in] unsigned int size); +} -- Gitee