1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @addtogroup HdiAudio 18 * 19 * @brief Provides unified APIs for audio services to access audio drivers. 20 * 21 * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to 22 * access different types of audio devices based on the audio IDs, thereby obtaining audio information, 23 * subscribing to or unsubscribing from audio data, enabling or disabling an audio, 24 * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. 25 * 26 * @since 4.1 27 * @version 3.0 28 */ 29 30package ohos.hdi.audio.v3_0; 31 32/** 33 * @brief Enumerates the audio port type. 34 * 35 * @since 4.1 36 * @version 2.0 37 */ 38enum AudioPortDirection { 39 PORT_OUT = 1, /**< Output port */ 40 PORT_IN = 2, /**< Input port */ 41 PORT_OUT_IN = 3, /**< Input/output port, supporting both audio input and output */ 42}; 43 44/** 45 * @brief Enumerates the pin of an audio adapter. 46 * 47 * @since 4.1 48 * @version 3.0 49 */ 50enum AudioPortPin { 51 PIN_NONE = 0, /**< Invalid pin */ 52 PIN_OUT_SPEAKER = 1 << 0, /**< Speaker output pin */ 53 PIN_OUT_HEADSET = 1 << 1, /**< Wired headset pin for output */ 54 PIN_OUT_LINEOUT = 1 << 2, /**< Line-out pin */ 55 PIN_OUT_HDMI = 1 << 3, /**< HDMI output pin */ 56 PIN_OUT_USB = 1 << 4, /**< USB output pin */ 57 PIN_OUT_USB_EXT = 1 << 5, /**< Extended USB output pin*/ 58 PIN_OUT_EARPIECE = 1 << 5 | 1 << 4, /**< Earpiece output pin */ 59 PIN_OUT_BLUETOOTH_SCO = 1 << 6, /**< Bluetooth SCO output pin */ 60 PIN_OUT_DAUDIO_DEFAULT = 1 << 7, /**< Daudio default output pin */ 61 PIN_OUT_HEADPHONE = 1 << 8, /**< Wired headphone output pin*/ 62 PIN_OUT_USB_HEADSET = 1 << 9, /**< ARM USB out pin */ 63 PIN_OUT_BLUETOOTH_A2DP = 1 << 10, /**< Bluetooth A2DP output pin */ 64 PIN_OUT_DP = 1 << 11, /**< Dp output pin */ 65 PIN_IN_MIC = 1 << 27 | 1 << 0, /**< Microphone input pin */ 66 PIN_IN_HS_MIC = 1 << 27 | 1 << 1, /**< Wired headset microphone pin for input */ 67 PIN_IN_LINEIN = 1 << 27 | 1 << 2, /**< Line-in pin */ 68 PIN_IN_USB_EXT = 1 << 27 | 1 << 3, /**< Extended USB input pin*/ 69 PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, /**< Bluetooth SCO headset input pin */ 70 PIN_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, /**< Daudio default input pin */ 71 PIN_IN_USB_HEADSET = 1 << 27 | 1 << 6, /**< ARM USB input pin */ 72}; 73 74/** 75 * @brief Enumerates the audio category. 76 * 77 * @since 4.1 78 * @version 3.0 79 */ 80enum AudioCategory { 81 AUDIO_IN_MEDIA = 0, /**< Media */ 82 AUDIO_IN_COMMUNICATION = 1, /**< Communications */ 83 AUDIO_IN_RINGTONE = 2, /**< Ringtone */ 84 AUDIO_IN_CALL = 3, /**< Call */ 85 AUDIO_MMAP_NOIRQ = 4, /**< Mmap mode */ 86 AUDIO_OFFLOAD = 5, /**< Offload */ 87 AUDIO_MULTI_CHANNEL = 6, /**< Multi channel */ 88 AUDIO_DP = 7, /**< Audio dp */ 89 AUDIO_MMAP_VOIP = 8, /**< Audio voip */ 90 AUDIO_IN_NAVIGATION = 9, /**< Audio navigation */ 91 AUDIO_DIRECT = 10,/**< Audio direct */ 92}; 93 94/** 95 * @brief Enumerates the audio format. 96 * 97 * @since 4.1 98 * @version 2.0 99 */ 100enum AudioFormat { 101 AUDIO_FORMAT_TYPE_PCM_8_BIT = 1 << 0, /**< 8-bit PCM */ 102 AUDIO_FORMAT_TYPE_PCM_16_BIT = 1 << 1, /**< 16-bit PCM */ 103 AUDIO_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0, /**< 24-bit PCM */ 104 AUDIO_FORMAT_TYPE_PCM_32_BIT = 1 << 2, /**< 32-bit PCM */ 105 AUDIO_FORMAT_TYPE_PCM_FLOAT = 1 << 2 | 1 << 0, /**< FLOAT PCM */ 106 AUDIO_FORMAT_TYPE_MP3 = 1 << 24, /**< MP3 */ 107 AUDIO_FORMAT_TYPE_AAC_MAIN = 1 << 24 | 1 << 0, /**< AAC main */ 108 AUDIO_FORMAT_TYPE_AAC_LC = 1 << 24 | 1 << 1, /**< AAC LC */ 109 AUDIO_FORMAT_TYPE_AAC_LD = 1 << 24 | 1 << 1 | 1 << 0, /**< AAC LD */ 110 AUDIO_FORMAT_TYPE_AAC_ELD = 1 << 24 | 1 << 2, /**< AAC ELD */ 111 AUDIO_FORMAT_TYPE_AAC_HE_V1 = 1 << 24 | 1 << 2 | 1 << 0, /**< AAC HE_V1 */ 112 AUDIO_FORMAT_TYPE_AAC_HE_V2 = 1 << 24 | 1 << 2 | 1 << 1, /**< AAC HE_V2 */ 113 AUDIO_FORMAT_TYPE_G711A = 1 << 25 | 1 << 0, /**< G711A */ 114 AUDIO_FORMAT_TYPE_G711U = 1 << 25 | 1 << 1, /**< G711u */ 115 AUDIO_FORMAT_TYPE_G726 = 1 << 25 | 1 << 1 | 1 << 0, /**< G726 */ 116}; 117 118/** 119 * @brief Enumerates the audio channel mask. 120 * 121 * A mask describes an audio channel position. 122 * 123 * @since 4.1 124 * @version 2.0 125 */ 126enum AudioChannelMask { 127 AUDIO_CHANNEL_FRONT_LEFT = 1, /**< Front left channel */ 128 AUDIO_CHANNEL_FRONT_RIGHT = 2, /**< Front right channel */ 129 AUDIO_CHANNEL_MONO = 1, /**< Mono channel */ 130 AUDIO_CHANNEL_STEREO = 3, /**< Stereo channel, consisting of front left and front right channels */ 131}; 132 133/** 134 * @brief Enumerates masks of audio sampling rates. 135 * 136 * @since 4.1 137 * @version 2.0 138 */ 139enum AudioSampleRatesMask { 140 AUDIO_SAMPLE_RATE_MASK_8000 = 1 << 0, /**< 8 kHz */ 141 AUDIO_SAMPLE_RATE_MASK_12000 = 1 << 1, /**< 12 kHz */ 142 AUDIO_SAMPLE_RATE_MASK_11025 = 1 << 2, /**< 11.025 kHz */ 143 AUDIO_SAMPLE_RATE_MASK_16000 = 1 << 3, /**< 16 kHz */ 144 AUDIO_SAMPLE_RATE_MASK_22050 = 1 << 4, /**< 22.050 kHz */ 145 AUDIO_SAMPLE_RATE_MASK_24000 = 1 << 5, /**< 24 kHz */ 146 AUDIO_SAMPLE_RATE_MASK_32000 = 1 << 6, /**< 32 kHz */ 147 AUDIO_SAMPLE_RATE_MASK_44100 = 1 << 7, /**< 44.1 kHz */ 148 AUDIO_SAMPLE_RATE_MASK_48000 = 1 << 8, /**< 48 kHz */ 149 AUDIO_SAMPLE_RATE_MASK_64000 = 1 << 9, /**< 64 kHz */ 150 AUDIO_SAMPLE_RATE_MASK_96000 = 1 << 10, /**< 96 kHz */ 151 AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295, /**< Invalid sampling rate */ 152}; 153 154/** 155 * @brief Enumerates the passthrough data transmission mode of an audio port. 156 * 157 * @since 4.1 158 * @version 2.0 159 */ 160enum AudioPortPassthroughMode { 161 PORT_PASSTHROUGH_LPCM = 1 << 0, /**< Stereo PCM */ 162 PORT_PASSTHROUGH_RAW = 1 << 1, /**< HDMI passthrough */ 163 PORT_PASSTHROUGH_HBR2LBR = 1 << 2, /**< Blu-ray next-generation audio output with reduced specifications */ 164 PORT_PASSTHROUGH_AUTO = 1 << 3, /**< Mode automatically matched based on the HDMI EDID */ 165}; 166 167/** 168 * @brief Defines formats of raw audio samples. 169 * 170 * @since 4.1 171 * @version 2.0 172 */ 173enum AudioSampleFormat { 174 /* 8 bits */ 175 AUDIO_SAMPLE_FORMAT_S8 = 0, /**< signed 8 bit sample */ 176 AUDIO_SAMPLE_FORMAT_S8P = 1, /**< signed 8 bit planar sample */ 177 AUDIO_SAMPLE_FORMAT_U8 = 2, /**< unsigned 8 bit sample */ 178 AUDIO_SAMPLE_FORMAT_U8P = 3, /**< unsigned 8 bit planar sample */ 179 /* 16 bits */ 180 AUDIO_SAMPLE_FORMAT_S16 = 4, /**< signed 16 bit sample */ 181 AUDIO_SAMPLE_FORMAT_S16P = 5, /**< signed 16 bit planar sample */ 182 AUDIO_SAMPLE_FORMAT_U16 = 6, /**< unsigned 16 bit sample */ 183 AUDIO_SAMPLE_FORMAT_U16P = 7, /**< unsigned 16 bit planar sample */ 184 /* 24 bits */ 185 AUDIO_SAMPLE_FORMAT_S24 = 8, /**< signed 24 bit sample */ 186 AUDIO_SAMPLE_FORMAT_S24P = 9, /**< signed 24 bit planar sample */ 187 AUDIO_SAMPLE_FORMAT_U24 = 10, /**< unsigned 24 bit sample */ 188 AUDIO_SAMPLE_FORMAT_U24P = 11, /**< unsigned 24 bit planar sample */ 189 /* 32 bits */ 190 AUDIO_SAMPLE_FORMAT_S32 = 12, /**< signed 32 bit sample */ 191 AUDIO_SAMPLE_FORMAT_S32P = 13, /**< signed 32 bit planar sample */ 192 AUDIO_SAMPLE_FORMAT_U32 = 14, /**< unsigned 32 bit sample */ 193 AUDIO_SAMPLE_FORMAT_U32P = 15, /**< unsigned 32 bit planar sample */ 194 /* 64 bits */ 195 AUDIO_SAMPLE_FORMAT_S64 = 16, /**< signed 64 bit sample */ 196 AUDIO_SAMPLE_FORMAT_S64P = 17, /**< signed 64 bit planar sample */ 197 AUDIO_SAMPLE_FORMAT_U64 = 18, /**< unsigned 64 bit sample */ 198 AUDIO_SAMPLE_FORMAT_U64P = 19, /**< unsigned 64 bit planar sample */ 199 /* float double */ 200 AUDIO_SAMPLE_FORMAT_F32 = 20, /**< float 32 bit sample */ 201 AUDIO_SAMPLE_FORMAT_F32P = 21, /**< float 32 bit planar sample */ 202 AUDIO_SAMPLE_FORMAT_F64 = 22, /**< double 64 bit sample */ 203 AUDIO_SAMPLE_FORMAT_F64P = 23, /**< double 64 bit planar sample */ 204}; 205 206/** 207 * @brief Enumerates channel modes for audio rendering. 208 * 209 * @attention The following modes are set for rendering dual-channel audios. Others are not supported. 210 * 211 * @since 4.1 212 * @version 2.0 213 */ 214enum AudioChannelMode { 215 AUDIO_CHANNEL_NORMAL = 0, /**< Normal mode. No processing is required. */ 216 AUDIO_CHANNEL_BOTH_LEFT = 1, /**< Two left channels */ 217 AUDIO_CHANNEL_BOTH_RIGHT = 2, /**< Two right channels */ 218 AUDIO_CHANNEL_EXCHANGE = 3, /**< Data exchange between the left and right channels. The left channel takes the audio 219 * stream of the right channel, and the right channel takes that of the left channel. 220 */ 221 AUDIO_CHANNEL_MIX = 4, /**< Mix of streams of the left and right channels */ 222 AUDIO_CHANNEL_LEFT_MUTE = 5, /**< Left channel muted. The stream of the right channel is output. */ 223 AUDIO_CHANNEL_RIGHT_MUTE = 6, /**< Right channel muted. The stream of the left channel is output. */ 224 AUDIO_CHANNEL_BOTH_MUTE = 7, /**< Both left and right channels are muted */ 225}; 226 227/** 228 * @brief Enumerates the execution types of the <b>DrainBuffer</b> function. 229 * 230 * @since 4.1 231 * @version 2.0 232 */ 233enum AudioDrainNotifyType { 234 AUDIO_DRAIN_NORMAL_MODE = 0, /**< The <b>DrainBuffer</b> function returns after all data finishes playback. */ 235 AUDIO_DRAIN_EARLY_MODE = 1, /**< The <b>DrainBuffer</b> function returns before all the data of the current track 236 * finishes playback to reserve time for a smooth track switch by the audio service. 237 */ 238 239}; 240 241/** 242 * @brief Enumerates callback notification events. 243 * 244 * @since 4.1 245 * @version 2.0 246 */ 247enum AudioCallbackType { 248 AUDIO_NONBLOCK_WRITE_COMPLETED = 0, /**< The non-block write is complete. */ 249 AUDIO_DRAIN_COMPLETED = 1, /**< The draining is complete. */ 250 AUDIO_FLUSH_COMPLETED = 2, /**< The flush is complete. */ 251 AUDIO_RENDER_FULL = 3, /**< The render buffer is full.*/ 252 AUDIO_ERROR_OCCUR = 4, /**< An error occurs.*/ 253}; 254 255/** 256 * @brief Describes AudioPortRole. 257 * 258 * @since 4.1 259 * @version 2.0 260 */ 261enum AudioPortRole { 262 AUDIO_PORT_UNASSIGNED_ROLE = 0, /**< Unassigned port role */ 263 AUDIO_PORT_SOURCE_ROLE = 1, /**< Assigned source role */ 264 AUDIO_PORT_SINK_ROLE = 2, /**< Assigned sink role */ 265}; 266 267/** 268 * @brief Describes AudioPortType. 269 * 270 * @since 4.1 271 * @version 2.0 272 */ 273enum AudioPortType { 274 AUDIO_PORT_UNASSIGNED_TYPE = 0, /**< Unassigned port type */ 275 AUDIO_PORT_DEVICE_TYPE = 1, /**< Assigned device type */ 276 AUDIO_PORT_MIX_TYPE = 2, /**< Assigned mix type */ 277 AUDIO_PORT_SESSION_TYPE = 3, /**< Assigned session type */ 278}; 279 280/** 281 * @brief Describes AudioSessionType. 282 * 283 * @since 4.1 284 * @version 2.0 285 */ 286enum AudioSessionType { 287 AUDIO_OUTPUT_STAGE_SESSION = 0, /**< Assigned output stage session */ 288 AUDIO_OUTPUT_MIX_SESSION = 1, /**< Assigned output mix session */ 289 AUDIO_ALLOCATE_SESSION = 2, /**< Assigned allocate session */ 290 AUDIO_INVALID_SESSION = 3, /**< Assigned invalid session */ 291}; 292 293/** 294 * @brief Describes AudioDeviceType. 295 * 296 * @since 4.1 297 * @version 3.0 298 */ 299enum AudioDeviceType { 300 AUDIO_LINEOUT = 1 << 0, /**< Assigned lineout device type */ 301 AUDIO_HEADPHONE = 1 << 1, /**< Assigned headphone device type */ 302 AUDIO_HEADSET = 1 << 2, /**< Assigned headset device type */ 303 AUDIO_USB_HEADSET = 1 << 3, /**< Assigned usb headset device type */ 304 AUDIO_USB_HEADPHONE = 1 << 4, /**< Assigned usb headphone device type */ 305 AUDIO_USBA_HEADSET = 1 << 5, /**< Assigned usba headset device type */ 306 AUDIO_USBA_HEADPHONE = 1 << 6, /**< Assigned usba headphone device type */ 307 AUDIO_PRIMARY_DEVICE = 1 << 7, /**< Assigned primary device type */ 308 AUDIO_USB_DEVICE = 1 << 8, /**< Assigned usb device type */ 309 AUDIO_A2DP_DEVICE = 1 << 9, /**< Assigned a2dp device type */ 310 AUDIO_HDMI_DEVICE = 1 << 10, /**< Assigned hdmi device type */ 311 AUDIO_ADAPTER_DEVICE = 1 << 11, /**< Assigned adapter device type */ 312 AUDIO_DP_DEVICE = 1 << 12, /**< Assigned dp device type */ 313 AUDIO_DEVICE_UNKNOWN, /**< Assigned unknown device type */ 314}; 315 316/** 317 * @brief Describes AudioEventType. 318 * 319 * @since 4.1 320 * @version 2.0 321 */ 322enum AudioEventType { 323 AUDIO_DEVICE_ADD = 1, /**< Assigned add device event type */ 324 AUDIO_DEVICE_REMOVE = 2, /**< Assigned remove device event type */ 325 AUDIO_LOAD_SUCCESS = 3, /**< Assigned load sucess event type */ 326 AUDIO_LOAD_FAILURE = 4, /**< Assigned load failure event type */ 327 AUDIO_UNLOAD = 5, /**< Assigned unload event type */ 328 AUDIO_SERVICE_VALID = 7, /**< Assigned valid service event type */ 329 AUDIO_SERVICE_INVALID = 8, /**< Assigned invalid service event type */ 330 AUDIO_CAPTURE_THRESHOLD = 9, /**< Assigned threshold capture event type */ 331 AUDIO_EVENT_UNKNOWN = 10, /**< Assigned unknown event type */ 332}; 333 334/** 335 * @brief Enumerates the restricted key type of the parameters 336 * 337 * @since 4.1 338 * @version 2.0 339 */ 340enum AudioExtParamKey { 341 AUDIO_EXT_PARAM_KEY_NONE = 0, /**< Distributed audio extra param key none */ 342 AUDIO_EXT_PARAM_KEY_VOLUME = 1, /**< Distributed audio extra param key volume event */ 343 AUDIO_EXT_PARAM_KEY_FOCUS = 2, /**< Distributed audio extra param key focus event */ 344 AUDIO_EXT_PARAM_KEY_BUTTON = 3, /**< Distributed audio extra param key media button event */ 345 AUDIO_EXT_PARAM_KEY_EFFECT = 4, /**< Distributed audio extra param key audio effect event */ 346 AUDIO_EXT_PARAM_KEY_STATUS = 5, /**< Distributed audio extra param key device status event */ 347 AUDIO_EXT_PARAM_KEY_USB_DEVICE = 101, /**< Check USB device type ARM or HIFI */ 348 AUDIO_EXT_PARAM_KEY_PERF_INFO = 201, /**< Distributed audio extra param key dsp load event */ 349 AUDIO_EXT_PARAM_KEY_MMI = 301, /**< Distributed audio extra param key Man-Machine interface Test */ 350 AUDIO_EXT_PARAM_KEY_LOWPOWER = 1000, /**< Low power event type */ 351}; 352 353/** 354 * @brief Describes status of audio deivce.@link enum AudioDeviceType 355 * 356 * @since 4.1 357 * @version 2.0 358 */ 359struct AudioDeviceStatus { 360 unsigned int pnpStatus; /**< Audio pnp status */ 361}; 362 363/** 364 * @brief Describes the audio scene. 365 * 366 * @since 4.1 367 * @version 2.0 368 */ 369union SceneDesc { 370 unsigned int id; /**< Audio scene ID */ 371}; 372 373/** 374 * @brief Defines the audio port. 375 * 376 * @since 4.1 377 * @version 2.0 378 */ 379struct AudioPort { 380 enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */ 381 unsigned int portId; /**< Audio port ID */ 382 String portName; /**< Audio port name */ 383}; 384 385/** 386 * @brief Defines the audio adapter descriptor. 387 * 388 * An audio adapter is a set of port drivers for a sound card, including the output and input ports. 389 * One port corresponds to multiple pins, and each pin belongs to a physical component (such as a 390 * speaker or a wired headset). 391 * 392 * @since 4.1 393 * @version 2.0 394 */ 395struct AudioAdapterDescriptor { 396 String adapterName; /**< Name of the audio adapter */ 397 struct AudioPort[] ports; /**< List of ports supported by an audio adapter */ 398}; 399 400/** 401 * @brief Defines the audio device descriptor. 402 * 403 * @since 4.1 404 * @version 2.0 405 */ 406struct AudioDeviceDescriptor { 407 unsigned int portId; /**< Audio port ID */ 408 enum AudioPortPin pins; /**< Pins of audio ports (input and output). For details, see {@link AudioPortPin}. */ 409 String desc; /**< Audio device name */ 410}; 411 412/** 413 * @brief Defines the audio scene descriptor. 414 * 415 * @since 4.1 416 * @version 2.0 417 */ 418struct AudioSceneDescriptor { 419 union SceneDesc scene; /**< Describes the audio scene */ 420 struct AudioDeviceDescriptor desc; /**< Audio device descriptor */ 421}; 422 423/** 424 * @brief Defines audio input type. 425 * 426 * @since 4.1 427 * @version 2.0 428 */ 429enum AudioInputType { 430 AUDIO_INPUT_DEFAULT_TYPE = 0, /**< Assigned default input type */ 431 AUDIO_INPUT_MIC_TYPE = 1 << 0, /**< Assigned mic input type */ 432 AUDIO_INPUT_SPEECH_WAKEUP_TYPE = 1 << 1, /**< Assigned speech wakeup input type */ 433 AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, /**< Assigned voice communication input type */ 434 AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, /**< Assigned voice recognition input type */ 435 AUDIO_INPUT_VOICE_UPLINK_TYPE = 1 << 4, /**< Assigned voice uplink input type */ 436 AUDIO_INPUT_VOICE_DOWNLINK_TYPE = 1 << 5, /**< Assigned voice downlink input type */ 437 AUDIO_INPUT_VOICE_CALL_TYPE = 1 << 6, /**< Assigned voice call input type */ 438 AUDIO_INPUT_CAMCORDER_TYPE = 1 << 7, /**< Assigned camcorder input type */ 439}; 440 441/** 442 * @brief Defines audio offload attributes. 443 * 444 * @since 4.1 445 * @version 2.0 446 */ 447struct AudioOffloadInfo 448{ 449 unsigned int sampleRate; /**< Audio sampling rate */ 450 unsigned int channelCount; /**< Number of audio channels */ 451 unsigned long channelLayout; /**< Audio channel layout */ 452 unsigned int bitRate; /**< bitRate of compressed audio data */ 453 unsigned int bitWidth; /**< bitwidth of audio data */ 454 enum AudioFormat format; /**< Audio data format. */ 455 unsigned int offloadBufferSize; /**< buffersize for offload audio data */ 456 unsigned long duration; /** audio duration, unit is nanosecond*/ 457}; 458 459/** 460 * @brief Defines audio sampling attributes. 461 * 462 * @since 4.1 463 * @version 2.0 464 */ 465struct AudioSampleAttributes { 466 enum AudioCategory type; /**< Audio type. For details, see {@link AudioCategory} */ 467 boolean interleaved; /**< Interleaving flag of audio data */ 468 enum AudioFormat format; /**< Audio data format. For details, see {@link AudioFormat}. */ 469 unsigned int sampleRate; /**< Audio sampling rate */ 470 unsigned int channelCount; /**< Number of audio channels. For example, for the mono channel, the value is 1, 471 * and for the stereo channel, the value is 2. 472 */ 473 unsigned long channelLayout; /**< Audio channel layout */ 474 unsigned int period; /**< Audio sampling period */ 475 unsigned int frameSize; /**< Frame size of the audio data */ 476 boolean isBigEndian; /**< Big endian flag of audio data */ 477 boolean isSignedData; /**< Signed or unsigned flag of audio data */ 478 unsigned int startThreshold; /**< Audio render start threshold. */ 479 unsigned int stopThreshold; /**< Audio render stop threshold. */ 480 unsigned int silenceThreshold; /**< Audio capture buffer threshold. */ 481 int streamId; /**< Audio Identifier of render or capture */ 482 int sourceType; /**< Audio sourceType of render or capture */ 483 struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ 484}; 485 486/** 487 * @brief Defines the audio timestamp, which is a substitute for POSIX <b>timespec</b>. 488 * 489 * @since 4.1 490 * @version 2.0 491 */ 492struct AudioTimeStamp { 493 long tvSec; /**< Seconds */ 494 long tvNSec; /**< Nanoseconds */ 495}; 496 497/** 498 * @brief Defines the sub-port capability. 499 * 500 * @since 4.1 501 * @version 2.0 502 */ 503struct AudioSubPortCapability { 504 unsigned int portId; /**< Sub-port ID */ 505 String desc; /**< Sub-port name */ 506 enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details, 507 * see {@link AudioPortPassthroughMode}. 508 */ 509}; 510 511/** 512 * @brief Defines the audio port capability. 513 * 514 * @since 4.1 515 * @version 2.0 516 */ 517struct AudioPortCapability { 518 unsigned int deviceType; /**< Device type (output or input) */ 519 unsigned int deviceId; /**< Device ID used for device binding */ 520 boolean hardwareMode; /**< Whether to support device binding */ 521 unsigned int formatNum; /**< Number of the supported audio formats */ 522 enum AudioFormat[] formats; /**< Supported audio formats. For details, see {@link AudioFormat}. */ 523 unsigned int sampleRateMasks; /**< Supported audio sampling rates (8 kHz, 16 kHz, 32 kHz, and 48 kHz) */ 524 enum AudioChannelMask channelMasks; /**< Audio channel layout mask of the device. For details, 525 * see {@link AudioChannelMask}. 526 */ 527 unsigned int channelCount; /**< Supported maximum number of audio channels */ 528 struct AudioSubPortCapability[] subPorts; /**< List of supported sub-ports */ 529 enum AudioSampleFormat[] supportSampleFormats; /**< Supported audio sample formats. For details, 530 * see {@link AudioSampleFormat}. 531 */ 532}; 533 534/** 535 * @brief Describes a mmap buffer. 536 * 537 * @since 4.1 538 * @version 2.0 539 */ 540struct AudioMmapBufferDescriptor { 541 byte[] memoryAddress; /**< Pointer to the mmap buffer */ 542 FileDescriptor memoryFd; /**< File descriptor of the mmap buffer */ 543 int totalBufferFrames; /**< Total size of the mmap buffer (unit: frame )*/ 544 int transferFrameSize; /**< Transfer size (unit: frame) */ 545 int isShareable; /**< Whether the mmap buffer can be shared among processes */ 546 unsigned int offset; /**< off set */ 547 String filePath; /**< file path */ 548}; 549 550/** 551 * @brief Describes AudioDevExtInfo. 552 * 553 * @since 4.1 554 * @version 2.0 555 */ 556struct AudioDevExtInfo { 557 int moduleId; /**< Identifier of the module stream is attached to */ 558 enum AudioPortPin type; /**< Device type For details, see {@link AudioPortPin}. */ 559 String desc; /**< Address */ 560}; 561 562/** 563 * @brief Describes AudioMixInfo. 564 * 565 * @since 4.1 566 * @version 2.0 567 */ 568struct AudioMixExtInfo { 569 int moduleId; /**< Identifier of the module stream is attached to */ 570 int streamId; /**< Identifier of the capture or render passed by caller */ 571}; 572 573/** 574 * @brief Describes AudioSessionExtInfo. 575 * 576 * @since 4.1 577 * @version 2.0 578 */ 579struct AudioSessionExtInfo { 580 enum AudioSessionType sessionType; /**< Audio session type */ 581}; 582 583/** 584 * @brief Describes AudioInfo. 585 * 586 * @since 4.1 587 * @version 2.0 588 */ 589struct AudioInfo { 590 struct AudioDevExtInfo device; /* Specific Device Ext info */ 591 struct AudioMixExtInfo mix; /* Specific mix info */ 592 struct AudioSessionExtInfo session; /* session specific info */ 593}; 594 595/** 596 * @brief Describes AudioRouteNode. 597 * 598 * @since 4.1 599 * @version 2.0 600 */ 601struct AudioRouteNode { 602 int portId; /**< Audio port ID */ 603 enum AudioPortRole role; /**< Audio port as a sink or a source */ 604 enum AudioPortType type; /**< device, mix ... */ 605 struct AudioInfo ext; /**< The <b>ext</b> object */ 606}; 607 608/** 609 * @brief Describes AudioRoute. 610 * 611 * @since 4.1 612 * @version 2.0 613 */ 614struct AudioRoute { 615 struct AudioRouteNode[] sources; /**< List of sources */ 616 struct AudioRouteNode[] sinks; /**< List of sinks */ 617}; 618 619/** 620 * @brief Describes AudioEvent. 621 * 622 * @since 4.1 623 * @version 2.0 624 */ 625struct AudioEvent { 626 unsigned int eventType; /**< @link enum AudioEventType */ 627 unsigned int deviceType; /**< @link enum AudioDeviceType */ 628}; 629