diff --git a/audiohandler/BUILD.gn b/audiohandler/BUILD.gn index cfc10ac40f97386f99fe33679ff9d2e44ca0af4e..ef27e2523666235435c2a070b125e08232b085fa 100644 --- a/audiohandler/BUILD.gn +++ b/audiohandler/BUILD.gn @@ -23,7 +23,14 @@ ohos_shared_library("distributed_audio_handler") { ubsan = true } stack_protector_ret = true - include_dirs = [ "//third_party/json/include" ] + include_dirs = [ + "//third_party/json/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include", + "${mediastandardfwk_path}/audiomanager/include", + "${mediastandardfwk_path}/audiocommon/include", + "${mediastandardfwk_path}/audiocapturer/include", + ] include_dirs += [ "include", diff --git a/audiohandler/include/daudio_handler.h b/audiohandler/include/daudio_handler.h index 75123436ca58414393e90960656cd982b9c8b1ee..4b79ea821c5cd754d1c5e3be46fc3cbaa3059bbd 100644 --- a/audiohandler/include/daudio_handler.h +++ b/audiohandler/include/daudio_handler.h @@ -22,6 +22,7 @@ #include "single_instance.h" #include "audio_param.h" #include "audio_capturer.h" +#include "audio_info.h" namespace OHOS { namespace DistributedHardware { diff --git a/audiohandler/include/ihardware_handler.h b/audiohandler/include/ihardware_handler.h deleted file mode 100644 index 5ff5c40582a3cc14adbf8d92b9b593879d250b6b..0000000000000000000000000000000000000000 --- a/audiohandler/include/ihardware_handler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_DISTRIBUTED_HARDWARE_IHARDWARE_HANDLER_H -#define OHOS_DISTRIBUTED_HARDWARE_IHARDWARE_HANDLER_H - -#include -#include -#include -#include - -namespace OHOS { -namespace DistributedHardware { -const std::string COMPONENT_LOADER_GET_HARDWARE_HANDLER = "GetHardwareHandler"; -struct DHItem { - std::string dhId; - std::string attrs; - std::string subtype; -}; - -class PluginListener { -public: - virtual void PluginHardware(const std::string &dhId, const std::string &attrs, const std::string &subtype) = 0; - virtual void UnPluginHardware(const std::string &dhId) = 0; -}; - -class IHardwareHandler { -public: - virtual int32_t Initialize() = 0; - virtual std::vector Query() = 0; - virtual std::map QueryExtraInfo() = 0; - virtual bool IsSupportPlugin() = 0; - virtual void RegisterPluginListener(std::shared_ptr listener) = 0; - virtual void UnRegisterPluginListener() = 0; -}; -extern "C" __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); -} // namespace DistributedHardware -} // namespace OHOS -#endif diff --git a/audiohandler/src/daudio_handler.cpp b/audiohandler/src/daudio_handler.cpp index c6551f37e62aa599cdd1011b3e1d72842e327b5a..36275a2e71c899a15091291d5a601a33138613d8 100644 --- a/audiohandler/src/daudio_handler.cpp +++ b/audiohandler/src/daudio_handler.cpp @@ -22,6 +22,7 @@ #include "nlohmann/json.hpp" #include "string_ex.h" +#include "histreamer_query_tool.h" #include "daudio_constants.h" #include "daudio_errorcode.h" #include "daudio_log.h" diff --git a/common/dfx_utils/include/daudio_hidumper.h b/common/dfx_utils/include/daudio_hidumper.h index 667e33db73ed5433d8cc26a6c602dd774933be88..aa1d6da9c99787b3ab35517c8fee2658cc28a045 100644 --- a/common/dfx_utils/include/daudio_hidumper.h +++ b/common/dfx_utils/include/daudio_hidumper.h @@ -20,6 +20,11 @@ #include #include "sys/stat.h" +#include "audio_capturer.h" +#include "audio_info.h" + +#include "audio_adapter.h" +#include "audio_manager.h" #include "daudio_handler.h" #include "single_instance.h" @@ -55,7 +60,10 @@ private: int32_t StopDumpData(std::string &result); private: + AudioManager *audioManager_ = nullptr; + AudioAdapterDescriptor *adapterdesc_ = nullptr; bool dumpAudioDataFlag_ = false; + int32_t g_deviceNum = 0; const std::string DEFAULT_SPK_DHID = "1"; const std::string DEFAULT_MIC_DHID = "134217729"; }; diff --git a/common/dfx_utils/src/daudio_hidumper.cpp b/common/dfx_utils/src/daudio_hidumper.cpp index 44376fb9e5655ca2c625d36d32473aa43df8ff49..d33ddbe83a415369a47cbb438c083c9a63375f61 100644 --- a/common/dfx_utils/src/daudio_hidumper.cpp +++ b/common/dfx_utils/src/daudio_hidumper.cpp @@ -128,6 +128,23 @@ int32_t DaudioHidumper::GetSourceDevId(std::string &result) int32_t DaudioHidumper::GetSinkInfo(std::string &result) { DHLOGI("Get sink info dump."); + audioManager_ = GetAudioManagerFuncs(); + if (audioManager_ == nullptr) { + return ERR_DH_AUDIO_NULLPTR; + } + int32_t ret = audioManager_->GetAllAdapters(audioManager_, &adapterdesc_, &g_deviceNum); + if (ret != DH_SUCCESS) { + DHLOGE("Get all adapters failed."); + return ERR_DH_AUDIO_NULLPTR; + } + for (int32_t index = 0; index < g_deviceNum; index++) { + AudioAdapterDescriptor &desc = adapterdesc_[index]; + result.append("sinkDevId: ").append(GetAnonyString(desc.adapterName)).append(" portId: "); + for (uint32_t i = 0; i < desc.portNum; i++) { + result.append(std::to_string(desc.ports[i].portId)).append(" "); + } + } + return DH_SUCCESS; } diff --git a/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn index 3b4c678b3c7145942b12bc8d3bfbec7f919803f2..2a10e58d1ae4e1f6bf0d7017735f94574844d2fc 100755 --- a/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn @@ -26,7 +26,10 @@ ohos_shared_library("distributed_audio_sink_sdk") { ubsan = true } stack_protector_ret = true - include_dirs = [ "//third_party/json/include" ] + include_dirs = [ + "${fwk_common_path}/utils/include", + "//third_party/json/include", + ] include_dirs += [ "include", diff --git a/interfaces/inner_kits/native_cpp/audio_sink/include/idistributed_hardware_sink.h b/interfaces/inner_kits/native_cpp/audio_sink/include/idistributed_hardware_sink.h deleted file mode 100644 index db9dc6c6d91b24db9315c48987e75ba024772c63..0000000000000000000000000000000000000000 --- a/interfaces/inner_kits/native_cpp/audio_sink/include/idistributed_hardware_sink.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_DISTRIBUTED_HARDWARE_IDISTRIBUTED_HARDWARE_SINK_H -#define OHOS_DISTRIBUTED_HARDWARE_IDISTRIBUTED_HARDWARE_SINK_H - -#include - -namespace OHOS { -namespace DistributedHardware { -const std::string COMPONENT_LOADER_GET_SINK_HANDLER = "GetSinkHardwareHandler"; -enum class ResourceEventType : int32_t { - EVENT_TYPE_QUERY_RESOURCE = 0, - EVENT_TYPE_PULL_UP_PAGE = 1, - EVENT_TYPE_CLOSE_PAGE = 2 -}; - -class SubscribeCallback { -public: - virtual int32_t OnSubscribeCallback(const std::string &dhId, int32_t status, const std::string &data) = 0; -}; - -class PrivacyResourcesListener { -public: - virtual int32_t OnPrivaceResourceMessage(const ResourceEventType &type, const std::string &subType, - const std::string &networkId, bool &isSensitive, bool &isSameAccout) = 0; -}; - -class IDistributedHardwareSink { -public: - virtual int32_t InitSink(const std::string ¶ms) = 0; - virtual int32_t ReleaseSink() = 0; - virtual int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶ms) = 0; - virtual int32_t UnsubscribeLocalHardware(const std::string &dhId) = 0; - virtual int32_t RegisterPrivacyResources(std::shared_ptr listener) = 0; - virtual int32_t PauseDistributedHardware(const std::string &networkId) = 0; - virtual int32_t ResumeDistributedHardware(const std::string &networkId) = 0; - virtual int32_t StopDistributedHardware(const std::string &networkId) = 0; -}; -extern "C" __attribute__((visibility("default"))) IDistributedHardwareSink* GetSinkHardwareHandler(); -} // namespace DistributedHardware -} // namespace OHOS -#endif diff --git a/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn b/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn index 9fcf62d753f919aed2ea89c337c84558a26209cb..feacb89b654b5be163c7e8551eab5a4f6e40ed3f 100755 --- a/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn @@ -26,7 +26,10 @@ ohos_shared_library("distributed_audio_source_sdk") { ubsan = true } stack_protector_ret = true - include_dirs = [ "//third_party/json/include" ] + include_dirs = [ + "${fwk_common_path}/utils/include", + "//third_party/json/include", + ] include_dirs += [ "include", diff --git a/interfaces/inner_kits/native_cpp/audio_source/include/idistributed_hardware_source.h b/interfaces/inner_kits/native_cpp/audio_source/include/idistributed_hardware_source.h deleted file mode 100644 index 78e2ed4d193b5607584b1821facc4b0c7c5993d3..0000000000000000000000000000000000000000 --- a/interfaces/inner_kits/native_cpp/audio_source/include/idistributed_hardware_source.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_DISTRIBUTED_HARDWARE_IDISTRIBUTED_HARDWARE_SOURCE_H -#define OHOS_DISTRIBUTED_HARDWARE_IDISTRIBUTED_HARDWARE_SOURCE_H - -#include -#include - -namespace OHOS { -namespace DistributedHardware { -const std::string COMPONENT_LOADER_GET_SOURCE_HANDLER = "GetSourceHardwareHandler"; -class RegisterCallback { -public: - virtual int32_t OnRegisterResult(const std::string &uuid, const std::string &dhId, int32_t status, - const std::string &data) = 0; -}; - -class UnregisterCallback { -public: - virtual int32_t OnUnregisterResult(const std::string &uuid, const std::string &dhId, int32_t status, - const std::string &data) = 0; -}; - -struct EnableParam { - std::string sourceVersion; - std::string sourceAttrs; - std::string sinkVersion; - std::string sinkAttrs; - std::string subtype; -}; - -class IDistributedHardwareSource { -public: - virtual int32_t InitSource(const std::string ¶ms) = 0; - virtual int32_t ReleaseSource() = 0; - virtual int32_t RegisterDistributedHardware(const std::string &uuid, const std::string &dhId, - const EnableParam ¶m, std::shared_ptr callback) = 0; - virtual int32_t UnregisterDistributedHardware(const std::string &uuid, const std::string &dhId, - std::shared_ptr callback) = 0; - virtual int32_t ConfigDistributedHardware(const std::string &uuid, const std::string &dhId, const std::string &key, - const std::string &value) = 0; -}; -extern "C" __attribute__((visibility("default"))) IDistributedHardwareSource* GetSourceHardwareHandler(); -} // namespace DistributedHardware -} // namespace OHOS -#endif diff --git a/services/audiomanager/servicesink/BUILD.gn b/services/audiomanager/servicesink/BUILD.gn index 842a85754d91746f3d746651fa614f857b49988a..022415421ae243117915c6bf1e8ce8ab071406d0 100755 --- a/services/audiomanager/servicesink/BUILD.gn +++ b/services/audiomanager/servicesink/BUILD.gn @@ -29,6 +29,7 @@ ohos_shared_library("distributed_audio_sink") { include_dirs = [ "//third_party/json/include", "//third_party/cJSON", + "${fwk_common_path}/utils/include", ] include_dirs += [ diff --git a/services/audiomanager/servicesource/BUILD.gn b/services/audiomanager/servicesource/BUILD.gn index caf33f137310069ed62743464c36c6d89b49dd3d..c7d2fb51808b275b60be263faf559266bba891fd 100755 --- a/services/audiomanager/servicesource/BUILD.gn +++ b/services/audiomanager/servicesource/BUILD.gn @@ -29,6 +29,11 @@ ohos_shared_library("distributed_audio_source") { include_dirs = [ "//third_party/json/include", "//third_party/cJSON", + "${driver_audio_path}/include", + "${fwk_common_path}/utils/include", + "${mediastandardfwk_path}/audiocapturer/include", + "${mediastandardfwk_path}/audiocommon/include", + "${mediastandardfwk_path}/audiomanager/include", ] include_dirs += [ @@ -44,6 +49,7 @@ ohos_shared_library("distributed_audio_source") { "${common_path}/dfx_utils/include", "${common_path}/include", "${distributedaudio_path}/audiohandler/include", + "${hdf_service_path}/hdi_service/common/include", "${innerkits_path}/native_cpp/audio_sink/include", "${innerkits_path}/native_cpp/audio_source/include", "${interfaces_path}/inner_kits/native_cpp/audio_sink/include", @@ -86,7 +92,6 @@ ohos_shared_library("distributed_audio_source") { external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", - "audio_framework:audio_capturer", "c_utils:utils", "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", diff --git a/services/audiotransport/receiverengine/BUILD.gn b/services/audiotransport/receiverengine/BUILD.gn index df5377c3423602d874cc3022ddf74dd8a464ab2f..98cc9aa94dd1e0df3664cbd828f39bd501ffeb63 100644 --- a/services/audiotransport/receiverengine/BUILD.gn +++ b/services/audiotransport/receiverengine/BUILD.gn @@ -33,7 +33,11 @@ ohos_shared_library("distributed_audio_decode_transport") { ubsan = true } stack_protector_ret = true - include_dirs = [ "//third_party/json/include" ] + include_dirs = [ + "${mediastandard_path}/interfaces/innerkits/native/media/include", + "${mediastandardfwk_path}/audiocommon/include", + "//third_party/json/include", + ] include_dirs += [ "include", diff --git a/services/audiotransport/senderengine/BUILD.gn b/services/audiotransport/senderengine/BUILD.gn index fd72053088401a1ee6b5aa8e5edb75b0b1416a5f..6e18f37a28a06c8cb9f215d511eb193de20edae8 100644 --- a/services/audiotransport/senderengine/BUILD.gn +++ b/services/audiotransport/senderengine/BUILD.gn @@ -33,7 +33,11 @@ ohos_shared_library("distributed_audio_encode_transport") { ubsan = true } stack_protector_ret = true - include_dirs = [ "//third_party/json/include" ] + include_dirs = [ + "${mediastandard_path}/interfaces/innerkits/native/media/include", + "${mediastandardfwk_path}/audiocommon/include", + "//third_party/json/include", + ] include_dirs += [ "include", diff --git a/services/hdfaudioclient/BUILD.gn b/services/hdfaudioclient/BUILD.gn index a29eb55d79e699f17c690ad31f18c60b09e78c04..f702e01b242c62037056c323f94322152dab75ee 100644 --- a/services/hdfaudioclient/BUILD.gn +++ b/services/hdfaudioclient/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/ohos.gni") +import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") import("../../distributedaudio.gni") ohos_shared_library("daudio_client") { @@ -28,6 +29,7 @@ ohos_shared_library("daudio_client") { include_dirs = [ "./include", "${common_path}/include", + "${driver_audio_path}/include", ] sources = [ @@ -39,7 +41,7 @@ ohos_shared_library("daudio_client") { "./src/distributed_audio_client.cpp", ] - deps = [ "${services_path}/common:distributed_audio_utils" ] + public_deps = [ "${services_path}/common:distributed_audio_utils" ] external_deps = [ "c_utils:utils", diff --git a/services/hdfaudioclient/include/audio_adapter.h b/services/hdfaudioclient/include/audio_adapter.h deleted file mode 100644 index 5872080aa8301f2a652751b2f951a421e1970fef..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_adapter.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_adapter.h - * - * @brief Declares APIs for operations related to the audio adapter. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_ADAPTER_H -#define AUDIO_ADAPTER_H - -#include "audio_types.h" -#include "audio_render.h" -#include "audio_capture.h" - -/** - * @brief Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks, - * and obtaining the port capability set. - * - * @see AudioRender - * @see AudioCapture - * @since 1.0 - * @version 1.0 - */ -struct AudioAdapter { - /** - * @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. - */ - int32_t (*InitAllPorts)(struct AudioAdapter *adapter); - - /** - * @brief Creates an AudioRender 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 AudioRender object. - * @return Returns 0 if the AudioRender object is created successfully; - * returns a negative value otherwise. - * @see GetPortCapability - * @see DestroyRender - */ - int32_t (*CreateRender)(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, - const struct AudioSampleAttributes *attrs, struct AudioRender **render); - - /** - * @brief Destroys an AudioRender 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 AudioRender object to operate. - * @return Returns 0 if the AudioRender object is destroyed; returns a negative value otherwise. - * @see CreateRender - */ - int32_t (*DestroyRender)(struct AudioAdapter *adapter, struct AudioRender *render); - - /** - * @brief Creates an AudioCapture 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 AudioCapture object. - * @return Returns 0 if the AudioCapture object is created successfully; - * returns a negative value otherwise. - * @see GetPortCapability - * @see DestroyCapture - */ - int32_t (*CreateCapture)(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, - const struct AudioSampleAttributes *attrs, struct AudioCapture **capture); - - /** - * @brief Destroys an AudioCapture 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 AudioCapture object to operate. - * @return Returns 0 if the AudioCapture object is destroyed; returns a negative value otherwise. - * @see CreateCapture - */ - int32_t (*DestroyCapture)(struct AudioAdapter *adapter, struct AudioCapture *capture); - - /** - * @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. - */ - int32_t (*GetPortCapability)(struct AudioAdapter *adapter, const struct AudioPort *port, - 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 - */ - int32_t (*SetPassthroughMode)(struct AudioAdapter *adapter, const struct AudioPort *port, - 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 - */ - int32_t (*GetPassthroughMode)(struct AudioAdapter *adapter, const struct AudioPort *port, - enum AudioPortPassthroughMode *mode); - - /** - * @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 - */ - int32_t (*UpdateAudioRoute)(struct AudioAdapter *adapter, const struct AudioRoute *route, int32_t *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 - */ - int32_t (*ReleaseAudioRoute)(struct AudioAdapter *adapter, int32_t 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 - */ - int32_t (*SetMicMute)(struct AudioAdapter *adapter, bool 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 - */ - int32_t (*GetMicMute)(struct AudioAdapter *adapter, bool *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 - */ - int32_t (*SetVoiceVolume)(struct AudioAdapter *adapter, 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. - */ - int32_t (*SetExtraParams)(struct AudioAdapter *adapter, enum AudioExtParamKey key, - const char *condition, const char *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. - */ - int32_t (*GetExtraParams)(struct AudioAdapter *adapter, enum AudioExtParamKey key, - const char *condition, char *value, int32_t lenth); - - /** - * @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. - */ - int32_t (*RegExtraParamObserver)(struct AudioAdapter *adapter, ParamCallback callback, void* cookie); - /** - * @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. - */ - int32_t (*GetDeviceStatus)(struct AudioAdapter *adapter, struct AudioDeviceStatus *status); -}; -#endif /* AUDIO_ADAPTER_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_attribute.h b/services/hdfaudioclient/include/audio_attribute.h deleted file mode 100644 index b5beed142c09ed3c7059725f7d98589e17ab9f97..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_attribute.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_attribute.h - * - * @brief Declares APIs for audio attributes. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_ATTRIBUTE_H -#define AUDIO_ATTRIBUTE_H - -#include "audio_types.h" - -/** - * @brief Provides attribute-related APIs for audio rendering or capturing, including functions to - * obtain frame information and set audio sampling attributes. - * - * @since 1.0 - * @version 1.0 - */ -struct AudioAttribute { - /** - * @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. - */ - int32_t (*GetFrameSize)(AudioHandle handle, uint64_t *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. - */ - int32_t (*GetFrameCount)(AudioHandle handle, uint64_t *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 - */ - int32_t (*SetSampleAttributes)(AudioHandle handle, const 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 - */ - int32_t (*GetSampleAttributes)(AudioHandle handle, 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. - */ - int32_t (*GetCurrentChannelId)(AudioHandle handle, uint32_t *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. - */ - int32_t (*SetExtraParams)(AudioHandle handle, const char *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. - */ - int32_t (*GetExtraParams)(AudioHandle handle, char *keyValueList, int32_t listLenth); - - /** - * @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. - */ - int32_t (*ReqMmapBuffer)(AudioHandle handle, int32_t reqSize, 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. - */ - int32_t (*GetMmapPosition)(AudioHandle handle, uint64_t *frames, 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. - */ - int32_t (*AddAudioEffect)(AudioHandle handle, uint64_t 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. - */ - int32_t (*RemoveAudioEffect)(AudioHandle handle, uint64_t 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. - */ - int32_t (*GetFrameBufferSize)(AudioHandle handle, uint64_t *bufferSize); -}; - -#endif /* AUDIO_ATTRIBUTE_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_capture.h b/services/hdfaudioclient/include/audio_capture.h deleted file mode 100644 index 52347aab1483324caeb99d0c57d71097f09757ce..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_capture.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_capture.h - * - * @brief Declares APIs for audio capturing. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_CAPTURE_H -#define AUDIO_CAPTURE_H - -#include "audio_types.h" -#include "audio_control.h" -#include "audio_attribute.h" -#include "audio_scene.h" -#include "audio_volume.h" - -/** - * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, - * scenes, and volume, and capturing audio frames. - * - * @see AudioControl - * @see AudioAttribute - * @see AudioScene - * @see AudioVolume - * @since 1.0 - * @version 1.0 - */ -struct AudioCapture { - /** - * @brief Defines the audio control. For details, see {@link AudioControl}. - */ - struct AudioControl control; - /** - * @brief Defines the audio attribute. For details, see {@link AudioAttribute}. - */ - struct AudioAttribute attr; - /** - * @brief Defines the audio scene. For details, see {@link AudioScene}. - */ - struct AudioScene scene; - /** - * @brief Defines audio volume. For details, see {@link AudioVolume}. - */ - struct AudioVolume volume; - - /** - * @brief Reads a frame of input data (uplink data) from the audio driver for capturing. - * - * @param capture Indicates the pointer to the AudioCapture 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. - */ - int32_t (*CaptureFrame)(struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes); - - /** - * @brief Obtains the last number of input audio frames. - * - * @param capture Indicates the pointer to the AudioCapture 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 - */ - int32_t (*GetCapturePosition)(struct AudioCapture *capture, uint64_t *frames, struct AudioTimeStamp *time); -}; - -#endif /* AUDIO_CAPTURE_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_control.h b/services/hdfaudioclient/include/audio_control.h deleted file mode 100644 index a20f7875395700f1fbf13582c51b22ece9daf41b..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_control.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_control.h - * - * @brief Declares APIs for audio control. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_CONTROL_H -#define AUDIO_CONTROL_H - -#include "audio_types.h" - -/** - * @brief Provides control-related APIs for audio rendering or capturing, including functions to - * start, stop, pause, and resume audio rendering or capturing, and flush data in the audio buffer. - * - * @since 1.0 - * @version 1.0 - */ -struct AudioControl { - /** - * @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 - */ - int32_t (*Start)(AudioHandle handle); - - /** - * @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 - */ - int32_t (*Stop)(AudioHandle handle); - - /** - * @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 - */ - int32_t (*Pause)(AudioHandle handle); - - /** - * @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 - */ - int32_t (*Resume)(AudioHandle handle); - - /** - * @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. - */ - int32_t (*Flush)(AudioHandle handle); - - /** - * @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. - */ - int32_t (*TurnStandbyMode)(AudioHandle handle); - - /** - * @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. - */ - int32_t (*AudioDevDump)(AudioHandle handle, int32_t range, int32_t 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 - */ - int32_t (*IsSupportsPauseAndResume)(AudioHandle handle, bool *supportPause, bool *supportResume); -}; - -#endif /* AUDIO_CONTROL_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_manager.h b/services/hdfaudioclient/include/audio_manager.h deleted file mode 100644 index f952dc3c6bf73282ebefc2e8a19b89293ae992a2..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_manager.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_manager.h - * - * @brief Declares APIs for audio adapter management and loading. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_MANAGER_H -#define AUDIO_MANAGER_H - -#include "audio_types.h" -#include "audio_adapter.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio - * adapter descriptor. - * - * @see AudioAdapter - * @since 1.0 - * @version 1.0 - */ -struct AudioManager { - /** - * @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 - */ - int32_t (*GetAllAdapters)(struct AudioManager *manager, struct AudioAdapterDescriptor **descs, int32_t *size); - - /** - * @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 - */ - int32_t (*LoadAdapter)(struct AudioManager *manager, const struct AudioAdapterDescriptor *desc, - struct AudioAdapter **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 - */ - void (*UnloadAdapter)(struct AudioManager *manager, struct AudioAdapter *adapter); - - /** - * @brief Release the AudioManager Object. - * - * @param object Indicates the pointer to the audio adapter manager to operate. - * @return Returns true if the Object is released; returns false otherwise. - */ - bool (*ReleaseAudioManagerObject)(struct AudioManager *object); -}; - -/** - * @brief Obtains the operation function list of the {@link AudioManager} class. - * - * @return Returns the pointer to the AudioManager object if the list is obtained; returns NULL otherwise. - */ -struct AudioManager *GetAudioManagerFuncs(void); - -#ifdef __cplusplus -} -#endif - -#endif /* AUDIO_MANAGER_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_render.h b/services/hdfaudioclient/include/audio_render.h deleted file mode 100644 index 1627fe629e6fa72da0cdec0f6fb859239f86c4be..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_render.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_render.h - * - * @brief Declares APIs for audio rendering. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_RENDER_H -#define AUDIO_RENDER_H - -#include "audio_types.h" -#include "audio_control.h" -#include "audio_attribute.h" -#include "audio_scene.h" -#include "audio_volume.h" - -/** - * @brief Provides capabilities for audio rendering, including controlling the rendering, setting audio attributes, - * scenes, and volume, obtaining hardware latency, and rendering audio frames. - * - * @see AudioControl - * @see AudioAttribute - * @see AudioScene - * @see AudioVolume - * @since 1.0 - * @version 1.0 - */ -struct AudioRender { - /** - * @brief Defines the audio control. For details, see {@link AudioControl}. - */ - struct AudioControl control; - /** - * @brief Defines the audio attribute. For details, see {@link AudioAttribute}. - */ - struct AudioAttribute attr; - /** - * @brief Defines the audio scene. For details, see {@link AudioScene}. - */ - struct AudioScene scene; - /** - * @brief Defines audio volume. For details, see {@link AudioVolume}. - */ - struct AudioVolume volume; - - /** - * @brief Obtains the estimated latency of the audio device driver. - * - * @param render Indicates the pointer to the AudioRender 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. - */ - int32_t (*GetLatency)(struct AudioRender *render, uint32_t *ms); - - /** - * @brief Writes a frame of output data (downlink data) into the audio driver for rendering. - * - * @param render Indicates the pointer to the AudioRender 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. - */ - int32_t (*RenderFrame)(struct AudioRender *render, const void *frame, uint64_t requestBytes, uint64_t *replyBytes); - - /** - * @brief Obtains the last number of output audio frames. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*GetRenderPosition)(struct AudioRender *render, uint64_t *frames, struct AudioTimeStamp *time); - - /** - * @brief Sets the audio rendering speed. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*SetRenderSpeed)(struct AudioRender *render, float speed); - - /** - * @brief Obtains the current audio rendering speed. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*GetRenderSpeed)(struct AudioRender *render, float *speed); - - /** - * @brief Sets the channel mode for audio rendering. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*SetChannelMode)(struct AudioRender *render, enum AudioChannelMode mode); - - /** - * @brief Obtains the current channel mode for audio rendering. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*GetChannelMode)(struct AudioRender *render, 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 AudioRender 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 - */ - int32_t (*RegCallback)(struct AudioRender *render, RenderCallback callback, void* cookie); - - /** - * @brief Drains the buffer. - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*DrainBuffer)(struct AudioRender *render, enum AudioDrainNotifyType *type); - - /** - * @brief query whether the vendor supports draining buffer - * - * @param render Indicates the pointer to the AudioRender 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 - */ - int32_t (*IsSupportsDrain)(struct AudioRender *render, bool *support); -}; - -#endif /* AUDIO_RENDER_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_scene.h b/services/hdfaudioclient/include/audio_scene.h deleted file mode 100644 index e6ef9f9050624d411b50eac80987ffe62c31943b..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_scene.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_scene.h - * - * @brief Declares APIs for audio scenes. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_SCENE_H -#define AUDIO_SCENE_H - -#include "audio_types.h" - -/** - * @brief Provides scene-related APIs for audio rendering or capturing, including functions to - * select an audio scene and check whether the configuration of an audio scene is supported. - * - * @since 1.0 - * @version 1.0 - */ -struct AudioScene { - /** - * @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 - */ - int32_t (*CheckSceneCapability)(AudioHandle handle, const struct AudioSceneDescriptor *scene, bool *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 - */ - int32_t (*SelectScene)(AudioHandle handle, const struct AudioSceneDescriptor *scene); -}; - -#endif /* AUDIO_SCENE_H */ -/** @} */ diff --git a/services/hdfaudioclient/include/audio_types.h b/services/hdfaudioclient/include/audio_types.h deleted file mode 100644 index 76662f99e776797c7032d5f5684940bbd76450a5..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_types.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_types.h - * - * @brief Defines custom data types used in API declarations for the audio module, including audio ports, - * adapter descriptors, device descriptors, scene descriptors, sampling attributes, and timestamp. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_TYPES_H -#define AUDIO_TYPES_H - -#include -#include - -/** - * @brief Defines the audio handle. - */ -typedef void *AudioHandle; - -/** - * @brief Enumerates the audio port type. - */ -enum AudioPortDirection { - PORT_OUT = 0x1u, /**< Output port */ - PORT_IN = 0x2u, /**< Input port */ - PORT_OUT_IN = 0x3u, /**< Input/output port, supporting both audio input and output */ -}; - -/** - * @brief Defines the audio port. - */ -struct AudioPort { - enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */ - uint32_t portId; /**< Audio port ID */ - const char *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). - */ -struct AudioAdapterDescriptor { - const char *adapterName; /**< Name of the audio adapter */ - uint32_t portNum; /**< Number of ports supported by an audio adapter */ - struct AudioPort *ports; /**< List of ports supported by an audio adapter */ -}; - -/** - * @brief Enumerates the pin of an audio adapter. - */ -enum AudioPortPin { - PIN_NONE = 0x0u, /**< Invalid pin */ - PIN_OUT_SPEAKER = 0x1u, /**< Speaker output pin */ - PIN_OUT_HEADSET = 0x2u, /**< Wired headset pin for output */ - PIN_OUT_LINEOUT = 0x4u, /**< Line-out pin */ - PIN_OUT_HDMI = 0x8u, /**< HDMI output pin */ - PIN_OUT_USB = 0x10u, /**< USB output pin */ - PIN_OUT_USB_EXT = 0x20u, /**< Extended USB output pin*/ - PIN_OUT_EARPIECE = 0x30u, /**< Earpiece output pin */ - PIN_OUT_BLUETOOTH_SCO = 0x40u, /**< Bluetooth SCO output pin */ - PIN_OUT_DAUDIO_DEFAULT = 0x80u, - PIN_OUT_HEADPHONE = 0x100u, /**< Wired headphone output pin*/ - PIN_OUT_USB_HEADSET = 0x200u, /**< ARM USB out pin */ - PIN_IN_MIC = 0x8000001u, /**< Microphone input pin */ - PIN_IN_HS_MIC = 0x8000002u, /**< Wired headset microphone pin for input */ - PIN_IN_LINEIN = 0x8000004u, /**< Line-in pin */ - PIN_IN_USB_EXT = 0x8000008u, /**< Extended USB input pin*/ - PIN_IN_BLUETOOTH_SCO_HEADSET = 0x8000010u, /**< Bluetooth SCO headset input pin */ - PIN_IN_USB_HEADSET = 0x8000040u, /**< ARM USB input pin */ -}; - -/** - * @brief Defines the audio device descriptor. - */ -struct AudioDeviceDescriptor { - uint32_t portId; /**< Audio port ID */ - enum AudioPortPin pins; /**< Pins of audio ports (input and output). For details, see {@link AudioPortPin}. */ - const char *desc; /**< Audio device name */ -}; - -/** - * @brief Enumerates the audio category. - */ -enum AudioCategory { - AUDIO_IN_MEDIA = 0, /**< Media */ - AUDIO_IN_COMMUNICATION, /**< Communications */ - AUDIO_IN_RINGTONE, /**< Ringtone */ - AUDIO_IN_CALL, /**< Call */ - AUDIO_MMAP_NOIRQ, /**< Mmap mode */ -}; - -/** - * @brief Defines the audio scene descriptor. - */ -struct AudioSceneDescriptor { - /** - * @brief Describes the audio scene. - */ - union SceneDesc { - uint32_t id; /**< Audio scene ID */ - const char *desc; /**< Name of the audio scene */ - } scene; /**< The scene object */ - struct AudioDeviceDescriptor desc; /**< Audio device descriptor */ -}; - -/** - * @brief Enumerates the audio format. - */ -enum AudioFormat { - AUDIO_FORMAT_TYPE_PCM_8_BIT = 0x1u, /**< 8-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_16_BIT = 0x2u, /**< 16-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_24_BIT = 0x3u, /**< 24-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_32_BIT = 0x4u, /**< 32-bit PCM */ - AUDIO_FORMAT_TYPE_AAC_MAIN = 0x1000001u, /**< AAC main */ - AUDIO_FORMAT_TYPE_AAC_LC = 0x1000002u, /**< AAC LC */ - AUDIO_FORMAT_TYPE_AAC_LD = 0x1000003u, /**< AAC LD */ - AUDIO_FORMAT_TYPE_AAC_ELD = 0x1000004u, /**< AAC ELD */ - AUDIO_FORMAT_TYPE_AAC_HE_V1 = 0x1000005u, /**< AAC HE_V1 */ - AUDIO_FORMAT_TYPE_AAC_HE_V2 = 0x1000006u, /**< AAC HE_V2 */ - AUDIO_FORMAT_TYPE_G711A = 0x2000001u, /**< G711A */ - AUDIO_FORMAT_TYPE_G711U = 0x2000002u, /**< G711u */ - AUDIO_FORMAT_TYPE_G726 = 0x2000003u, /**< G726 */ -}; - -/** - * @brief Enumerates the audio channel mask. - * - * A mask describes an audio channel position. - */ -enum AudioChannelMask { - AUDIO_CHANNEL_MONO = 1u, /**< Mono channel */ - AUDIO_CHANNEL_FRONT_LEFT = 1u, /**< Front left channel */ - AUDIO_CHANNEL_FRONT_RIGHT = 2u, /**< Front right channel */ - AUDIO_CHANNEL_FRONT_CENTER = 4u, /**< Front right channel */ - AUDIO_CHANNEL_LOW_FREQUENCY = 8u, /**< 0x8 */ - AUDIO_CHANNEL_BACK_LEFT = 16u, /**< 0x10 */ - AUDIO_CHANNEL_BACK_RIGHT = 32u, /**< 0x20 */ - AUDIO_CHANNEL_BACK_CENTER = 256u, /**< 0x100 */ - AUDIO_CHANNEL_SIDE_LEFT = 512u, /**< 0x200 */ - AUDIO_CHANNEL_SIDE_RIGHT = 1024u, /**< 0x400 */ - AUDIO_CHANNEL_TOP_SIDE_LEFT = 262144u, /**< 0x40000 */ - AUDIO_CHANNEL_TOP_SIDE_RIGHT = 524288u, /**< 0x80000 */ - AUDIO_CHANNEL_STEREO = 3u, /**< FRONT_LEFT | FRONT_RIGHT */ - AUDIO_CHANNEL_2POINT1 = 11u, /**< STEREO | LOW_FREQUENCY */ - AUDIO_CHANNEL_QUAD = 51u, /**< STEREO | BACK_LEFT | BACK_RIGHT */ - AUDIO_CHANNEL_3POINT0POINT2 = 786439u, /**< STEREO | FRONT_CENTER | TOP_SIDE_LEFT | TOP_SIDE_RIGHT */ - AUDIO_CHANNEL_5POINT1 = 63u, /**< QUAD | FRONT_CENTER | LOW_FREQUENCY */ - AUDIO_CHANNEL_6POINT1 = 319u, /**< AUDIO_CHANNEL_5POINT1 | BACK_CENTER */ - AUDIO_CHANNEL_7POINT1 = 1599u, /**< AUDIO_CHANNEL_5POINT1 | SIDE_LEFT | SIDE_RIGHT */ -}; - -/** - * @brief Enumerates masks of audio sampling rates. - */ -enum AudioSampleRatesMask { - AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, /**< 8 kHz */ - AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, /**< 12 kHz */ - AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, /**< 11.025 kHz */ - AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u, /**< 16 kHz */ - AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, /**< 22.050 kHz */ - AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, /**< 24 kHz */ - AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, /**< 32 kHz */ - AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u, /**< 44.1 kHz */ - AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, /**< 48 kHz */ - AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, /**< 64 kHz */ - AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, /**< 96 kHz */ - AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu, /**< Invalid sampling rate */ -}; -enum AudioInputType { - AUDIO_INPUT_DEFAULT_TYPE = 0, - AUDIO_INPUT_MIC_TYPE = 1 << 0, - AUDIO_INPUT_SPEECH_WAKEUP_TYPE = 1 << 1, - AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, - AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, -}; -/** - * @brief Defines audio sampling attributes. - */ -struct AudioSampleAttributes { - enum AudioCategory type; /**< Audio type. For details, see {@link AudioCategory} */ - bool interleaved; /**< Interleaving flag of audio data */ - enum AudioFormat format; /**< Audio data format. For details, see {@link AudioFormat}. */ - uint32_t sampleRate; /**< Audio sampling rate */ - uint32_t channelCount; /**< Number of audio channels. For example, for the mono channel, the value is 1, - * and for the stereo channel, the value is 2. - */ - uint32_t period; /**< Audio sampling period */ - uint32_t frameSize; /**< Frame size of the audio data */ - bool isBigEndian; /**< Big endian flag of audio data */ - bool isSignedData; /**< Signed or unsigned flag of audio data */ - uint32_t startThreshold; /**< Audio render start threshold. */ - uint32_t stopThreshold; /**< Audio render stop threshold. */ - uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ - int32_t streamId; /**< Audio Identifier of render or capture */ - int32_t sourceType; -}; - -/** - * @brief Defines the audio timestamp, which is a substitute for POSIX timespec. - */ -struct AudioTimeStamp { - int64_t tvSec; /**< Seconds */ - int64_t tvNSec; /**< Nanoseconds */ -}; - -/** - * @brief Enumerates the passthrough data transmission mode of an audio port. - */ -enum AudioPortPassthroughMode { - PORT_PASSTHROUGH_LPCM = 0x1, /**< Stereo PCM */ - PORT_PASSTHROUGH_RAW = 0x2, /**< HDMI passthrough */ - PORT_PASSTHROUGH_HBR2LBR = 0x4, /**< Blu-ray next-generation audio output with reduced specifications */ - PORT_PASSTHROUGH_AUTO = 0x8, /**< Mode automatically matched based on the HDMI EDID */ -}; - -/** - * @brief Defines the sub-port capability. - */ -struct AudioSubPortCapability { - uint32_t portId; /**< Sub-port ID */ - const char *desc; /**< Sub-port name */ - enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details, - * see {@link AudioPortPassthroughMode}. - */ -}; - -/** - * @brief Defines formats of raw audio samples. - */ -enum AudioSampleFormat { - /* 8 bits */ - AUDIO_SAMPLE_FORMAT_S8, /**< signed 8 bit sample */ - AUDIO_SAMPLE_FORMAT_S8P, /**< signed 8 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U8, /**< unsigned 8 bit sample */ - AUDIO_SAMPLE_FORMAT_U8P, /**< unsigned 8 bit planar sample */ - /* 16 bits */ - AUDIO_SAMPLE_FORMAT_S16, /**< signed 16 bit sample */ - AUDIO_SAMPLE_FORMAT_S16P, /**< signed 16 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U16, /**< unsigned 16 bit sample */ - AUDIO_SAMPLE_FORMAT_U16P, /**< unsigned 16 bit planar sample */ - /* 24 bits */ - AUDIO_SAMPLE_FORMAT_S24, /**< signed 24 bit sample */ - AUDIO_SAMPLE_FORMAT_S24P, /**< signed 24 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U24, /**< unsigned 24 bit sample */ - AUDIO_SAMPLE_FORMAT_U24P, /**< unsigned 24 bit planar sample */ - /* 32 bits */ - AUDIO_SAMPLE_FORMAT_S32, /**< signed 32 bit sample */ - AUDIO_SAMPLE_FORMAT_S32P, /**< signed 32 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U32, /**< unsigned 32 bit sample */ - AUDIO_SAMPLE_FORMAT_U32P, /**< unsigned 32 bit planar sample */ - /* 64 bits */ - AUDIO_SAMPLE_FORMAT_S64, /**< signed 64 bit sample */ - AUDIO_SAMPLE_FORMAT_S64P, /**< signed 64 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U64, /**< unsigned 64 bit sample */ - AUDIO_SAMPLE_FORMAT_U64P, /**< unsigned 64 bit planar sample */ - /* float double */ - AUDIO_SAMPLE_FORMAT_F32, /**< float 32 bit sample */ - AUDIO_SAMPLE_FORMAT_F32P, /**< float 32 bit planar sample */ - AUDIO_SAMPLE_FORMAT_F64, /**< double 64 bit sample */ - AUDIO_SAMPLE_FORMAT_F64P, /**< double 64 bit planar sample */ -}; - -/** - * @brief Defines the audio port capability. - */ -struct AudioPortCapability { - uint32_t deviceType; /**< Device type (output or input) */ - uint32_t deviceId; /**< Device ID used for device binding */ - bool hardwareMode; /**< Whether to support device binding */ - uint32_t formatNum; /**< Number of the supported audio formats */ - enum AudioFormat *formats; /**< Supported audio formats. For details, see {@link AudioFormat}. */ - uint32_t 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}. - */ - uint32_t channelCount; /**< Supported maximum number of audio channels */ - uint32_t subPortsNum; /**< Number of supported sub-ports (for output devices only) */ - struct AudioSubPortCapability *subPorts; /**< List of supported sub-ports */ - uint32_t supportSampleFormatNum; /**< Number of the supported audio sample format enum. */ - enum AudioSampleFormat *supportSampleFormats; /**< Supported audio sample formats. For details, - * see {@link AudioSampleFormat}. - */ -}; - -/** - * @brief Enumerates channel modes for audio rendering. - * - * @attention The following modes are set for rendering dual-channel audios. Others are not supported. - */ -enum AudioChannelMode { - AUDIO_CHANNEL_NORMAL = 0, /**< Normal mode. No processing is required. */ - AUDIO_CHANNEL_BOTH_LEFT, /**< Two left channels */ - AUDIO_CHANNEL_BOTH_RIGHT, /**< Two right channels */ - AUDIO_CHANNEL_EXCHANGE, /**< 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, /**< Mix of streams of the left and right channels */ - AUDIO_CHANNEL_LEFT_MUTE, /**< Left channel muted. The stream of the right channel is output. */ - AUDIO_CHANNEL_RIGHT_MUTE, /**< Right channel muted. The stream of the left channel is output. */ - AUDIO_CHANNEL_BOTH_MUTE, /**< Both left and right channels muted */ -}; - -/** - * @brief Enumerates the execution types of the DrainBuffer function. - */ -enum AudioDrainNotifyType { - AUDIO_DRAIN_NORMAL_MODE, /**< The DrainBuffer function returns after all data finishes playback. */ - AUDIO_DRAIN_EARLY_MODE, /**< 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. - */ -enum AudioCallbackType { - AUDIO_NONBLOCK_WRITE_COMPLETED, /**< The non-block write is complete. */ - AUDIO_DRAIN_COMPLETED, /**< The draining is complete. */ - AUDIO_FLUSH_COMPLETED, /**< The flush is complete. */ - AUDIO_RENDER_FULL, /**< The render buffer is full.*/ - AUDIO_ERROR_OCCUR, /**< An error occurs.*/ -}; - -/** - * @brief Describes a mmap buffer. - */ -struct AudioMmapBufferDescriptor { - void *memoryAddress; /**< Pointer to the mmap buffer */ - int32_t memoryFd; /**< File descriptor of the mmap buffer */ - int32_t totalBufferFrames; /**< Total size of the mmap buffer (unit: frame )*/ - int32_t transferFrameSize; /**< Transfer size (unit: frame) */ - int32_t isShareable; /**< Whether the mmap buffer can be shared among processes */ - uint32_t offset; -}; - -/** - * @brief Describes AudioPortRole. - */ -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. - */ -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 AudioDevExtInfo. - */ -struct AudioDevExtInfo { - int32_t moduleId; /**< Identifier of the module stream is attached to */ - enum AudioPortPin type; /**< Device type For details, see {@link AudioPortPin}. */ - const char *desc; /**< Address */ -}; - -/** - * @brief Describes AudioMixInfo. - */ -struct AudioMixExtInfo { - int32_t moduleId; /**< Identifier of the module stream is attached to */ - int32_t streamId; /**< Identifier of the capture or render passed by caller */ -}; - -/** - * @brief Describes AudioSessionType. - */ -enum AudioSessionType { - AUDIO_OUTPUT_STAGE_SESSION = 0, - AUDIO_OUTPUT_MIX_SESSION, - AUDIO_ALLOCATE_SESSION, - AUDIO_INVALID_SESSION, -}; - -/** - * @brief Describes AudioSessionExtInfo. - */ -struct AudioSessionExtInfo { - enum AudioSessionType sessionType; -}; - -/** - * @brief Describes AudioRouteNode. - */ -struct AudioRouteNode { - int32_t portId; /**< Audio port ID */ - enum AudioPortRole role; /**< Audio port as a sink or a source */ - enum AudioPortType type; /**< device, mix ... */ - union { - struct AudioDevExtInfo device; /* Specific Device Ext info */ - struct AudioMixExtInfo mix; /* Specific mix info */ - struct AudioSessionExtInfo session; /* session specific info */ - } ext; -}; - -/** - * @brief Describes AudioRoute. - */ -struct AudioRoute { - uint32_t sourcesNum; - const struct AudioRouteNode *sources; - uint32_t sinksNum; - const struct AudioRouteNode *sinks; -}; - -/** - * @brief Enumerates the restricted key type of the parameters - */ -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_LOWPOWER = 1000, /**< Low power event type */ -}; -/** - * @brief Describes status of audio deivce.@link enum AudioDeviceType - */ -struct AudioDeviceStatus { - uint32_t pnpStatus; -}; -/** - * @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 - */ -typedef int32_t (*RenderCallback)(enum AudioCallbackType, void *reserved, void *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. - */ -typedef int32_t (*ParamCallback)(enum AudioExtParamKey key, const char *condition, const char *value, void *reserved, - void *cookie); - -#endif /* AUDIO_TYPES_H */ diff --git a/services/hdfaudioclient/include/audio_volume.h b/services/hdfaudioclient/include/audio_volume.h deleted file mode 100644 index ad476f7ca61c02bdd4d15cb5dce81415bcc1c86c..0000000000000000000000000000000000000000 --- a/services/hdfaudioclient/include/audio_volume.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2020-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 Audio - * @{ - * - * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, - * accessing a driver adapter, and rendering and capturing audios. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file audio_volume.h - * - * @brief Declares APIs for audio volume. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef AUDIO_VOLUME_H -#define AUDIO_VOLUME_H - -#include "audio_types.h" - -/** - * @brief Provides volume-related APIs for audio rendering or capturing, including functions to - * set the mute operation, volume, and gain. - * - * @since 1.0 - * @version 1.0 - */ -struct AudioVolume { - /** - * @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 - */ - int32_t (*SetMute)(AudioHandle handle, bool 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 - */ - int32_t (*GetMute)(AudioHandle handle, bool *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 - */ - int32_t (*SetVolume)(AudioHandle handle, 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 - */ - int32_t (*GetVolume)(AudioHandle handle, 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 - */ - int32_t (*GetGainThreshold)(AudioHandle handle, float *min, 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 - */ - int32_t (*GetGain)(AudioHandle handle, 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 - */ - int32_t (*SetGain)(AudioHandle handle, float gain); -}; - -#endif /* AUDIO_VOLUME_H */ -/** @} */ diff --git a/services/test_example/BUILD.gn b/services/test_example/BUILD.gn index 6238bddd071b64e06f17cc5a18c39aaa807c51fc..d207d1207b9f43287254cac70212083773df630d 100644 --- a/services/test_example/BUILD.gn +++ b/services/test_example/BUILD.gn @@ -23,6 +23,8 @@ ohos_executable("audio_distributed_test") { include_dirs = [ "./include", + "${driver_audio_path}/include", + "${hdf_service_path}/hdi_service/common/include", "${services_path}/hdfaudioclient/include", ] diff --git a/services/test_example/daudio_errcode.h b/services/test_example/daudio_errcode.h deleted file mode 100644 index b408d5698a2d3f11714dbbd41da4308ff327a447..0000000000000000000000000000000000000000 --- a/services/test_example/daudio_errcode.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_ERRCODE_H -#define OHOS_DAUDIO_ERRCODE_H - -namespace OHOS { -namespace DistributedHardware { -enum DAudioErrorCode { - DH_SUCCESS = 0, - // Distributed Audio HDF Error Code - ERR_DH_AUDIO_HDF_FAIL = -46001, - ERR_DH_AUDIO_HDF_NULLPTR = -46002, - ERR_DH_AUDIO_HDF_INVALID_PARAM = -46003, - ERR_DH_AUDIO_HDF_REPEAT_OPERATION = -46004, - ERR_DH_AUDIO_HDF_INVALID_OPERATION = -46005, - ERR_DH_AUDIO_HDF_SET_PARAM_FAIL = -46006, - ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL = -46007, - ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL = -46008, - ERR_DH_AUDIO_COMMON_NOT_FOUND_KEY = -46009, - ERR_DH_AUDIO_HDF_WAIT_TIMEOUT = -46010, - - ERR_DH_AUDIO_HDF_INIT_ENGINE_FAILED = -46011, - ERR_DH_AUDIO_HDF_NOTIFY_SINK_FAILED = -46012, - ERR_DH_AUDIO_HDF_TRANS_SETUP_FAILED = -46013, - ERR_DH_AUDIO_HDF_TRANS_START_FAILED = -46014, - ERR_DH_AUDIO_HDF_RESULT_FAILED = -46015, -}; -} // Distributedaudio -} // OHOS -#endif