From f997c93f413e0594d911dc103897f1f7895180f1 Mon Sep 17 00:00:00 2001 From: xuxuehai Date: Mon, 19 May 2025 19:37:46 +0800 Subject: [PATCH 1/9] =?UTF-8?q?audio=E6=8E=A5=E5=8F=A3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A75.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuxuehai --- audio/v5_0/AudioTypes.idl | 688 ++++++++++++++++++++++++++++++++++ audio/v5_0/BUILD.gn | 40 ++ audio/v5_0/IAudioAdapter.idl | 310 +++++++++++++++ audio/v5_0/IAudioCallback.idl | 75 ++++ audio/v5_0/IAudioCapture.idl | 486 ++++++++++++++++++++++++ audio/v5_0/IAudioManager.idl | 97 +++++ audio/v5_0/IAudioRender.idl | 593 +++++++++++++++++++++++++++++ 7 files changed, 2289 insertions(+) create mode 100644 audio/v5_0/AudioTypes.idl create mode 100644 audio/v5_0/BUILD.gn create mode 100644 audio/v5_0/IAudioAdapter.idl create mode 100644 audio/v5_0/IAudioCallback.idl create mode 100644 audio/v5_0/IAudioCapture.idl create mode 100644 audio/v5_0/IAudioManager.idl create mode 100644 audio/v5_0/IAudioRender.idl diff --git a/audio/v5_0/AudioTypes.idl b/audio/v5_0/AudioTypes.idl new file mode 100644 index 00000000..93d81644 --- /dev/null +++ b/audio/v5_0/AudioTypes.idl @@ -0,0 +1,688 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_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.1 + */ +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_OUT_NEARLINK_SCO = 1 << 12, /**< Nearlink SCO output pin */ + PIN_OUT_NEARLINK = 1 << 13, /**< Nearlink 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 */ + PIN_IN_PENCIL = 1 << 27 | 1 << 7, /**< Pencil input pin */ + PIN_IN_UWB = 1 << 27 | 1 << 8, /**< UWB input pin */ + PIN_IN_NEARLINK = 1 << 27 | 1 << 9, /**< Nearlink 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.1 + */ +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_EAC3 = 1 << 24 | 1 << 2 | 1 << 1 | 1 << 0, /**< EAC3 */ + 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.1 + */ +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_ACCESSORY_DEVICE = 1 << 13, /**< Assigned accessory device type */ + AUDIO_REMOTE_DEVICE = 1 << 14, /**< Assigned remote 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.1 + */ +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 */ + AUDIO_INPUT_RAW_TYPE = 1 << 10, /**< Assigned raw input type */ + AUDIO_INPUT_LIVE_TYPE = 1 << 11, /**< Assigned live 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 3.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 */ + unsigned int syncInfoSize; /**< Synchronize information size (unit: uint32_t size, 0 means not support) */ +}; + +/** + * @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/v5_0/BUILD.gn b/audio/v5_0/BUILD.gn new file mode 100644 index 00000000..2bd39569 --- /dev/null +++ b/audio/v5_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_5.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/v5_0/IAudioAdapter.idl b/audio/v5_0/IAudioAdapter.idl new file mode 100644 index 00000000..7c7d2486 --- /dev/null +++ b/audio/v5_0/IAudioAdapter.idl @@ -0,0 +1,310 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_0; + +import ohos.hdi.audio.v5_0.AudioTypes; +import ohos.hdi.audio.v5_0.IAudioRender; +import ohos.hdi.audio.v5_0.IAudioCapture; +import ohos.hdi.audio.v5_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/v5_0/IAudioCallback.idl b/audio/v5_0/IAudioCallback.idl new file mode 100644 index 00000000..b8a9f683 --- /dev/null +++ b/audio/v5_0/IAudioCallback.idl @@ -0,0 +1,75 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_0; + +import ohos.hdi.audio.v5_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/v5_0/IAudioCapture.idl b/audio/v5_0/IAudioCapture.idl new file mode 100644 index 00000000..6df57de7 --- /dev/null +++ b/audio/v5_0/IAudioCapture.idl @@ -0,0 +1,486 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_0; + +import ohos.hdi.audio.v5_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. + * + * + * @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: + * + * @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/v5_0/IAudioManager.idl b/audio/v5_0/IAudioManager.idl new file mode 100644 index 00000000..ccb12222 --- /dev/null +++ b/audio/v5_0/IAudioManager.idl @@ -0,0 +1,97 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_0; + +import ohos.hdi.audio.v5_0.AudioTypes; +import ohos.hdi.audio.v5_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/v5_0/IAudioRender.idl b/audio/v5_0/IAudioRender.idl new file mode 100644 index 00000000..970898b3 --- /dev/null +++ b/audio/v5_0/IAudioRender.idl @@ -0,0 +1,593 @@ +/* + * 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 5.0 + */ + +package ohos.hdi.audio.v5_0; + +import ohos.hdi.audio.v5_0.AudioTypes; +import ohos.hdi.audio.v5_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. + * + * + * @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: + * + * @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 From a07e0e780f97f87ecf41d3917cff6d71a4c48b49 Mon Sep 17 00:00:00 2001 From: xuxuehai Date: Mon, 19 May 2025 20:49:10 +0800 Subject: [PATCH 2/9] =?UTF-8?q?audio=E6=8E=A5=E5=8F=A3=E5=8D=87=E7=BA=A75.?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuxuehai --- audio/bundle.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/bundle.json b/audio/bundle.json index 6dd6f4e7..dc3b5883 100644 --- a/audio/bundle.json +++ b/audio/bundle.json @@ -29,7 +29,7 @@ "build": { "sub_component": [ "//drivers/interface/audio/effect/v1_0:libeffect_proxy_1.0", - "//drivers/interface/audio/v4_0:libaudio_proxy_4.0" + "//drivers/interface/audio/v5_0:libaudio_proxy_5.0" ], "test": [ ], @@ -59,7 +59,7 @@ } }, { - "name": "//drivers/interface/audio/v4_0:libaudio_proxy_4.0", + "name": "//drivers/interface/audio/v5_0:libaudio_proxy_5.0", "header": { "header_files": [ ], @@ -67,7 +67,7 @@ } }, { - "name": "//drivers/interface/audio/v4_0:audio_idl_headers", + "name": "//drivers/interface/audio/v5_0:audio_idl_headers", "header": { "header_files": [ ], @@ -75,7 +75,7 @@ } }, { - "name": "//drivers/interface/audio/v4_0:libaudio_stub_4.0", + "name": "//drivers/interface/audio/v5_0:libaudio_stub_5.0", "header": { "header_files": [ ], -- Gitee From b17fa41af0af1202dced78df0db4f9f168cd7b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:50:00 +0000 Subject: [PATCH 3/9] update audio/v5_0/AudioTypes.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/AudioTypes.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/AudioTypes.idl b/audio/v5_0/AudioTypes.idl index 93d81644..f0caba0c 100644 --- a/audio/v5_0/AudioTypes.idl +++ b/audio/v5_0/AudioTypes.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 6ffe49c2c8e69aa14ea9b09dd7ddf1710d9a3187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:50:15 +0000 Subject: [PATCH 4/9] update audio/v5_0/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/BUILD.gn b/audio/v5_0/BUILD.gn index 2bd39569..b9c55e97 100644 --- a/audio/v5_0/BUILD.gn +++ b/audio/v5_0/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2025 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 -- Gitee From 6a7c90225041c73d07e00432225d8f4c306b7cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:50:29 +0000 Subject: [PATCH 5/9] update audio/v5_0/IAudioAdapter.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/IAudioAdapter.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/IAudioAdapter.idl b/audio/v5_0/IAudioAdapter.idl index 7c7d2486..eb172e91 100644 --- a/audio/v5_0/IAudioAdapter.idl +++ b/audio/v5_0/IAudioAdapter.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 5c422adb08a6069269cb848dbeae664986308ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:50:44 +0000 Subject: [PATCH 6/9] update audio/v5_0/IAudioCallback.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/IAudioCallback.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/IAudioCallback.idl b/audio/v5_0/IAudioCallback.idl index b8a9f683..cee94872 100644 --- a/audio/v5_0/IAudioCallback.idl +++ b/audio/v5_0/IAudioCallback.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 8495117ce69d457741610fb9391880fd70c5b7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:51:00 +0000 Subject: [PATCH 7/9] update audio/v5_0/IAudioCapture.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/IAudioCapture.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/IAudioCapture.idl b/audio/v5_0/IAudioCapture.idl index 6df57de7..b3f0ac41 100644 --- a/audio/v5_0/IAudioCapture.idl +++ b/audio/v5_0/IAudioCapture.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 7bb5e97c3e18b220285064780aa16b68ae3aa2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:51:15 +0000 Subject: [PATCH 8/9] update audio/v5_0/IAudioManager.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/IAudioManager.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/IAudioManager.idl b/audio/v5_0/IAudioManager.idl index ccb12222..1539e384 100644 --- a/audio/v5_0/IAudioManager.idl +++ b/audio/v5_0/IAudioManager.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 881e86bd4eb6aae831b071eba7ba7c1a90da11c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AD=A6=E6=B5=B7?= Date: Tue, 20 May 2025 06:51:35 +0000 Subject: [PATCH 9/9] update audio/v5_0/IAudioRender.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许学海 --- audio/v5_0/IAudioRender.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/v5_0/IAudioRender.idl b/audio/v5_0/IAudioRender.idl index 970898b3..5334c465 100644 --- a/audio/v5_0/IAudioRender.idl +++ b/audio/v5_0/IAudioRender.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee