1# OHAudio 2 3 4## Overview 5 6The **OHAudio** module provides C APIs of the audio module. 7 8**System capability**: SystemCapability.Multimedia.Audio.Core 9 10**Since**: 10 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [native_audio_common.h](native__audio__common_8h.md) | Declares the common basic audio data structs. | 21| [native_audio_device_base.h](native__audio__device__base_8h.md) | Declares the types of audio device parameters and the functions for obtaining these parameters. | 22| [native_audio_manager.h](native__audio__manager_8h.md) | Declares the functions related to an audio manager. | 23| [native_audio_routing_manager.h](native__audio__routing__manager_8h.md) | Declares the functions related to an audio routing manager. | 24| [native_audio_session_manager.h](native__audio__session__manager_8h.md) | Declares the functions related to an audio session manager. | 25| [native_audiocapturer.h](native__audiocapturer_8h.md) | Declares the functions related to an audio capturer. | 26| [native_audiorenderer.h](native__audiorenderer_8h.md) | Declares the functions related to an audio renderer. | 27| [native_audiostream_base.h](native__audiostream__base_8h.md) | Declares the basic data structure of **OHAudio**. | 28| [native_audiostreambuilder.h](native__audiostreambuilder_8h.md) | Declares the functions related to an audio stream builder. | 29 30 31### Structs 32 33| Name| Description| 34| -------- | -------- | 35| struct [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) | Describes an array of audio device descriptors. | 36| struct [OH_AudioSession_Strategy](_o_h___audio_session___strategy.md) | Describes the audio session strategy. | 37| struct [OH_AudioSession_DeactivatedEvent](_o_h___audio_session___deactivated_event.md) | Describes the event indicating that an audio session is deactivated. | 38| struct [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) | Describes a pointer to the callback functions related to an audio renderer. | 39| struct [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) | Describes a pointer to the callback functions related to an audio capturer. | 40 41 42### Types 43 44| Name| Description| 45| -------- | -------- | 46| typedef struct [OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) [OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) | Defines a struct for an audio device descriptor. It provides detailed attributes of an audio device. | 47| typedef struct [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) [OH_AudioDeviceDescriptorArray](#oh_audiodevicedescriptorarray) | Defines a struct for an array of audio device descriptors. | 48| typedef struct [OH_AudioManager](#oh_audiomanager) [OH_AudioManager](#oh_audiomanager) | Defines a struct for an audio manager. | 49| typedef struct [OH_AudioRoutingManager](#oh_audioroutingmanager) [OH_AudioRoutingManager](#oh_audioroutingmanager) | Defines a struct for an audio routing manager, which is used for routing and device-related functions. | 50| typedef int32_t(\* [OH_AudioRoutingManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback))([OH_AudioDevice_ChangeType](#oh_audiodevice_changetype) type, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*audioDeviceDescriptorArray) | Defines a pointer to the callback function that returns the changed audio device descriptor (possibly multiple descriptors). | 51| typedef struct [OH_AudioSessionManager](#oh_audiosessionmanager) [OH_AudioSessionManager](#oh_audiosessionmanager) | Defines a struct for an audio session manager. | 52| typedef struct [OH_AudioSession_Strategy](_o_h___audio_session___strategy.md) [OH_AudioSession_Strategy](#oh_audiosession_strategy) | Defines a struct for an audio session strategy. | 53| typedef struct [OH_AudioSession_DeactivatedEvent](_o_h___audio_session___deactivated_event.md) [OH_AudioSession_DeactivatedEvent](#oh_audiosession_deactivatedevent) | Defines a struct for the event indicating that an audio session is deactivated. | 54| typedef int32_t(\* [OH_AudioSession_DeactivatedCallback](#oh_audiosession_deactivatedcallback))([OH_AudioSession_DeactivatedEvent](_o_h___audio_session___deactivated_event.md) event) | Defines a function pointer to the callback function used to listen for audio session deactivation events. | 55| typedef struct OH_AudioStreamBuilderStruct [OH_AudioStreamBuilder](#oh_audiostreambuilder) | Defines a struct for an audio stream builder. | 56| typedef struct OH_AudioRendererStruct [OH_AudioRenderer](#oh_audiorenderer) | Defines a struct for an audio renderer. | 57| typedef struct OH_AudioCapturerStruct [OH_AudioCapturer](#oh_audiocapturer) | Defines a struct for an audio capturer. | 58| typedef struct [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) | Defines a pointer to the callback functions related to an audio renderer. | 59| typedef struct [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) | Defines a pointer to the callback functions related to an audio capturer. | 60| typedef void(\* [OH_AudioRenderer_OutputDeviceChangeCallback](#oh_audiorenderer_outputdevicechangecallback))([OH_AudioRenderer](#oh_audiorenderer) \*renderer, void \*userData, [OH_AudioStream_DeviceChangeReason](#oh_audiostream_devicechangereason) reason) | Defines a pointer to the callback invoked when the audio stream device changes. | 61| typedef void(\* [OH_AudioRenderer_OnMarkReachedCallback](#oh_audiorenderer_onmarkreachedcallback))([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t samplePos, void \*userData) | Defines a pointer to the callback invoked when the mark position is reached. | 62| typedef int32_t(\* [OH_AudioRenderer_WriteDataWithMetadataCallback](#oh_audiorenderer_writedatawithmetadatacallback))([OH_AudioRenderer](#oh_audiorenderer) \*renderer, void \*userData, void \*audioData, int32_t audioDataSize, void \*metadata, int32_t metadataSize) | Defines a function pointer to the callback function used to write audio data and metadata. | 63| typedef [OH_AudioData_Callback_Result](#oh_audiodata_callback_result)(\* [OH_AudioRenderer_OnWriteDataCallback](#oh_audiorenderer_onwritedatacallback))([OH_AudioRenderer](#oh_audiorenderer) \*renderer, void \*userData, void \*audioData, int32_t audioDataSize) | Defines a function pointer to the callback function used to write audio data. | 64 65 66### Enums 67 68| Name| Description| 69| -------- | -------- | 70| [OH_AudioCommon_Result](#oh_audiocommon_result) {<br>AUDIOCOMMON_RESULT_SUCCESS = 0,<br>AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM = 6800101,<br>AUDIOCOMMON_RESULT_ERROR_NO_MEMORY = 6800102,<br>AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE = 6800103,<br>AUDIOCOMMON_RESULT_ERROR_UNSUPPORTED = 6800104,<br>AUDIOCOMMON_RESULT_ERROR_TIMEOUT = 6800105,<br>AUDIOCOMMON_RESULT_ERROR_STREAM_LIMIT = 6800201,<br>AUDIOCOMMON_RESULT_ERROR_SYSTEM = 6800301<br>} | Enumerates the audio operation results.| 71| [OH_AudioScene](#oh_audioscene) { <br>AUDIO_SCENE_DEFAULT = 0, <br>AUDIO_SCENE_RINGING = 1, <br>AUDIO_SCENE_PHONE_CALL = 2, <br>AUDIO_SCENE_VOICE_CHAT = 3 } | Enumerates the audio scenes. | 72| [OH_AudioDevice_ChangeType](#oh_audiodevice_changetype) {<br>AUDIO_DEVICE_CHANGE_TYPE_CONNECT = 0,<br>AUDIO_DEVICE_CHANGE_TYPE_DISCONNECT = 1<br>} | Enumerates the types of audio device changes.| 73| [OH_AudioDevice_Role](#oh_audiodevice_role) {<br>AUDIO_DEVICE_ROLE_INPUT = 1,<br>AUDIO_DEVICE_ROLE_OUTPUT = 2<br>} | Enumerates the roles of audio devices.| 74| [OH_AudioDevice_Type](#oh_audiodevice_type) {<br>AUDIO_DEVICE_TYPE_INVALID = 0,<br>AUDIO_DEVICE_TYPE_EARPIECE = 1,<br>AUDIO_DEVICE_TYPE_SPEAKER = 2,<br>AUDIO_DEVICE_TYPE_WIRED_HEADSET = 3,<br>AUDIO_DEVICE_TYPE_WIRED_HEADPHONES = 4,<br>AUDIO_DEVICE_TYPE_BLUETOOTH_SCO = 7,<br>AUDIO_DEVICE_TYPE_BLUETOOTH_A2DP = 8,<br>AUDIO_DEVICE_TYPE_MIC = 15,<br>AUDIO_DEVICE_TYPE_USB_HEADSET = 22,<br>AUDIO_DEVICE_TYPE_DISPLAY_PORT = 23,<br>AUDIO_DEVICE_TYPE_REMOTE_CAST = 24,<br>AUDIO_DEVICE_TYPE_DEFAULT = 1000<br>} | Enumerates the types of audio devices.| 75| [OH_AudioDevice_Flag](#oh_audiodevice_flag) {<br>AUDIO_DEVICE_FLAG_NONE = 0,<br>AUDIO_DEVICE_FLAG_OUTPUT = 1,<br>AUDIO_DEVICE_FLAG_INPUT = 2,<br>AUDIO_DEVICE_FLAG_ALL = 3<br>} | Enumerates the flags of audio devices.| 76| [OH_AudioDevice_Usage](#oh_audiodevice_usage) {<br>AUDIO_DEVICE_USAGE_MEDIA_OUTPUT = 1, <br>AUDIO_DEVICE_USAGE_MEDIA_INPUT = 2, <br>AUDIO_DEVICE_USAGE_MEDIA_ALL = 3, <br>AUDIO_DEVICE_USAGE_CALL_OUTPUT = 4,<br>AUDIO_DEVICE_USAGE_CALL_INPUT = 8, <br>AUDIO_DEVICE_USAGE_CALL_ALL = 12<br>} | Enumerates the usage scenarios of audio devices. | 77| [OH_AudioSession_ConcurrencyMode](#oh_audiosession_concurrencymode) { <br>CONCURRENCY_DEFAULT = 0, <br>CONCURRENCY_MIX_WITH_OTHERS = 1, <br>CONCURRENCY_DUCK_OTHERS = 2, <br>CONCURRENCY_PAUSE_OTHERS = 3 } | Enumerates the audio concurrency modes. | 78| [OH_AudioSession_DeactivatedReason](#oh_audiosession_deactivatedreason) { <br>DEACTIVATED_LOWER_PRIORITY = 0, <br>DEACTIVATED_TIMEOUT = 1 } | Enumerates the reasons for deactivating an audio session. | 79| [OH_AudioStream_Result](#oh_audiostream_result) {<br>AUDIOSTREAM_SUCCESS = 0,<br>AUDIOSTREAM_ERROR_INVALID_PARAM = 1,<br>AUDIOSTREAM_ERROR_ILLEGAL_STATE = 2,<br>AUDIOSTREAM_ERROR_SYSTEM = 3<br>} | Enumerates the audio stream operation results.| 80| [OH_AudioStream_Type](#oh_audiostream_type) {<br>AUDIOSTREAM_TYPE_RENDERER = 1,<br>AUDIOSTREAM_TYPE_CAPTURER = 2<br>} | Enumerates the audio stream types.| 81| [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) {<br>AUDIOSTREAM_SAMPLE_U8 = 0,<br>AUDIOSTREAM_SAMPLE_S16LE = 1,<br>AUDIOSTREAM_SAMPLE_S24LE = 2,<br>AUDIOSTREAM_SAMPLE_S32LE = 3<br>} | Enumerates the sampling formats of audio streams.| 82| [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) { <br>AUDIOSTREAM_ENCODING_TYPE_RAW = 0, <br>AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID = 1 <br>} | Enumerates the encoding types of audio streams. | 83| [OH_AudioStream_Usage](#oh_audiostream_usage) {<br>AUDIOSTREAM_USAGE_UNKNOWN = 0,<br>AUDIOSTREAM_USAGE_MUSIC = 1,<br>AUDIOSTREAM_USAGE_VOICE_COMMUNICATION = 2,<br>AUDIOSTREAM_USAGE_VOICE_ASSISTANT = 3,<br>AUDIOSTREAM_USAGE_ALARM = 4,<br>AUDIOSTREAM_USAGE_VOICE_MESSAGE = 5,<br>AUDIOSTREAM_USAGE_RINGTONE = 6,<br>AUDIOSTREAM_USAGE_NOTIFICATION = 7,<br>AUDIOSTREAM_USAGE_ACCESSIBILITY = 8,<br>AUDIOSTREAM_USAGE_MOVIE = 10,<br>AUDIOSTREAM_USAGE_GAME = 11,<br>AUDIOSTREAM_USAGE_AUDIOBOOK = 12,<br>AUDIOSTREAM_USAGE_NAVIGATION = 13,<br>AUDIOSTREAM_USAGE_VIDEO_COMMUNICATION = 17<br>} | Enumerates the usage scenarios of audio streams.| 84| [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) {<br>AUDIOSTREAM_LATENCY_MODE_NORMAL = 0,<br>AUDIOSTREAM_LATENCY_MODE_FAST = 1<br>} | Enumerates the latency modes of audio streams.| 85| [OH_AudioStream_State](#oh_audiostream_state) {<br>AUDIOSTREAM_STATE_INVALID = -1,<br>AUDIOSTREAM_STATE_NEW = 0,<br>AUDIOSTREAM_STATE_PREPARED = 1,<br>AUDIOSTREAM_STATE_RUNNING = 2,<br>AUDIOSTREAM_STATE_STOPPED = 3,<br>AUDIOSTREAM_STATE_RELEASED = 4,<br>AUDIOSTREAM_STATE_PAUSED = 5<br>} | Enumerates the audio stream states.| 86| [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) {<br>AUDIOSTREAM_SOURCE_TYPE_INVALID = -1,<br>AUDIOSTREAM_SOURCE_TYPE_MIC = 0,<br>AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION = 1,<br>AUDIOSTREAM_SOURCE_TYPE_PLAYBACK_CAPTURE = 2,<br>AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION = 7<br>} | Enumerates the usage scenarios of audio streams.| 87| [OH_AudioStream_Event](#oh_audiostream_event) {<br>AUDIOSTREAM_EVENT_ROUTING_CHANGED = 0<br>} | Enumerates the audio stream events.| 88| [OH_AudioInterrupt_ForceType](#oh_audiointerrupt_forcetype) {<br>AUDIOSTREAM_INTERRUPT_FORCE = 0,<br>AUDIOSTREAM_INTERRUPT_SHARE = 1<br>} | Enumerates the types of force that causes audio interruption.| 89| [OH_AudioInterrupt_Hint](#oh_audiointerrupt_hint) {<br>AUDIOSTREAM_INTERRUPT_HINT_NONE = 0,<br>AUDIOSTREAM_INTERRUPT_HINT_RESUME = 1,<br>AUDIOSTREAM_INTERRUPT_HINT_PAUSE = 2,<br>AUDIOSTREAM_INTERRUPT_HINT_STOP = 3,<br>AUDIOSTREAM_INTERRUPT_HINT_DUCK = 4,<br>AUDIOSTREAM_INTERRUPT_HINT_UNDUCK = 5<br>} | Enumerates the hints provided along with audio interruption.| 90| [OH_AudioInterrupt_Mode](#oh_audiointerrupt_mode) {<br> AUDIOSTREAM_INTERRUPT_MODE_SHARE = 0, <br>AUDIOSTREAM_INTERRUPT_MODE_INDEPENDENT = 1 <br>} | Enumerates the audio interruption modes. | 91| [OH_AudioStream_AudioEffectMode](#oh_audiostream_audioeffectmode) { <br>EFFECT_NONE = 0, <br>EFFECT_DEFAULT = 1 <br>} | Enumerates the audio effect modes. | 92| [OH_AudioStream_DeviceChangeReason](#oh_audiostream_devicechangereason) {<br>REASON_UNKNOWN = 0,<br>REASON_NEW_DEVICE_AVAILABLE = 1,<br>REASON_OLD_DEVICE_UNAVAILABLE = 2,<br>REASON_OVERRODE = 3<br>} | Enumerates the reasons for audio stream device changes.| 93| [OH_AudioStream_PrivacyType](#oh_audiostream_privacytype) { <br>AUDIO_STREAM_PRIVACY_TYPE_PUBLIC = 0, <br>AUDIO_STREAM_PRIVACY_TYPE_PRIVATE = 1 <br>} | Enumerates the privacy types of an audio stream. The privacy type specifies whether the audio stream can be recorded by other applications. | 94| [OH_AudioData_Callback_Result](#oh_audiodata_callback_result) { <br>AUDIO_DATA_CALLBACK_RESULT_INVALID = -1, <br>AUDIO_DATA_CALLBACK_RESULT_VALID = 0 <br>} | Enumerates the audio data callback results. | 95 96 97### Functions 98 99| Name| Description| 100| -------- | -------- | 101| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceRole](#oh_audiodevicedescriptor_getdevicerole)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioDevice_Role](#oh_audiodevice_role) \*deviceRole) | Obtains the device role based on an audio device descriptor. | 102| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceType](#oh_audiodevicedescriptor_getdevicetype)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioDevice_Type](#oh_audiodevice_type) \*deviceType) | Obtains the device type based on an audio device descriptor. | 103| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceId](#oh_audiodevicedescriptor_getdeviceid)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*id) | Obtains the device ID based on an audio device descriptor. | 104| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceName](#oh_audiodevicedescriptor_getdevicename)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*name) | Obtains the device name based on an audio device descriptor. | 105| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceAddress](#oh_audiodevicedescriptor_getdeviceaddress)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*address) | Obtains the device address based on an audio device descriptor. | 106| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceSampleRates](#oh_audiodevicedescriptor_getdevicesamplerates)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*\*sampleRates, uint32_t \*size) | Obtains the sample rates based on an audio device descriptor. | 107| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceChannelCounts](#oh_audiodevicedescriptor_getdevicechannelcounts)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*\*channelCounts, uint32_t \*size) | Obtains an array that holds the number of device channels based on an audio device descriptor. | 108| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceDisplayName](#oh_audiodevicedescriptor_getdevicedisplayname)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*displayName) | Obtains the device display name based on an audio device descriptor. | 109| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceEncodingTypes](#oh_audiodevicedescriptor_getdeviceencodingtypes)([OH_AudioDeviceDescriptor](#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*\*encodingTypes, uint32_t \*size) | Obtains the device encoding types based on an audio device descriptor. | 110| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_GetAudioManager](#oh_getaudiomanager)([OH_AudioManager](#oh_audiomanager) \*\*audioManager) | Obtains an **OH_AudioManager** instance. | 111| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_GetAudioScene](#oh_getaudioscene)([OH_AudioManager](#oh_audiomanager) \*manager, [OH_AudioScene](#oh_audioscene) \*scene) | Obtains the audio scene. | 112| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*\*audioRoutingManager) | Obtains the handle to an audio routing manager. The handle should be set as the first parameter in the routing-related functions. | 113| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioDevice_Flag](#oh_audiodevice_flag) deviceFlag, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*\*audioDeviceDescriptorArray) | Obtains available devices based on the device flag. | 114| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_GetAvailableDevices](#oh_audioroutingmanager_getavailabledevices)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioDevice_Usage](#oh_audiodevice_usage) deviceUsage, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*\*audioDeviceDescriptorArray) | Obtains the available audio devices. | 115| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_GetPreferredOutputDevice](#oh_audioroutingmanager_getpreferredoutputdevice)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioStream_Usage](#oh_audiostream_usage) streamUsage, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*\*audioDeviceDescriptorArray) | Obtains the output device with the highest priority based on the usage scenario of an audio output stream. | 116| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_GetPreferredInputDevice](#oh_audioroutingmanager_getpreferredinputdevice)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) sourceType, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*\*audioDeviceDescriptorArray) | Obtains the input device with the highest priority based on the usage scenario of an audio input stream. | 117| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_RegisterDeviceChangeCallback](#oh_audioroutingmanager_registerdevicechangecallback)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioDevice_Flag](#oh_audiodevice_flag) deviceFlag, [OH_AudioRoutingManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback) callback) | Registers a callback to listen for device changes of an audio routing manager. | 118| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_UnregisterDeviceChangeCallback](#oh_audioroutingmanager_unregisterdevicechangecallback)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioRoutingManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback) callback) | Unregisters the callback used to listen for device changes of an audio routing manager. | 119| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices)([OH_AudioRoutingManager](#oh_audioroutingmanager) \*audioRoutingManager, [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) \*audioDeviceDescriptorArray) | Releases audio devices available for an audio routing manager. | 120| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager)([OH_AudioSessionManager](#oh_audiosessionmanager) \*\*audioSessionManager) | Obtains an **OH_AudioSessionManager** instance. | 121| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioSessionManager_ActivateAudioSession](#oh_audiosessionmanager_activateaudiosession)([OH_AudioSessionManager](#oh_audiosessionmanager) \*audioSessionManager, const [OH_AudioSession_Strategy](_o_h___audio_session___strategy.md) \*strategy) | Activates an audio session. | 122| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioSessionManager_DeactivateAudioSession](#oh_audiosessionmanager_deactivateaudiosession)([OH_AudioSessionManager](#oh_audiosessionmanager) \*audioSessionManager) | Deactivates an audio session. | 123| bool [OH_AudioSessionManager_IsAudioSessionActivated](#oh_audiosessionmanager_isaudiosessionactivated)([OH_AudioSessionManager](#oh_audiosessionmanager) \*audioSessionManager) | Checks whether an audio session is activated. | 124| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioSessionManager_RegisterSessionDeactivatedCallback](#oh_audiosessionmanager_registersessiondeactivatedcallback)([OH_AudioSessionManager](#oh_audiosessionmanager) \*audioSessionManager, [OH_AudioSession_DeactivatedCallback](#oh_audiosession_deactivatedcallback) callback) | Registers a callback to listen for audio session deactivation events. | 125| [OH_AudioCommon_Result](#oh_audiocommon_result) [OH_AudioSessionManager_UnregisterSessionDeactivatedCallback](#oh_audiosessionmanager_unregistersessiondeactivatedcallback)([OH_AudioSessionManager](#oh_audiosessionmanager) \*audioSessionManager, [OH_AudioSession_DeactivatedCallback](#oh_audiosession_deactivatedcallback) callback) | Unregisters the callback used to listen for audio session deactivation events. | 126| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_Release](#oh_audiocapturer_release)([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Releases an audio capturer. | 127| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_Start](#oh_audiocapturer_start)([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Starts an audio capturer. | 128| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_Pause](#oh_audiocapturer_pause)([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Pauses an audio capturer. | 129| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_Stop](#oh_audiocapturer_stop)([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Stops an audio capturer. | 130| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_Flush](#oh_audiocapturer_flush)([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Flushes obtained audio data. | 131| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetCurrentState](#oh_audiocapturer_getcurrentstate)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio capturer. | 132| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetLatencyMode](#oh_audiocapturer_getlatencymode)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio capturer. | 133| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetStreamId](#oh_audiocapturer_getstreamid)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, uint32_t \*streamId) | Obtains the stream ID of an audio capturer. | 134| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetSamplingRate](#oh_audiocapturer_getsamplingrate)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*rate) | Obtains the sampling rate of an audio capturer. | 135| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetChannelCount](#oh_audiocapturer_getchannelcount)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*channelCount) | Obtains the number of channels for an audio capturer. | 136| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetSampleFormat](#oh_audiocapturer_getsampleformat)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio capturer. | 137| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetEncodingType](#oh_audiocapturer_getencodingtype)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio capturer. | 138| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetCapturerInfo](#oh_audiocapturer_getcapturerinfo)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) \*sourceType) | Obtains the usage scenario of an audio capturer. | 139| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetFrameSizeInCallback](#oh_audiocapturer_getframesizeincallback)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*frameSize) | Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback. | 140| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetTimestamp](#oh_audiocapturer_gettimestamp)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, clockid_t clockId, int64_t \*framePosition, int64_t \*timestamp) | Obtains the timestamp and position information of an audio input stream. | 141| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetFramesRead](#oh_audiocapturer_getframesread)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int64_t \*frames) | Obtains the number of frames that have been read since the stream was created. | 142| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioCapturer_GetOverflowCount](#oh_audiocapturer_getoverflowcount)([OH_AudioCapturer](#oh_audiocapturer) \*capturer, uint32_t \*count) | Obtains the number of overloaded audio streams of an audio capturer. | 143| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_Release](#oh_audiorenderer_release)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Releases an audio renderer. | 144| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_Start](#oh_audiorenderer_start)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Starts an audio renderer. | 145| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_Pause](#oh_audiorenderer_pause)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Pauses an audio renderer. | 146| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_Stop](#oh_audiorenderer_stop)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Stops an audio renderer. | 147| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_Flush](#oh_audiorenderer_flush)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Flushes written audio data. | 148| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetCurrentState](#oh_audiorenderer_getcurrentstate)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio renderer. | 149| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetSamplingRate](#oh_audiorenderer_getsamplingrate)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*rate) | Obtains the sampling rate of an audio renderer. | 150| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetStreamId](#oh_audiorenderer_getstreamid)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t \*streamId) | Obtains the stream ID of an audio renderer. | 151| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetChannelCount](#oh_audiorenderer_getchannelcount)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*channelCount) | Obtains the number of channels for an audio renderer. | 152| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetSampleFormat](#oh_audiorenderer_getsampleformat)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio renderer. | 153| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetLatencyMode](#oh_audiorenderer_getlatencymode)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio renderer. | 154| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetRendererInfo](#oh_audiorenderer_getrendererinfo)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_Usage](#oh_audiostream_usage) \*usage) | Obtains the usage scenario of an audio renderer. | 155| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetEncodingType](#oh_audiorenderer_getencodingtype)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio renderer. | 156| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetFramesWritten](#oh_audiorenderer_getframeswritten)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int64_t \*frames) | Obtains the number of frames that have been written since the stream was created. | 157| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetTimestamp](#oh_audiorenderer_gettimestamp)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, clockid_t clockId, int64_t \*framePosition, int64_t \*timestamp) | Obtains the timestamp and position information of an audio output stream. | 158| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetFrameSizeInCallback](#oh_audiorenderer_getframesizeincallback)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*frameSize) | Obtains the frame size in the callback. | 159| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetSpeed](#oh_audiorenderer_getspeed)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, float \*speed) | Obtains the audio renderer rate. | 160| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetSpeed](#oh_audiorenderer_setspeed)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, float speed) | Sets the audio renderer rate. | 161| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetMarkPosition](#oh_audiorenderer_setmarkposition)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t samplePos, [OH_AudioRenderer_OnMarkReachedCallback](#oh_audiorenderer_onmarkreachedcallback) callback, void \*userData) | Sets the mark position for an audio renderer. When this function is called, the mark position that has been set will be overwritten. | 162| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_CancelMark](#oh_audiorenderer_cancelmark)([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Cancels the mark set by [OH_AudioRenderer_SetMarkPosition](#oh_audiorenderer_setmarkposition). | 163| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetVolume](#oh_audiorenderer_setvolume)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, float volume) | Sets the volume for an audio stream. | 164| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetVolumeWithRamp](#oh_audiorenderer_setvolumewithramp)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, float volume, int32_t durationMs) | Sets the volume with a ramp within the specified duration for an audio stream. | 165| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetVolume](#oh_audiorenderer_getvolume)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, float \*volume) | Obtains the volume of an audio stream. | 166| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetUnderflowCount](#oh_audiorenderer_getunderflowcount)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t \*count) | Obtains the number of underloaded audio streams of an audio capturer. | 167| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetChannelLayout](#oh_audiorenderer_getchannellayout)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1) \*channelLayout) | Obtains the channel layout of an audio stream. | 168| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetEffectMode](#oh_audiorenderer_geteffectmode)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_AudioEffectMode](#oh_audiostream_audioeffectmode) \*effectMode) | Obtains the effect mode of an audio stream. | 169| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetEffectMode](#oh_audiorenderer_seteffectmode)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_AudioEffectMode](#oh_audiostream_audioeffectmode) effectMode) | Sets the effect mode for an audio stream. | 170| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetRendererPrivacy](#oh_audiorenderer_getrendererprivacy)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_PrivacyType](#oh_audiostream_privacytype) \*privacy) | Checks whether the audio stream being played can be recorded by other applications. | 171| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetSilentModeAndMixWithOthers](#oh_audiorenderer_setsilentmodeandmixwithothers)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, bool on) | Sets the silent mode in concurrent playback for an audio stream. | 172| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_GetSilentModeAndMixWithOthers](#oh_audiorenderer_getsilentmodeandmixwithothers)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, bool \*on) | Checks whether the silent mode in concurrent playback is enabled for an audio stream. | 173| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioRenderer_SetDefaultOutputDevice](#oh_audiorenderer_setdefaultoutputdevice)([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioDevice_Type](#oh_audiodevice_type) deviceType) | Sets the default built-in audio output device. | 174| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*\*builder, [OH_AudioStream_Type](#oh_audiostream_type) type) | Creates an audio stream builder, which can be an audio renderer or capturer. | 175| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_Destroy](#oh_audiostreambuilder_destroy)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder) | Destroys an audio stream builder. | 176| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetSamplingRate](#oh_audiostreambuilder_setsamplingrate)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t rate) | Sets the sampling rate of an audio stream. | 177| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetChannelCount](#oh_audiostreambuilder_setchannelcount)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t channelCount) | Sets the number of channels for an audio stream. | 178| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetSampleFormat](#oh_audiostreambuilder_setsampleformat)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) format) | Sets the sampling format of an audio stream. | 179| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetEncodingType](#oh_audiostreambuilder_setencodingtype)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) encodingType) | Sets the encoding type of an audio stream. | 180| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetLatencyMode](#oh_audiostreambuilder_setlatencymode)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) latencyMode) | Sets the latency mode of an audio stream. | 181| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetChannelLayout](#oh_audiostreambuilder_setchannellayout)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1) channelLayout) | Sets the channel layout for an audio stream. | 182| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererInfo](#oh_audiostreambuilder_setrendererinfo)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_Usage](#oh_audiostream_usage) usage) | Sets the usage scenario of an audio renderer. | 183| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetCapturerInfo](#oh_audiostreambuilder_setcapturerinfo)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) sourceType) | Sets the usage scenario of an audio capturer. | 184| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio renderer. | 185| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback](#oh_audiostreambuilder_setrendereroutputdevicechangecallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_OutputDeviceChangeCallback](#oh_audiorenderer_outputdevicechangecallback) callback, void \*userData) | Sets the callback invoked when the audio stream device changes. | 186| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererPrivacy](#oh_audiostreambuilder_setrendererprivacy)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_PrivacyType](#oh_audiostream_privacytype) privacy) | Sets the privacy type for the audio stream being played. The privacy type specifies whether the audio stream can be recorded by other applications. | 187| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio capturer. | 188| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback](#oh_audiostreambuilder_setwritedatawithmetadatacallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_WriteDataWithMetadataCallback](#oh_audiorenderer_writedatawithmetadatacallback) callback, void \*userData) | Sets the callback invoked to write both audio data and metadata. | 189| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer](#oh_audiorenderer) \*\*audioRenderer) | Creates an audio renderer instance. | 190| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer](#oh_audiocapturer) \*\*audioCapturer) | Creates an audio capturer instance. | 191| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetFrameSizeInCallback](#oh_audiostreambuilder_setframesizeincallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t frameSize) | Sets the frame size for each callback during playback. The frame size must be at least equal to the size of the data processed by the audio hardware at a time and less than half of the internal buffer capacity. | 192| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererInterruptMode](#oh_audiostreambuilder_setrendererinterruptmode)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioInterrupt_Mode](#oh_audiointerrupt_mode) mode) | Sets the interrupt mode of the stream client.| 193| [OH_AudioStream_Result](#oh_audiostream_result) [OH_AudioStreamBuilder_SetRendererWriteDataCallback](#oh_audiostreambuilder_setrendererwritedatacallback)([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_OnWriteDataCallback](#oh_audiorenderer_onwritedatacallback) callback, void \*userData) | Sets the callback used to write audio data. | 194 195 196## Type Description 197 198 199### OH_AudioCapturer 200 201``` 202typedef struct OH_AudioCapturerStruct OH_AudioCapturer 203``` 204 205**Description** 206 207Defines a struct for an audio capturer. 208 209An audio capturer instance is used to capture audio data. 210 211**System capability**: SystemCapability.Multimedia.Audio.Core 212 213**Since**: 10 214 215 216### OH_AudioCapturer_Callbacks 217 218``` 219typedef struct OH_AudioCapturer_Callbacks_Struct OH_AudioCapturer_Callbacks 220``` 221 222**Description** 223 224Defines a pointer to the callback functions related to an audio capturer. 225 226**System capability**: SystemCapability.Multimedia.Audio.Core 227 228**Since**: 10 229 230 231### OH_AudioDeviceDescriptor 232 233``` 234typedef struct OH_AudioDeviceDescriptor OH_AudioDeviceDescriptor 235``` 236 237**Description** 238 239Defines a struct for an audio device descriptor. 240 241It provides detailed attributes of an audio device. 242 243**Since**: 12 244 245 246### OH_AudioDeviceDescriptorArray 247 248``` 249typedef struct OH_AudioDeviceDescriptorArray OH_AudioDeviceDescriptorArray 250``` 251 252**Description** 253 254Defines a struct for an array of audio device descriptors. 255 256**Since**: 12 257 258 259### OH_AudioManager 260 261``` 262typedef struct OH_AudioManager OH_AudioManager 263``` 264 265**Description** 266 267Defines a struct for an audio manager. 268 269An audio manager provides audio management. 270 271**Since**: 12 272 273 274### OH_AudioRenderer 275 276``` 277typedef struct OH_AudioRendererStruct OH_AudioRenderer 278``` 279 280**Description** 281 282Defines a struct for an audio renderer. 283 284An audio renderer instance is used to render audio data. 285 286**System capability**: SystemCapability.Multimedia.Audio.Core 287 288**Since**: 10 289 290 291### OH_AudioRenderer_Callbacks 292 293``` 294typedef struct OH_AudioRenderer_Callbacks_Struct OH_AudioRenderer_Callbacks 295``` 296 297**Description** 298 299Defines a pointer to the callback functions related to an audio renderer. 300 301**System capability**: SystemCapability.Multimedia.Audio.Core 302 303**Since**: 10 304 305 306### OH_AudioRenderer_OnMarkReachedCallback 307 308``` 309typedef void(* OH_AudioRenderer_OnMarkReachedCallback)(OH_AudioRenderer *renderer, uint32_t samplePos, void *userData) 310``` 311 312**Description** 313 314Defines a pointer to the callback invoked when the mark position is reached. 315 316**Since**: 12 317 318**Parameters** 319 320| Name| Description| 321| -------- | -------- | 322| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 323| samplePos | Mark position. | 324| userData | Pointer to the application data passed through the callback functions. | 325 326 327### OH_AudioRenderer_OnWriteDataCallback 328 329``` 330typedef OH_AudioData_Callback_Result(* OH_AudioRenderer_OnWriteDataCallback)(OH_AudioRenderer *renderer, void *userData, void *audioData, int32_t audioDataSize) 331``` 332 333**Description** 334 335Defines a function pointer to the callback function used to write audio data. 336 337This function is similar to the function pointer [OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnWriteData](_o_h___audio_renderer___callbacks___struct.md#oh_audiorenderer_onwritedata). However, this function has a return value to identify the audio data callback result. The return result indicates whether the data filled in the buffer is valid. If the data is invalid, the data entered by the user will not be played. 338 339**System capability**: SystemCapability.Multimedia.Audio.Core 340 341**Since**: 12 342 343**Parameters** 344 345| Name| Description| 346| -------- | -------- | 347| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 348| userData | Pointer to the application data passed through the callback functions. | 349| audioData | Pointer to the audio data written by the user. | 350| audioDataSize | Length of the audio data, in bytes. | 351 352**Returns** 353 354Audio data callback result. 355 356**See** 357 358[OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnWriteData](_o_h___audio_renderer___callbacks___struct.md#oh_audiorenderer_onwritedata) 359 360 361### OH_AudioRenderer_OutputDeviceChangeCallback 362 363``` 364typedef void(* OH_AudioRenderer_OutputDeviceChangeCallback) (OH_AudioRenderer *renderer, void *userData, OH_AudioStream_DeviceChangeReason reason) 365``` 366 367**Description** 368 369Defines a pointer to the callback invoked when the audio stream device changes. 370 371**System capability**: SystemCapability.Multimedia.Audio.Core 372 373**Since**: 11 374 375**Parameters** 376 377| Name| Description| 378| -------- | -------- | 379| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 380| userData | Pointer to the application data passed through the callback functions. | 381| reason | Enumerates the reasons for audio stream device changes. | 382 383 384### OH_AudioRenderer_WriteDataWithMetadataCallback 385 386``` 387typedef int32_t(* OH_AudioRenderer_WriteDataWithMetadataCallback)(OH_AudioRenderer *renderer, void *userData, void *audioData, int32_t audioDataSize, void *metadata, int32_t metadataSize) 388``` 389 390**Description** 391 392Defines a function pointer to the callback function used to write audio data and metadata. 393 394**System capability**: SystemCapability.Multimedia.Audio.Core 395 396**Since**: 12 397 398**Parameters** 399 400| Name| Description| 401| -------- | -------- | 402| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 403| userData | Pointer to the application data passed through the callback functions. | 404| audioData | Pointer to the audio data written by the user. | 405| audioDataSize | Length of the audio data, in bytes. | 406| metadata | Pointer to the metadata written by the user. | 407| metadataSize | Length of the metadata, in bytes. | 408 409**Returns** 410 411Error code of the callback function. 412 413 414### OH_AudioRoutingManager 415 416``` 417typedef struct OH_AudioRoutingManager OH_AudioRoutingManager 418``` 419 420**Description** 421 422Defines a struct for an audio routing manager, which is used for routing and device-related functions. 423 424**Since**: 12 425 426 427### OH_AudioRoutingManager_OnDeviceChangedCallback 428 429``` 430typedef int32_t(* OH_AudioRoutingManager_OnDeviceChangedCallback) (OH_AudioDevice_ChangeType type, OH_AudioDeviceDescriptorArray *audioDeviceDescriptorArray) 431``` 432 433**Description** 434 435Defines a pointer to the callback function that returns the changed audio device descriptor (possibly multiple descriptors). 436 437**Since**: 12 438 439**Parameters** 440 441| Name| Description| 442| -------- | -------- | 443| type | Device connection status, which is [OH_AudioDevice_ChangeType](#oh_audiodevice_changetype). The status can be either connected or disconnected.| 444| audioDeviceDescriptorArray | Pointer to the audio device descriptor array, which is [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md). Do not release the pointer to the **audioDeviceDescriptorArray** struct separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release the **DeviceDescriptor** array.| 445 446 447### OH_AudioSession_DeactivatedCallback 448 449``` 450typedef int32_t(* OH_AudioSession_DeactivatedCallback)(OH_AudioSession_DeactivatedEvent event) 451``` 452 453**Description** 454 455Defines a function pointer to the callback function used to listen for audio session deactivation events. 456 457**Since**: 12 458 459**Parameters** 460 461| Name| Description| 462| -------- | -------- | 463| event | Pointer to [OH_AudioSession_Deactivated_Event](#oh_audiosession_deactivatedevent), which indicates that an audio session is deactivated. | 464 465 466### OH_AudioSession_DeactivatedEvent 467 468``` 469typedef struct OH_AudioSession_DeactivatedEventOH_AudioSession_DeactivatedEvent 470``` 471 472**Description** 473 474Defines a struct for the event indicating that an audio session is deactivated. 475 476**Since**: 12 477 478 479### OH_AudioSession_Strategy 480 481``` 482typedef struct OH_AudioSession_Strategy OH_AudioSession_Strategy 483``` 484 485**Description** 486 487Defines a struct for an audio session strategy. 488 489**Since**: 12 490 491 492### OH_AudioSessionManager 493 494``` 495typedef struct OH_AudioSessionManager OH_AudioSessionManager 496``` 497 498**Description** 499 500Defines a struct for an audio session manager. 501 502An audio session manager is used to manage audio sessions. 503 504**Since**: 12 505 506 507### OH_AudioStreamBuilder 508 509``` 510typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder 511``` 512 513**Description** 514 515Defines a struct for an audio stream builder. 516 517An audio stream builder instance is often used to create an audio stream and set its attributes. 518 519**System capability**: SystemCapability.Multimedia.Audio.Core 520 521**Since**: 10 522 523 524## Enum Description 525 526 527### OH_AudioCommon_Result 528 529``` 530enum OH_AudioCommon_Result 531``` 532 533**Description** 534 535Enumerates the audio operation results. 536 537**Since**: 12 538 539| Value| Description| 540| -------- | -------- | 541| AUDIOCOMMON_RESULT_SUCCESS | Operation successful. | 542| AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM | Invalid input parameter. | 543| AUDIOCOMMON_RESULT_ERROR_NO_MEMORY | No memory. | 544| AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE | Invalid state. | 545| AUDIOCOMMON_RESULT_ERROR_UNSUPPORTED | Unsupported operation. | 546| AUDIOCOMMON_RESULT_ERROR_TIMEOUT | Operation timed out. | 547| AUDIOCOMMON_RESULT_ERROR_STREAM_LIMIT | Reached the maximum number of audio streams allowed. | 548| AUDIOCOMMON_RESULT_ERROR_SYSTEM | System error. | 549 550 551### OH_AudioData_Callback_Result 552 553``` 554enum OH_AudioData_Callback_Result 555``` 556 557**Description** 558 559Enumerates the audio data callback results. 560 561**System capability**: SystemCapability.Multimedia.Audio.Core 562 563**Since**: 12 564 565| Value| Description| 566| -------- | -------- | 567| AUDIO_DATA_CALLBACK_RESULT_INVALID | The data is invalid. | 568| AUDIO_DATA_CALLBACK_RESULT_VALID | The data is valid. | 569 570 571### OH_AudioDevice_ChangeType 572 573``` 574enum OH_AudioDevice_ChangeType 575``` 576 577**Description** 578 579Enumerates the types of audio device changes. 580 581**Since**: 12 582 583| Value| Description| 584| -------- | -------- | 585| AUDIO_DEVICE_CHANGE_TYPE_CONNECT | Device connected.| 586| AUDIO_DEVICE_CHANGE_TYPE_DISCONNECT | Device disconnected.| 587 588 589### OH_AudioDevice_Flag 590 591``` 592enum OH_AudioDevice_Flag 593``` 594 595**Description** 596 597Enumerates the flags of audio devices. 598 599**Since**: 12 600 601| Value| Description| 602| -------- | -------- | 603| AUDIO_DEVICE_FLAG_NONE | No flag.| 604| AUDIO_DEVICE_FLAG_OUTPUT | Output device.| 605| AUDIO_DEVICE_FLAG_INPUT | Input device.| 606| AUDIO_DEVICE_FLAG_ALL | All devices.| 607 608 609### OH_AudioDevice_Role 610 611``` 612enum OH_AudioDevice_Role 613``` 614 615**Description** 616 617Enumerates the roles of audio devices. 618 619**Since**: 12 620 621| Value| Description| 622| -------- | -------- | 623| AUDIO_DEVICE_ROLE_INPUT | Input device.| 624| AUDIO_DEVICE_ROLE_OUTPUT | Output device.| 625 626 627### OH_AudioDevice_Type 628 629``` 630enum OH_AudioDevice_Type 631``` 632 633**Description** 634 635Enumerates the types of audio devices. 636 637**Since**: 12 638 639| Value| Description| 640| -------- | -------- | 641| AUDIO_DEVICE_TYPE_INVALID | Invalid device.| 642| AUDIO_DEVICE_TYPE_EARPIECE | Earpiece.| 643| AUDIO_DEVICE_TYPE_SPEAKER | Speaker.| 644| AUDIO_DEVICE_TYPE_WIRED_HEADSET | Wired headset with a microphone.| 645| AUDIO_DEVICE_TYPE_WIRED_HEADPHONES | Wired headset without microphone.| 646| AUDIO_DEVICE_TYPE_BLUETOOTH_SCO | Bluetooth device using Synchronous Connection-oriented (SCO) links.| 647| AUDIO_DEVICE_TYPE_BLUETOOTH_A2DP | Bluetooth device using Advanced Audio Distribution Profile (A2DP) links.| 648| AUDIO_DEVICE_TYPE_MIC | Microphone.| 649| AUDIO_DEVICE_TYPE_USB_HEADSET | USB headset.| 650| AUDIO_DEVICE_TYPE_DISPLAY_PORT | Display port device.| 651| AUDIO_DEVICE_TYPE_REMOTE_CAST | Remote cast device.| 652| AUDIO_DEVICE_TYPE_DEFAULT | Default device type.| 653 654 655### OH_AudioDevice_Usage 656 657``` 658enum OH_AudioDevice_Usage 659``` 660 661**Description** 662 663Enumerates the usage scenarios of audio devices. 664 665**Since**: 12 666 667| Value| Description| 668| -------- | -------- | 669| AUDIO_DEVICE_USAGE_MEDIA_OUTPUT | Media output device.| 670| AUDIO_DEVICE_USAGE_MEDIA_INPUT | Media input device.| 671| AUDIO_DEVICE_USAGE_MEDIA_ALL | All media devices.| 672| AUDIO_DEVICE_USAGE_CALL_OUTPUT | Call output device.| 673| AUDIO_DEVICE_USAGE_CALL_INPUT | Call input device.| 674| AUDIO_DEVICE_USAGE_CALL_ALL | All call devices.| 675 676 677### OH_AudioInterrupt_ForceType 678 679``` 680enum OH_AudioInterrupt_ForceType 681``` 682 683**Description** 684 685Enumerates the types of force that causes audio interruption. 686 687The force type is obtained when an audio interruption event is received. 688 689This type specifies whether the audio interruption operation is forcibly performed by the system. The operation information (such as audio pause or stop) can be obtained through [OH_AudioInterrupt_Hint](#oh_audiointerrupt_hint). 690 691**System capability**: SystemCapability.Multimedia.Audio.Core 692 693**Since**: 10 694 695| Value| Description| 696| -------- | -------- | 697| AUDIOSTREAM_INTERRUPT_FORCE | The operation is forcibly performed by the system. | 698| AUDIOSTREAM_INTERRUPT_SHARE | The operation will not be performed by the system. [OH_AudioInterrupt_Hint](#oh_audiointerrupt_hint) is used to provide recommended operations for the application, and the application can determine the next processing mode. | 699 700 701### OH_AudioInterrupt_Hint 702 703``` 704enum OH_AudioInterrupt_Hint 705``` 706 707**Description** 708 709Enumerates the hints provided along with audio interruption. 710 711The hint is obtained when an audio interruption event is received. 712 713The hint specifies the operation (such as audio pause or volume adjustment) to be performed on audio streams based on the focus policy. You can determine whether the operation is forcibly performed by the system based on [OH_AudioInterrupt_ForceType](#oh_audiointerrupt_forcetype). 714 715**System capability**: SystemCapability.Multimedia.Audio.Core 716 717**Since**: 10 718 719| Value| Description| 720| -------- | -------- | 721| AUDIOSTREAM_INTERRUPT_HINT_NONE | None. | 722| AUDIOSTREAM_INTERRUPT_HINT_RESUME | A hint is displayed, indicating that the audio stream is restored. The application can proactively trigger operations related to rendering or recording.<br>This operation cannot be forcibly performed by the system, and the corresponding [OH_AudioInterrupt_ForceType](#oh_audiointerrupt_forcetype) must be **AUDIOSTREAM_INTERRUPT_SHARE**. | 723| AUDIOSTREAM_INTERRUPT_HINT_PAUSE | A hint is displayed, indicating that the audio stream is paused and the audio focus is lost temporarily.<br>The **AUDIOSTREAM_INTERRUPT_HINT_RESUME** event will be triggered when the focus is gained. | 724| AUDIOSTREAM_INTERRUPT_HINT_STOP | A hint is displayed, indicating that the audio stream stops and the audio focus is lost. | 725| AUDIOSTREAM_INTERRUPT_HINT_DUCK | A hint is displayed, indicating that audio ducking starts and the audio is played at a lower volume. | 726| AUDIOSTREAM_INTERRUPT_HINT_UNDUCK | A hint is displayed, indicating that audio ducking ends and the audio is played at the normal volume. | 727 728 729### OH_AudioInterrupt_Mode 730 731``` 732enum OH_AudioInterrupt_Mode 733``` 734 735**Description** 736 737Enumerates the audio interruption modes. 738 739**System capability**: SystemCapability.Multimedia.Audio.Core 740 741**Since**: 12 742 743| Value| Description| 744| -------- | -------- | 745| AUDIOSTREAM_INTERRUPT_MODE_SHARE | Shared mode. | 746| AUDIOSTREAM_INTERRUPT_MODE_INDEPENDENT | Independent mode.| 747 748 749### OH_AudioScene 750 751``` 752enum OH_AudioScene 753``` 754 755**Description** 756 757Enumerates the audio scenes. 758 759**Since**: 12 760 761| Value| Description| 762| -------- | -------- | 763| AUDIO_SCENE_DEFAULT | Default audio scene.| 764| AUDIO_SCENE_RINGING | Ringing scene.| 765| AUDIO_SCENE_PHONE_CALL | Phone call scene.| 766| AUDIO_SCENE_VOICE_CHAT | Voice chat scene.| 767 768 769### OH_AudioSession_ConcurrencyMode 770 771``` 772enum OH_AudioSession_ConcurrencyMode 773``` 774 775**Description** 776 777Enumerates the audio concurrency modes. 778 779**Since**: 12 780 781| Value| Description| 782| -------- | -------- | 783| CONCURRENCY_DEFAULT | Uses the system strategy by default. | 784| CONCURRENCY_MIX_WITH_OTHERS | Mixes audio with other applications that are playing audio. | 785| CONCURRENCY_DUCK_OTHERS | Lowers the volume of the application that is currently playing the audio. | 786| CONCURRENCY_PAUSE_OTHERS | Pauses the application that is currently playing the audio. | 787 788 789### OH_AudioSession_DeactivatedReason 790 791``` 792enum OH_AudioSession_DeactivatedReason 793``` 794 795**Description** 796 797Enumerates the reasons for deactivating an audio session. 798 799**Since**: 12 800 801| Value| Description| 802| -------- | -------- | 803| DEACTIVATED_LOWER_PRIORITY | The application focus is preempted. | 804| DEACTIVATED_TIMEOUT | The application times out after the stream is stopped. | 805 806 807### OH_AudioStream_AudioEffectMode 808 809``` 810enum OH_AudioStream_AudioEffectMode 811``` 812 813**Description** 814 815Enumerates the audio effect modes. 816 817**System capability**: SystemCapability.Multimedia.Audio.Core 818 819**Since**: 12 820 821| Value| Description| 822| -------- | -------- | 823| EFFECT_NONE | No audio effect used. | 824| EFFECT_DEFAULT | Default audio effect mode. | 825 826 827### OH_AudioStream_DeviceChangeReason 828 829``` 830enum OH_AudioStream_DeviceChangeReason 831``` 832 833**Description** 834 835Enumerates the reasons for audio stream device changes. 836 837**System capability**: SystemCapability.Multimedia.Audio.Core 838 839**Since**: 11 840 841| Value| Description| 842| -------- | -------- | 843| REASON_UNKNOWN | Unknown reason. | 844| REASON_NEW_DEVICE_AVAILABLE | A new device is available. | 845| REASON_OLD_DEVICE_UNAVAILABLE | The old device is unavailable. When this reason is reported, the application should consider pausing audio playback. | 846| REASON_OVERRODE | The user or system forcibly changes the device. | 847 848 849### OH_AudioStream_EncodingType 850 851``` 852enum OH_AudioStream_EncodingType 853``` 854 855**Description** 856 857Enumerates the encoding types of audio streams. 858 859**System capability**: SystemCapability.Multimedia.Audio.Core 860 861**Since**: 10 862 863| Value| Description| 864| -------- | -------- | 865| AUDIOSTREAM_ENCODING_TYPE_RAW | PCM encoding. | 866| AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID | AudioVivid encoding.<br>**Since**: 12| 867 868 869### OH_AudioStream_Event 870 871``` 872enum OH_AudioStream_Event 873``` 874 875**Description** 876 877Enumerates the audio stream events. 878 879This enum is used to describe audio events. 880 881**System capability**: SystemCapability.Multimedia.Audio.Core 882 883**Since**: 10 884 885| Value| Description| 886| -------- | -------- | 887| AUDIOSTREAM_EVENT_ROUTING_CHANGED | The audio route has been changed. | 888 889 890### OH_AudioStream_LatencyMode 891 892``` 893enum OH_AudioStream_LatencyMode 894``` 895 896**Description** 897 898Enumerates the latency modes of audio streams. 899 900**System capability**: SystemCapability.Multimedia.Audio.Core 901 902**Since**: 10 903 904| Value| Description| 905| -------- | -------- | 906| AUDIOSTREAM_LATENCY_MODE_NORMAL | Normal latency mode. | 907| AUDIOSTREAM_LATENCY_MODE_FAST | Low latency mode. | 908 909 910### OH_AudioStream_PrivacyType 911 912``` 913enum OH_AudioStream_PrivacyType 914``` 915 916**Description** 917 918Enumerates the privacy types of an audio stream. The privacy type specifies whether the audio stream can be recorded by other applications. 919 920**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture 921 922**Since**: 12 923 924| Value| Description| 925| -------- | -------- | 926| AUDIO_STREAM_PRIVACY_TYPE_PUBLIC | The audio stream can be recorded by other applications. | 927| AUDIO_STREAM_PRIVACY_TYPE_PRIVATE | The audio stream cannot be recorded by other applications. | 928 929 930### OH_AudioStream_Result 931 932``` 933enum OH_AudioStream_Result 934``` 935 936**Description** 937 938Enumerates the audio stream operation results. 939 940**System capability**: SystemCapability.Multimedia.Audio.Core 941 942**Since**: 10 943 944| Value| Description| 945| -------- | -------- | 946| AUDIOSTREAM_SUCCESS | The operation is successful. | 947| AUDIOSTREAM_ERROR_INVALID_PARAM | Invalid input parameter. | 948| AUDIOSTREAM_ERROR_ILLEGAL_STATE | Invalid state. | 949| AUDIOSTREAM_ERROR_SYSTEM | System error. | 950 951 952### OH_AudioStream_SampleFormat 953 954``` 955enum OH_AudioStream_SampleFormat 956``` 957 958**Description** 959 960Enumerates the sampling formats of audio streams. 961 962**System capability**: SystemCapability.Multimedia.Audio.Core 963 964**Since**: 10 965 966| Value| Description| 967| -------- | -------- | 968| AUDIOSTREAM_SAMPLE_U8 | Unsigned 8-bit. | 969| AUDIOSTREAM_SAMPLE_S16LE | Short 16-bit little-endian. | 970| AUDIOSTREAM_SAMPLE_S24LE | Short 24-bit little-endian. | 971| AUDIOSTREAM_SAMPLE_S32LE | Short 32-bit little-endian. | 972 973 974### OH_AudioStream_SourceType 975 976``` 977enum OH_AudioStream_SourceType 978``` 979**Description** 980 981Enumerates the usage scenarios of an audio capturer, that is, the usage scenarios of audio input streams. 982 983**System capability**: SystemCapability.Multimedia.Audio.Core 984 985**Since**: 10 986 987| Value| Description| 988| -------- | -------- | 989| AUDIOSTREAM_SOURCE_TYPE_INVALID | Invalid state. | 990| AUDIOSTREAM_SOURCE_TYPE_MIC | Audio recording. | 991| AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION | Voice recognition. | 992| AUDIOSTREAM_SOURCE_TYPE_PLAYBACK_CAPTURE | Audio playback. | 993| AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION | Voice communication. | 994 995 996### OH_AudioStream_State 997 998``` 999enum OH_AudioStream_State 1000``` 1001 1002**Description** 1003 1004Enumerates the audio stream states. 1005 1006**System capability**: SystemCapability.Multimedia.Audio.Core 1007 1008**Since**: 10 1009 1010| Value| Description| 1011| -------- | -------- | 1012| AUDIOSTREAM_STATE_INVALID | Invalid state. | 1013| AUDIOSTREAM_STATE_NEW | Newly created. | 1014| AUDIOSTREAM_STATE_PREPARED | Prepared. | 1015| AUDIOSTREAM_STATE_RUNNING | Running. | 1016| AUDIOSTREAM_STATE_STOPPED | Stopped. | 1017| AUDIOSTREAM_STATE_RELEASED | Released. | 1018| AUDIOSTREAM_STATE_PAUSED | Paused. | 1019 1020 1021### OH_AudioStream_Type 1022 1023``` 1024enum OH_AudioStream_Type 1025``` 1026 1027**Description** 1028 1029Enumerates the audio stream types. 1030 1031**System capability**: SystemCapability.Multimedia.Audio.Core 1032 1033**Since**: 10 1034 1035| Value| Description| 1036| -------- | -------- | 1037| AUDIOSTREAM_TYPE_RENDERER | The audio stream is an output stream. | 1038| AUDIOSTREAM_TYPE_CAPTURER | The audio stream is an input stream. | 1039 1040 1041### OH_AudioStream_Usage 1042 1043``` 1044enum OH_AudioStream_Usage 1045``` 1046 1047**Description** 1048 1049Enumerates the usage scenarios of an audio renderer, that is, the usage scenarios of audio output streams. 1050 1051**System capability**: SystemCapability.Multimedia.Audio.Core 1052 1053**Since**: 10 1054 1055| Value| Description| 1056| -------- | -------- | 1057| AUDIOSTREAM_USAGE_UNKNOWN | Unknown content. | 1058| AUDIOSTREAM_USAGE_MUSIC | Music. | 1059| AUDIOSTREAM_USAGE_VOICE_COMMUNICATION | VoIP voice call. | 1060| AUDIOSTREAM_USAGE_VOICE_ASSISTANT | Voice assistant. | 1061| AUDIOSTREAM_USAGE_ALARM | Alarming. | 1062| AUDIOSTREAM_USAGE_VOICE_MESSAGE | Voice message. | 1063| AUDIOSTREAM_USAGE_RINGTONE | Ringtone. | 1064| AUDIOSTREAM_USAGE_NOTIFICATION | Notification. | 1065| AUDIOSTREAM_USAGE_ACCESSIBILITY | Accessibility. | 1066| AUDIOSTREAM_USAGE_MOVIE | Movie or video. | 1067| AUDIOSTREAM_USAGE_GAME | Gaming. | 1068| AUDIOSTREAM_USAGE_AUDIOBOOK | Audiobooks (including crosstalks and storytelling), news radio, and podcasts. | 1069| AUDIOSTREAM_USAGE_NAVIGATION | Navigation. | 1070| AUDIOSTREAM_USAGE_VIDEO_COMMUNICATION | VoIP video call.<br>**Since**: 12| 1071 1072 1073## Function Description 1074 1075 1076### OH_AudioCapturer_Flush() 1077 1078``` 1079OH_AudioStream_Result OH_AudioCapturer_Flush(OH_AudioCapturer *capturer) 1080``` 1081 1082**Description** 1083 1084Flushes obtained audio data. 1085 1086**Since**: 10 1087 1088**System capability**: SystemCapability.Multimedia.Audio.Core 1089 1090**Parameters** 1091 1092| Name| Description| 1093| -------- | -------- | 1094| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1095 1096**Returns** 1097 1098Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1099 1100**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1101 1102**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1103 1104**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1105 1106 1107### OH_AudioCapturer_GetCapturerInfo() 1108 1109``` 1110OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo(OH_AudioCapturer *capturer, OH_AudioStream_SourceType *sourceType) 1111``` 1112 1113**Description** 1114 1115Obtains the usage scenario of an audio capturer. 1116 1117**Since**: 10 1118 1119**System capability**: SystemCapability.Multimedia.Audio.Core 1120 1121**Parameters** 1122 1123| Name| Description| 1124| -------- | -------- | 1125| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1126| sourceType | Pointer to a variable used to receive the usage scenario.| 1127 1128**Returns** 1129 1130Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1131 1132**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1133 1134**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1135 1136 1137### OH_AudioCapturer_GetChannelCount() 1138 1139``` 1140OH_AudioStream_Result OH_AudioCapturer_GetChannelCount(OH_AudioCapturer *capturer, int32_t *channelCount) 1141``` 1142 1143**Description** 1144 1145Obtains the number of channels for an audio capturer. 1146 1147**Since**: 10 1148 1149**System capability**: SystemCapability.Multimedia.Audio.Core 1150 1151**Parameters** 1152 1153| Name| Description| 1154| -------- | -------- | 1155| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1156| channelCount | Pointer to a variable used to receive the number of channels.| 1157 1158**Returns** 1159 1160Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1161 1162**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1163 1164**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1165 1166 1167### OH_AudioCapturer_GetCurrentState() 1168 1169``` 1170OH_AudioStream_Result OH_AudioCapturer_GetCurrentState(OH_AudioCapturer *capturer, OH_AudioStream_State *state) 1171``` 1172 1173**Description** 1174 1175Obtains the state of an audio capturer. 1176 1177**Since**: 10 1178 1179**System capability**: SystemCapability.Multimedia.Audio.Core 1180 1181**Parameters** 1182 1183| Name| Description| 1184| -------- | -------- | 1185| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1186| state | Pointer to a variable used to receive the state.| 1187 1188**Returns** 1189 1190Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1191 1192**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1193 1194**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1195 1196 1197### OH_AudioCapturer_GetEncodingType() 1198 1199``` 1200OH_AudioStream_Result OH_AudioCapturer_GetEncodingType(OH_AudioCapturer *capturer, OH_AudioStream_EncodingType *encodingType) 1201``` 1202 1203**Description** 1204 1205Obtains the encoding type of an audio capturer. 1206 1207**Since**: 10 1208 1209**System capability**: SystemCapability.Multimedia.Audio.Core 1210 1211**Parameters** 1212 1213| Name| Description| 1214| -------- | -------- | 1215| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1216| encodingType | Pointer to a variable used to receive the encoding type.| 1217 1218**Returns** 1219 1220Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1221 1222**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1223 1224**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1225 1226 1227### OH_AudioCapturer_GetFrameSizeInCallback() 1228 1229``` 1230OH_AudioStream_Result OH_AudioCapturer_GetFrameSizeInCallback(OH_AudioCapturer *capturer, int32_t *frameSize) 1231``` 1232 1233**Description** 1234 1235Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback. 1236 1237**Since**: 10 1238 1239**System capability**: SystemCapability.Multimedia.Audio.Core 1240 1241**Parameters** 1242 1243| Name| Description| 1244| -------- | -------- | 1245| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1246| frameSize | Pointer to the variable that holds the frame size.| 1247 1248**Returns** 1249 1250Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1251 1252**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1253 1254**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1255 1256**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1257 1258 1259### OH_AudioCapturer_GetFramesRead() 1260 1261``` 1262OH_AudioStream_Result OH_AudioCapturer_GetFramesRead (OH_AudioCapturer *capturer, int64_t *frames) 1263``` 1264 1265**Description** 1266 1267Obtains the number of frames that have been read since the stream was created. 1268 1269**Since**: 10 1270 1271**System capability**: SystemCapability.Multimedia.Audio.Core 1272 1273**Parameters** 1274 1275| Name| Description| 1276| -------- | -------- | 1277| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1278| frames | Pointer to the variable that holds the frame count.| 1279 1280**Returns** 1281 1282Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1283 1284**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1285 1286**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1287 1288 1289### OH_AudioCapturer_GetLatencyMode() 1290 1291``` 1292OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode(OH_AudioCapturer *capturer, OH_AudioStream_LatencyMode *latencyMode) 1293``` 1294 1295**Description** 1296 1297Obtains the latency mode of an audio capturer. 1298 1299**Since**: 10 1300 1301**System capability**: SystemCapability.Multimedia.Audio.Core 1302 1303**Parameters** 1304 1305| Name| Description| 1306| -------- | -------- | 1307| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1308| latencyMode | Pointer to a variable used to receive the latency mode.| 1309 1310**Returns** 1311 1312Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1313 1314**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1315 1316**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1317 1318 1319### OH_AudioCapturer_GetOverflowCount() 1320 1321``` 1322OH_AudioStream_Result OH_AudioCapturer_GetOverflowCount (OH_AudioCapturer *capturer, uint32_t *count) 1323``` 1324 1325**Description** 1326 1327Obtains the number of overloaded audio streams of an audio capturer. 1328 1329**Since**: 12 1330 1331**Parameters** 1332 1333| Name| Description| 1334| -------- | -------- | 1335| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer). | 1336| count | Pointer to a variable used to receive the number of overloaded audio streams. | 1337 1338**Returns** 1339 1340Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1341 1342**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1343 1344**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1345 1346 1347### OH_AudioCapturer_GetSampleFormat() 1348 1349``` 1350OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat(OH_AudioCapturer *capturer, OH_AudioStream_SampleFormat *sampleFormat) 1351``` 1352 1353**Description** 1354 1355Obtains the sampling format of an audio capturer. 1356 1357**Since**: 10 1358 1359**System capability**: SystemCapability.Multimedia.Audio.Core 1360 1361**Parameters** 1362 1363| Name| Description| 1364| -------- | -------- | 1365| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1366| sampleFormat | Pointer to a variable used to receive the sampling format.| 1367 1368**Returns** 1369 1370Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1371 1372**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1373 1374**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1375 1376 1377### OH_AudioCapturer_GetSamplingRate() 1378 1379``` 1380OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate(OH_AudioCapturer *capturer, int32_t *rate) 1381``` 1382 1383**Description** 1384 1385Obtains the sampling rate of an audio capturer. 1386 1387**Since**: 10 1388 1389**System capability**: SystemCapability.Multimedia.Audio.Core 1390 1391**Parameters** 1392 1393| Name| Description| 1394| -------- | -------- | 1395| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1396| rate | Pointer to a variable used to receive the sampling rate.| 1397 1398**Returns** 1399 1400Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1401 1402**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1403 1404**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1405 1406 1407### OH_AudioCapturer_GetStreamId() 1408 1409``` 1410OH_AudioStream_Result OH_AudioCapturer_GetStreamId(OH_AudioCapturer *capturer, uint32_t *streamId) 1411``` 1412 1413**Description** 1414 1415Obtains the stream ID of an audio capturer. 1416 1417**Since**: 10 1418 1419**System capability**: SystemCapability.Multimedia.Audio.Core 1420 1421**Parameters** 1422 1423| Name| Description| 1424| -------- | -------- | 1425| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1426| streamId | Pointer to a variable used to receive the stream ID.| 1427 1428**Returns** 1429 1430Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1431 1432**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1433 1434**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1435 1436 1437### OH_AudioCapturer_GetTimestamp() 1438 1439``` 1440OH_AudioStream_Result OH_AudioCapturer_GetTimestamp(OH_AudioCapturer *capturer, clockid_t clockId, int64_t *framePosition, int64_t *timestamp) 1441``` 1442 1443**Description** 1444 1445Obtains the timestamp and position information of an audio input stream. 1446 1447**Since**: 10 1448 1449**System capability**: SystemCapability.Multimedia.Audio.Core 1450 1451**Parameters** 1452 1453| Name| Description| 1454| -------- | -------- | 1455| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1456| clockId | Clock identifier. Use **CLOCK_MONOTONIC**.| 1457| framePosition | Pointer to the variable that holds the position information.| 1458| timestamp | Pointer to the variable that holds the timestamp.| 1459 1460**Returns** 1461 1462Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1463 1464**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1465 1466**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 1467 1468 1. The **capturer** parameter is set to a null pointer. 1469 2. The **clockId** parameter is set to an invalid value. 1470 1471**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1472 1473 1474### OH_AudioCapturer_Pause() 1475 1476``` 1477OH_AudioStream_Result OH_AudioCapturer_Pause(OH_AudioCapturer *capturer) 1478``` 1479 1480**Description** 1481 1482Pauses an audio capturer. 1483 1484**Since**: 10 1485 1486**System capability**: SystemCapability.Multimedia.Audio.Core 1487 1488**Parameters** 1489 1490| Name| Description| 1491| -------- | -------- | 1492| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1493 1494**Required permissions** 1495 1496ohos.permission.MICROPHONE 1497 1498**Returns** 1499 1500Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1501 1502**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1503 1504**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1505 1506**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1507 1508 1509### OH_AudioCapturer_Release() 1510 1511``` 1512OH_AudioStream_Result OH_AudioCapturer_Release(OH_AudioCapturer *capturer) 1513``` 1514 1515**Description** 1516 1517Releases an audio capturer. 1518 1519**Since**: 10 1520 1521**System capability**: SystemCapability.Multimedia.Audio.Core 1522 1523**Parameters** 1524 1525| Name| Description| 1526| -------- | -------- | 1527| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1528 1529**Required permissions** 1530 1531ohos.permission.MICROPHONE 1532 1533**Returns** 1534 1535Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1536 1537**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1538 1539**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1540 1541**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1542 1543 1544### OH_AudioCapturer_Start() 1545 1546``` 1547OH_AudioStream_Result OH_AudioCapturer_Start(OH_AudioCapturer *capturer) 1548``` 1549 1550**Description** 1551 1552Starts an audio capturer. 1553 1554**Since**: 10 1555 1556**System capability**: SystemCapability.Multimedia.Audio.Core 1557 1558**Parameters** 1559 1560| Name| Description| 1561| -------- | -------- | 1562| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1563 1564**Required permissions** 1565 1566ohos.permission.MICROPHONE 1567 1568**Returns** 1569 1570Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1571 1572**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1573 1574**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1575 1576**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1577 1578 1579### OH_AudioCapturer_Stop() 1580 1581``` 1582OH_AudioStream_Result OH_AudioCapturer_Stop(OH_AudioCapturer *capturer) 1583``` 1584 1585**Description** 1586 1587Stops an audio capturer. 1588 1589**Since**: 10 1590 1591**System capability**: SystemCapability.Multimedia.Audio.Core 1592 1593**Parameters** 1594 1595| Name| Description| 1596| -------- | -------- | 1597| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 1598 1599**Required permissions** 1600 1601ohos.permission.MICROPHONE 1602 1603**Returns** 1604 1605Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1606 1607**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1608 1609**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **capturer** parameter is set to a null pointer. 1610 1611**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1612 1613 1614### OH_AudioDeviceDescriptor_GetDeviceAddress() 1615 1616``` 1617OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceAddress (OH_AudioDeviceDescriptor *audioDeviceDescriptor, char **address) 1618``` 1619 1620**Description** 1621 1622Obtains the device address based on an audio device descriptor. 1623 1624**Since**: 12 1625 1626**Parameters** 1627 1628| Name| Description| 1629| -------- | -------- | 1630| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1631| address | Double pointer to the MAC address of the device. Do not release the pointer to the MAC address separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1632 1633**Returns** 1634 1635Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1636 1637 1638### OH_AudioDeviceDescriptor_GetDeviceChannelCounts() 1639 1640``` 1641OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceChannelCounts (OH_AudioDeviceDescriptor *audioDeviceDescriptor, uint32_t **channelCounts, uint32_t *size) 1642``` 1643 1644**Description** 1645 1646Obtains an array that holds the number of device channels based on an audio device descriptor. 1647 1648**Since**: 12 1649 1650**Parameters** 1651 1652| Name| Description| 1653| -------- | -------- | 1654| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1655| channelCounts | Double pointer to the array that holds the channel counts. Do not release the pointer to the channel counts separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1656| size | Pointer to the size of the array.| 1657 1658**Returns** 1659 1660Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1661 1662 1663### OH_AudioDeviceDescriptor_GetDeviceDisplayName() 1664 1665``` 1666OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceDisplayName (OH_AudioDeviceDescriptor *audioDeviceDescriptor, char **displayName) 1667``` 1668 1669**Description** 1670 1671Obtains the device display name based on an audio device descriptor. 1672 1673**Since**: 12 1674 1675**Parameters** 1676 1677| Name| Description| 1678| -------- | -------- | 1679| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1680| displayName | Double pointer to the display name. Do not release the pointer to the display name separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1681 1682**Returns** 1683 1684Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1685 1686 1687### OH_AudioDeviceDescriptor_GetDeviceEncodingTypes() 1688 1689``` 1690OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceEncodingTypes (OH_AudioDeviceDescriptor *audioDeviceDescriptor, OH_AudioStream_EncodingType **encodingTypes, uint32_t *size) 1691``` 1692 1693**Description** 1694 1695Obtains the device encoding types based on an audio device descriptor. 1696 1697**Since**: 12 1698 1699**Parameters** 1700 1701| Name| Description| 1702| -------- | -------- | 1703| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1704| encodingTypes | Double pointer to the device encoding type. For details about the available options, see [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype). Do not release the pointer to the device encoding type separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1705| size | Pointer to the size of the device encoding type.| 1706 1707**Returns** 1708 1709Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1710 1711 1712### OH_AudioDeviceDescriptor_GetDeviceId() 1713 1714``` 1715OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceId (OH_AudioDeviceDescriptor *audioDeviceDescriptor, uint32_t *id) 1716``` 1717 1718**Description** 1719 1720Obtains the device ID based on an audio device descriptor. 1721 1722**Since**: 12 1723 1724**Parameters** 1725 1726| Name| Description| 1727| -------- | -------- | 1728| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1729| id | Pointer to the device ID, which is a variable for setting the device role.| 1730 1731**Returns** 1732 1733Returns **AUDIODEVICE_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1734 1735 1736### OH_AudioDeviceDescriptor_GetDeviceName() 1737 1738``` 1739OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceName (OH_AudioDeviceDescriptor *audioDeviceDescriptor, char **name ) 1740``` 1741 1742**Description** 1743 1744Obtains the device name based on an audio device descriptor. 1745 1746**Since**: 12 1747 1748**Parameters** 1749 1750| Name| Description| 1751| -------- | -------- | 1752| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1753| name | Double pointer to the device name. Do not release the pointer to the device name separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1754 1755**Returns** 1756 1757Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1758 1759 1760### OH_AudioDeviceDescriptor_GetDeviceRole() 1761 1762``` 1763OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceRole (OH_AudioDeviceDescriptor *audioDeviceDescriptor, OH_AudioDevice_Role *deviceRole) 1764``` 1765 1766**Description** 1767 1768Obtains the device role based on an audio device descriptor. 1769 1770**Since**: 12 1771 1772**Parameters** 1773 1774| Name| Description| 1775| -------- | -------- | 1776| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1777| deviceRole | Pointer to the device role. For details about the available options, see [OH_AudioDevice_Role](#oh_audiodevice_role).| 1778 1779**Returns** 1780 1781Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1782 1783 1784### OH_AudioDeviceDescriptor_GetDeviceSampleRates() 1785 1786``` 1787OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceSampleRates (OH_AudioDeviceDescriptor *audioDeviceDescriptor, uint32_t **sampleRates, uint32_t *size) 1788``` 1789 1790**Description** 1791 1792Obtains the sample rates based on an audio device descriptor. 1793 1794**Since**: 12 1795 1796**Parameters** 1797 1798| Name| Description| 1799| -------- | -------- | 1800| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1801| sampleRates | Double pointer to the array of sample rates. Do not release the pointer to the sample rates separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release all the device descriptors when they are no longer needed.| 1802| size | Pointer to the size of the array.| 1803 1804**Returns** 1805 1806Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1807 1808 1809### OH_AudioDeviceDescriptor_GetDeviceType() 1810 1811``` 1812OH_AudioCommon_Result OH_AudioDeviceDescriptor_GetDeviceType (OH_AudioDeviceDescriptor *audioDeviceDescriptor, OH_AudioDevice_Type *deviceType) 1813``` 1814 1815**Description** 1816 1817Obtains the device type based on an audio device descriptor. 1818 1819**Since**: 12 1820 1821**Parameters** 1822 1823| Name| Description| 1824| -------- | -------- | 1825| audioDeviceDescriptor | Pointer to an audio device descriptor, which is obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices) or [OH_AudioRouterManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 1826| deviceType | Pointer to the device type. For details about the available options, see [OH_AudioDevice_Type](#oh_audiodevice_type). | 1827 1828**Returns** 1829 1830Returns **AUDIOCOMMON_RESULT_SUCCESS** if the operation is successful; returns **AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM** otherwise. 1831 1832 1833### OH_AudioManager_GetAudioRoutingManager() 1834 1835``` 1836OH_AudioCommon_Result OH_AudioManager_GetAudioRoutingManager (OH_AudioRoutingManager **audioRoutingManager) 1837``` 1838 1839**Description** 1840 1841Obtains the handle to an audio routing manager. The handle should be set as the first parameter in the routing-related functions. 1842 1843**Since**: 12 1844 1845**Parameters** 1846 1847| Name| Description| 1848| -------- | -------- | 1849| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) object. | 1850 1851**Returns** 1852 1853Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 1854 1855**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1856 1857 1858### OH_AudioManager_GetAudioSessionManager() 1859 1860``` 1861OH_AudioCommon_Result OH_AudioManager_GetAudioSessionManager (OH_AudioSessionManager **audioSessionManager) 1862``` 1863 1864**Description** 1865 1866Obtains an **OH_AudioSessionManager** instance. 1867 1868Before using the features related to the audio session manager, you must obtain an **OH_AudioSessionManager** instance. 1869 1870**Since**: 12 1871 1872**Parameters** 1873 1874| Name| Description| 1875| -------- | -------- | 1876| audioSessionManager | Double pointer to the [OH_AudioSessionManager](#oh_audiosessionmanager) instance obtained.| 1877 1878**Returns** 1879 1880Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 1881 1882**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1883 1884 1885### OH_AudioRenderer_CancelMark() 1886 1887``` 1888OH_AudioStream_Result OH_AudioRenderer_CancelMark (OH_AudioRenderer *renderer) 1889``` 1890 1891**Description** 1892 1893Cancels the mark set by [OH_AudioRenderer_SetMarkPosition](#oh_audiorenderer_setmarkposition). 1894 1895**Since**: 12 1896 1897**System capability**: SystemCapability.Multimedia.Audio.Core 1898 1899**Parameters** 1900 1901| Name| Description| 1902| -------- | -------- | 1903| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 1904 1905**Returns** 1906 1907Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1908 1909**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1910 1911**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 1912 1913 1914### OH_AudioRenderer_Flush() 1915 1916``` 1917OH_AudioStream_Result OH_AudioRenderer_Flush(OH_AudioRenderer *renderer) 1918``` 1919 1920**Description** 1921 1922Flushes written audio data. 1923 1924**Since**: 10 1925 1926**System capability**: SystemCapability.Multimedia.Audio.Core 1927 1928**Parameters** 1929 1930| Name| Description| 1931| -------- | -------- | 1932| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 1933 1934**Returns** 1935 1936Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1937 1938**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1939 1940**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 1941 1942**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 1943 1944 1945### OH_AudioRenderer_GetChannelCount() 1946 1947``` 1948OH_AudioStream_Result OH_AudioRenderer_GetChannelCount(OH_AudioRenderer *renderer, int32_t *channelCount) 1949``` 1950 1951**Description** 1952 1953Obtains the number of channels for an audio renderer. 1954 1955**Since**: 10 1956 1957**System capability**: SystemCapability.Multimedia.Audio.Core 1958 1959**Parameters** 1960 1961| Name| Description| 1962| -------- | -------- | 1963| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 1964| channelCount | Pointer to a variable used to receive the number of channels. | 1965 1966**Returns** 1967 1968Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1969 1970**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 1971 1972**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 1973 1974 1975### OH_AudioRenderer_GetChannelLayout() 1976 1977``` 1978OH_AudioStream_Result OH_AudioRenderer_GetChannelLayout (OH_AudioRenderer *renderer, OH_AudioChannelLayout *channelLayout) 1979``` 1980 1981**Description** 1982 1983Obtains the channel layout of an audio stream. 1984 1985**Since**: 12 1986 1987**System capability**: SystemCapability.Multimedia.Audio.Core 1988 1989**Parameters** 1990 1991| Name| Description| 1992| -------- | -------- | 1993| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 1994| channelLayout | Pointer to a variable used to receive the channel layout. For details about the available options, see [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1). | 1995 1996**Returns** 1997 1998Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 1999 2000**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2001 2002**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2003 2004 2005### OH_AudioRenderer_GetCurrentState() 2006 2007``` 2008OH_AudioStream_Result OH_AudioRenderer_GetCurrentState(OH_AudioRenderer *renderer, OH_AudioStream_State *state) 2009``` 2010 2011**Description** 2012 2013Obtains the state of an audio renderer. 2014 2015**Since**: 10 2016 2017**System capability**: SystemCapability.Multimedia.Audio.Core 2018 2019**Parameters** 2020 2021| Name| Description| 2022| -------- | -------- | 2023| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2024| state | Pointer to a variable used to receive the state. | 2025 2026**Returns** 2027 2028Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2029 2030**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2031 2032**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2033 2034 2035### OH_AudioRenderer_GetEffectMode() 2036 2037``` 2038OH_AudioStream_Result OH_AudioRenderer_GetEffectMode (OH_AudioRenderer *renderer, OH_AudioStream_AudioEffectMode *effectMode) 2039``` 2040 2041**Description** 2042 2043Obtains the effect mode of an audio stream. 2044 2045**Since**: 12 2046 2047**System capability**: SystemCapability.Multimedia.Audio.Core 2048 2049**Parameters** 2050 2051| Name| Description| 2052| -------- | -------- | 2053| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2054| effectMode | Pointer to a variable used to receive the effect mode. | 2055 2056**Returns** 2057 2058Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2059 2060**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2061 2062**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2063 2064 2065### OH_AudioRenderer_GetEncodingType() 2066 2067``` 2068OH_AudioStream_Result OH_AudioRenderer_GetEncodingType(OH_AudioRenderer *renderer, OH_AudioStream_EncodingType *encodingType) 2069``` 2070 2071**Description** 2072 2073Obtains the encoding type of an audio renderer. 2074 2075**Since**: 10 2076 2077**System capability**: SystemCapability.Multimedia.Audio.Core 2078 2079**Parameters** 2080 2081| Name| Description| 2082| -------- | -------- | 2083| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2084| encodingType | Pointer to a variable used to receive the encoding type. | 2085 2086**Returns** 2087 2088Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2089 2090**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2091 2092**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2093 2094 2095### OH_AudioRenderer_GetFrameSizeInCallback() 2096 2097``` 2098OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer *renderer, int32_t *frameSize) 2099``` 2100 2101**Description** 2102 2103Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback. 2104 2105**Since**: 10 2106 2107**System capability**: SystemCapability.Multimedia.Audio.Core 2108 2109**Parameters** 2110 2111| Name| Description| 2112| -------- | -------- | 2113| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2114| frameSize | Pointer to the variable that holds the frame size. | 2115 2116**Returns** 2117 2118Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2119 2120**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2121 2122**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2123 2124 2125### OH_AudioRenderer_GetFramesWritten() 2126 2127``` 2128OH_AudioStream_Result OH_AudioRenderer_GetFramesWritten(OH_AudioRenderer *renderer, int64_t *frames) 2129``` 2130 2131**Description** 2132 2133Obtains the number of frames that have been written since the stream was created. 2134 2135**Since**: 10 2136 2137**System capability**: SystemCapability.Multimedia.Audio.Core 2138 2139**Parameters** 2140 2141| Name| Description| 2142| -------- | -------- | 2143| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2144| frames | Pointer to the variable that holds the frame count. | 2145 2146**Returns** 2147 2148Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2149 2150**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2151 2152**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2153 2154 2155### OH_AudioRenderer_GetLatencyMode() 2156 2157``` 2158OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode(OH_AudioRenderer *renderer, OH_AudioStream_LatencyMode *latencyMode) 2159``` 2160 2161**Description** 2162 2163Obtains the latency mode of an audio renderer. 2164 2165**Since**: 10 2166 2167**System capability**: SystemCapability.Multimedia.Audio.Core 2168 2169**Parameters** 2170 2171| Name| Description| 2172| -------- | -------- | 2173| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2174| latencyMode | Pointer to a variable used to receive the latency mode. | 2175 2176**Returns** 2177 2178Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2179 2180**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2181 2182**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2183 2184 2185### OH_AudioRenderer_GetRendererInfo() 2186 2187``` 2188OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo(OH_AudioRenderer *renderer, OH_AudioStream_Usage *usage) 2189``` 2190 2191**Description** 2192 2193Obtains the usage scenario of an audio renderer. 2194 2195**Since**: 10 2196 2197**System capability**: SystemCapability.Multimedia.Audio.Core 2198 2199**Parameters** 2200 2201| Name| Description| 2202| -------- | -------- | 2203| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2204| usage | Pointer to a variable used to receive the usage scenario. | 2205 2206**Returns** 2207 2208Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2209 2210**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2211 2212**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2213 2214 2215### OH_AudioRenderer_GetRendererPrivacy() 2216 2217``` 2218OH_AudioStream_Result OH_AudioRenderer_GetRendererPrivacy (OH_AudioRenderer *renderer, OH_AudioStream_PrivacyType *privacy) 2219``` 2220 2221**Description** 2222 2223Checks whether the audio stream being played can be recorded by other applications. 2224 2225**Since**: 12 2226 2227**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture 2228 2229**Parameters** 2230 2231| Name| Description| 2232| -------- | -------- | 2233| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2234| privacy | Pointer to the privacy type, which specifies whether the audio stream being played can be recorded by other applications. | 2235 2236**Returns** 2237 2238Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2239 2240**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2241 2242**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2243 2244 2245### OH_AudioRenderer_GetSampleFormat() 2246 2247``` 2248OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat(OH_AudioRenderer *renderer, OH_AudioStream_SampleFormat *sampleFormat) 2249``` 2250 2251**Description** 2252 2253Obtains the sampling format of an audio renderer. 2254 2255**Since**: 10 2256 2257**System capability**: SystemCapability.Multimedia.Audio.Core 2258 2259**Parameters** 2260 2261| Name| Description| 2262| -------- | -------- | 2263| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2264| sampleFormat | Pointer to a variable used to receive the sampling format. | 2265 2266**Returns** 2267 2268Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2269 2270**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2271 2272**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2273 2274 2275### OH_AudioRenderer_GetSamplingRate() 2276 2277``` 2278OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate(OH_AudioRenderer *renderer, int32_t *rate) 2279``` 2280 2281**Description** 2282 2283Obtains the sampling rate of an audio renderer. 2284 2285**Since**: 10 2286 2287**System capability**: SystemCapability.Multimedia.Audio.Core 2288 2289**Parameters** 2290 2291| Name| Description| 2292| -------- | -------- | 2293| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2294| rate | Pointer to a variable used to receive the sampling rate. | 2295 2296**Returns** 2297 2298Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2299 2300**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2301 2302**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2303 2304 2305### OH_AudioRenderer_GetSilentModeAndMixWithOthers() 2306 2307``` 2308OH_AudioStream_Result OH_AudioRenderer_GetSilentModeAndMixWithOthers(OH_AudioRenderer *renderer, bool *on) 2309``` 2310 2311**Description** 2312 2313Checks whether the silent mode in concurrent playback is enabled for an audio stream. 2314 2315**Since**: 12 2316 2317**System capability**: SystemCapability.Multimedia.Audio.Core 2318 2319**Parameters** 2320 2321| Name| Description| 2322| -------- | -------- | 2323| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2324| on | Whether the silent mode in concurrent playback is enabled. | 2325 2326**Returns** 2327 2328Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2329 2330**AUDIOSTREAM_SUCCESS**: The function is executed successfully. 2331 2332**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2333 2334 2335 2336### OH_AudioRenderer_GetSpeed() 2337 2338``` 2339OH_AudioStream_Result OH_AudioRenderer_GetSpeed (OH_AudioRenderer * renderer, float * speed ) 2340``` 2341 2342**Description** 2343 2344Obtains the audio renderer rate. 2345 2346**Since**: 11 2347 2348**System capability**: SystemCapability.Multimedia.Audio.Core 2349 2350**Parameters** 2351 2352| Name| Description| 2353| -------- | -------- | 2354| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2355| speed | Pointer to the variable that receives the playback speed. | 2356 2357**Returns** 2358 2359Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2360 2361**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2362 2363**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2364 2365 2366### OH_AudioRenderer_GetStreamId() 2367 2368``` 2369OH_AudioStream_Result OH_AudioRenderer_GetStreamId(OH_AudioRenderer *renderer, uint32_t *streamId) 2370``` 2371 2372**Description** 2373 2374Obtains the stream ID of an audio renderer. 2375 2376**Since**: 10 2377 2378**System capability**: SystemCapability.Multimedia.Audio.Core 2379 2380**Parameters** 2381 2382| Name| Description| 2383| -------- | -------- | 2384| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2385| streamId | Pointer to a variable used to receive the stream ID. | 2386 2387**Returns** 2388 2389Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2390 2391**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2392 2393**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2394 2395 2396### OH_AudioRenderer_GetTimestamp() 2397 2398``` 2399OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer *renderer, clockid_t clockId, int64_t *framePosition, int64_t *timestamp) 2400``` 2401 2402**Description** 2403 2404Obtains the timestamp and position information of an audio output stream. 2405 2406**Since**: 10 2407 2408**System capability**: SystemCapability.Multimedia.Audio.Core 2409 2410**Parameters** 2411 2412| Name| Description| 2413| -------- | -------- | 2414| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2415| clockId | Clock identifier. Use **CLOCK_MONOTONIC**. | 2416| framePosition | Pointer to the variable that holds the position information. | 2417| timestamp | Pointer to the variable that holds the timestamp. | 2418 2419**Returns** 2420 2421Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2422 2423**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2424 2425**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2426 2427 1. The **renderer** parameter is set to a null pointer. 2428 2. The **clockId** parameter is set to an invalid value. 2429 2430**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2431 2432 2433### OH_AudioRenderer_GetUnderflowCount() 2434 2435``` 2436OH_AudioStream_Result OH_AudioRenderer_GetUnderflowCount (OH_AudioRenderer *renderer, uint32_t *count) 2437``` 2438 2439**Description** 2440 2441Obtains the number of underloaded audio streams of an audio capturer. 2442 2443**Since**: 12 2444 2445**Parameters** 2446 2447| Name| Description| 2448| -------- | -------- | 2449| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2450| count | Pointer to a variable used to receive the number of underloaded audio streams. | 2451 2452**Returns** 2453 2454Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2455 2456**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2457 2458**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2459 2460 1. The **renderer** parameter is set to a null pointer. 2461 2. The **count** parameter is set to a null pointer. 2462 2463 2464### OH_AudioRenderer_GetVolume() 2465 2466``` 2467OH_AudioStream_Result OH_AudioRenderer_GetVolume (OH_AudioRenderer *renderer, float *volume) 2468``` 2469 2470**Description** 2471 2472Obtains the volume of an audio stream. 2473 2474**System capability**: SystemCapability.Multimedia.Audio.Core 2475 2476**Since**: 12 2477 2478**Parameters** 2479 2480| Name| Description| 2481| -------- | -------- | 2482| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2483| volume | Pointer to the audio volume, in the range of [0.0, 1.0]. | 2484 2485**Returns** 2486 2487Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2488 2489**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2490 2491**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2492 2493 1. The **renderer** parameter is set to a null pointer. 2494 2. The **volume** parameter is set to a null pointer. 2495 2496 2497### OH_AudioRenderer_Pause() 2498 2499``` 2500OH_AudioStream_Result OH_AudioRenderer_Pause(OH_AudioRenderer *renderer) 2501``` 2502 2503**Description** 2504 2505Pauses an audio renderer. 2506 2507**Since**: 10 2508 2509**System capability**: SystemCapability.Multimedia.Audio.Core 2510 2511**Parameters** 2512 2513| Name| Description| 2514| -------- | -------- | 2515| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2516 2517**Returns** 2518 2519Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2520 2521**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2522 2523**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2524 2525**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2526 2527 2528### OH_AudioRenderer_Release() 2529 2530``` 2531OH_AudioStream_Result OH_AudioRenderer_Release(OH_AudioRenderer *renderer) 2532``` 2533 2534**Description** 2535 2536Releases an audio renderer. 2537 2538**Since**: 10 2539 2540**System capability**: SystemCapability.Multimedia.Audio.Core 2541 2542**Parameters** 2543 2544| Name| Description| 2545| -------- | -------- | 2546| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2547 2548**Returns** 2549 2550Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2551 2552**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2553 2554**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2555 2556**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2557 2558 2559### OH_AudioRenderer_SetDefaultOutputDevice() 2560 2561``` 2562OH_AudioStream_Result OH_AudioRenderer_SetDefaultOutputDevice (OH_AudioRenderer* renderer, OH_AudioDevice_Type deviceType) 2563``` 2564 2565**Description** 2566 2567Sets the default built-in audio output device. 2568 2569This function applies only to the scenario where [OH_AudioStream_Usage](#oh_audiostream_usage) is set to voice messages, VoIP voice calls, and VoIP video calls and the available device types are the receiver, speaker, and system default device. 2570 2571This function can be called at any time after an **AudioRenderer** instance is created. The system records the default built-in audio output device set by the application. When the application is started, if an external device such as a Bluetooth or wired headset is connected, the system preferentially uses the external device to play sound. Otherwise, the system uses this default device to play sound. 2572 2573**Since**: 12 2574 2575**System capability**: SystemCapability.Multimedia.Audio.Core 2576 2577**Since**: 12 2578 2579**Parameters** 2580 2581| Name| Description| 2582| -------- | -------- | 2583| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2584| deviceType | Device type. For details about the available options, see [OH_AudioDevice_Type](#oh_audiodevice_type).<br>The device types that can be set are as follows:<br>**AUDIO_DEVICE_TYPE_EARPIECE**: receiver.<br>**AUDIO_DEVICE_TYPE_SPEAKER**: speaker.<br>**AUDIO_DEVICE_TYPE_DEFAULT**: system default device. | 2585 2586**Returns** 2587 2588Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2589 2590**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2591 2592AUDIOSTREAM_ERROR_INVALID_PARAM: 2593 25941. The **renderer** parameter is set to a null pointer. 25952. The **deviceType** parameter is set to an invalid value. 2596 2597**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2598 2599**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. 2600 2601 2602### OH_AudioRenderer_SetEffectMode() 2603 2604``` 2605OH_AudioStream_Result OH_AudioRenderer_SetEffectMode (OH_AudioRenderer *renderer, OH_AudioStream_AudioEffectMode effectMode) 2606``` 2607 2608**Description** 2609 2610Sets the effect mode for an audio stream. 2611 2612**Since**: 12 2613 2614**System capability**: SystemCapability.Multimedia.Audio.Core 2615 2616**Parameters** 2617 2618| Name| Description| 2619| -------- | -------- | 2620| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2621| effectMode | Effect mode to set. | 2622 2623**Returns** 2624 2625Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2626 2627**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2628 2629**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2630 2631 2632### OH_AudioRenderer_SetMarkPosition() 2633 2634``` 2635OH_AudioStream_Result OH_AudioRenderer_SetMarkPosition (OH_AudioRenderer *renderer, uint32_t samplePos, OH_AudioRenderer_OnMarkReachedCallback callback, void *userData) 2636``` 2637 2638**Description** 2639 2640Sets the mark position for an audio renderer. When this function is called, the mark position that has been set will be overwritten. 2641 2642**Since**: 12 2643 2644**System capability**: SystemCapability.Multimedia.Audio.Core 2645 2646**Parameters** 2647 2648| Name| Description| 2649| -------- | -------- | 2650| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2651| samplePos | Mark position. | 2652| callback | When the target mark position is reached, [OH_AudioRenderer_OnMarkReachedCallback](#oh_audiorenderer_onmarkreachedcallback) is invoked. | 2653| userData | Pointer to the application data passed through the callback functions. | 2654 2655**Returns** 2656 2657Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2658 2659**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2660 2661**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2662 2663 1. The **renderer** parameter is set to a null pointer. 2664 2. The **samplePos** parameter is set to an invalid value. 2665 2666**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2667 2668**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. 2669 2670 2671### OH_AudioRenderer_SetSilentModeAndMixWithOthers() 2672 2673``` 2674OH_AudioStream_Result OH_AudioRenderer_SetSilentModeAndMixWithOthers (OH_AudioRenderer *renderer, bool on) 2675``` 2676 2677**Description** 2678 2679Sets the silent mode in concurrent playback for an audio stream. 2680 2681**Since**: 12 2682 2683**System capability**: SystemCapability.Multimedia.Audio.Core 2684 2685**Parameters** 2686 2687| Name| Description| 2688| -------- | -------- | 2689| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2690| on | Status of the silent mode in concurrent playback. **true**: The audio stream being played is muted and the playback of other audio streams is not interrupted. **false**: The audio stream being played is unmuted and can gain focus based on the system focus policy. | 2691 2692**Returns** 2693 2694Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2695 2696**AUDIOSTREAM_SUCCESS**: The function is executed successfully. 2697 2698**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2699 2700 2701### OH_AudioRenderer_SetSpeed() 2702 2703``` 2704OH_AudioStream_Result OH_AudioRenderer_SetSpeed (OH_AudioRenderer *renderer, float speed) 2705``` 2706 2707**Description** 2708 2709Sets the audio renderer rate. 2710 2711**Since**: 11 2712 2713**System capability**: SystemCapability.Multimedia.Audio.Core 2714 2715**Parameters** 2716 2717| Name| Description| 2718| -------- | -------- | 2719| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2720| speed | Playback speed, which ranges from 0.25 to 4.0. | 2721 2722**Returns** 2723 2724Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2725 2726**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2727 2728**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2729 2730 2731### OH_AudioRenderer_SetVolume() 2732 2733``` 2734OH_AudioStream_Result OH_AudioRenderer_SetVolume (OH_AudioRenderer *renderer, float volume) 2735``` 2736 2737**Description** 2738 2739Sets the volume for an audio stream. 2740 2741**System capability**: SystemCapability.Multimedia.Audio.Core 2742 2743**Since**: 12 2744 2745**Parameters** 2746 2747| Name| Description| 2748| -------- | -------- | 2749| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2750| volume | Target volume, in the range of [0.0, 1.0]. | 2751 2752**Returns** 2753 2754Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2755 2756**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2757 2758**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2759 2760 1. The **renderer** parameter is set to a null pointer. 2761 2. The **volume** parameter is set to an invalid value. 2762 2763**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2764 2765**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. 2766 2767 2768### OH_AudioRenderer_SetVolumeWithRamp() 2769 2770``` 2771OH_AudioStream_Result OH_AudioRenderer_SetVolumeWithRamp (OH_AudioRenderer *renderer, float volume, int32_t durationMs) 2772``` 2773 2774**Description** 2775 2776Sets the volume with a ramp within the specified duration for an audio stream. 2777 2778**System capability**: SystemCapability.Multimedia.Audio.Core 2779 2780**Since**: 12 2781 2782**Parameters** 2783 2784| Name| Description| 2785| -------- | -------- | 2786| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2787| volume | Target volume, in the range of [0.0, 1.0]. | 2788| durationMs | Duration, in milliseconds. | 2789 2790**Returns** 2791 2792Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2793 2794**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2795 2796**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2797 2798 1. The **renderer** parameter is set to a null pointer. 2799 2. The **volume** parameter is set to an invalid value. 2800 2801**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2802 2803**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. 2804 2805 2806### OH_AudioRenderer_Start() 2807 2808``` 2809OH_AudioStream_Result OH_AudioRenderer_Start(OH_AudioRenderer *renderer) 2810``` 2811 2812**Description** 2813 2814Starts an audio renderer. 2815 2816**Since**: 10 2817 2818**System capability**: SystemCapability.Multimedia.Audio.Core 2819 2820**Parameters** 2821 2822| Name| Description| 2823| -------- | -------- | 2824| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2825 2826**Returns** 2827 2828Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2829 2830**AUDIOSTREAM_SUCCESS**: The function is executed successfully. 2831 2832**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2833 2834**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2835 2836 2837### OH_AudioRenderer_Stop() 2838 2839``` 2840OH_AudioStream_Result OH_AudioRenderer_Stop(OH_AudioRenderer *renderer) 2841``` 2842 2843**Description** 2844 2845Stops an audio renderer. 2846 2847**Since**: 10 2848 2849**System capability**: SystemCapability.Multimedia.Audio.Core 2850 2851**Parameters** 2852 2853| Name| Description| 2854| -------- | -------- | 2855| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer). | 2856 2857**Returns** 2858 2859Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 2860 2861**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2862 2863**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **renderer** parameter is set to a null pointer. 2864 2865**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 2866 2867 2868### OH_AudioRoutingManager_GetAvailableDevices() 2869 2870``` 2871OH_AudioCommon_Result OH_AudioRoutingManager_GetAvailableDevices (OH_AudioRoutingManager *audioRoutingManager, OH_AudioDevice_Usage deviceUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray) 2872``` 2873 2874**Description** 2875 2876Obtains the available audio devices. 2877 2878**Since**: 12 2879 2880**Parameters** 2881 2882| Name| Description| 2883| -------- | -------- | 2884| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) instance, which is created by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager). | 2885| deviceUsage | Usage scenario of the audio devices. For details about the available options, see [OH_AudioDevice_Usage](#oh_audiodevice_usage). | 2886| audioDeviceDescriptorArray | Double pointer to the audio device descriptors in the array. For details, see [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md). Do not release the pointer to the **audioDeviceDescriptorArray** struct separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release the device descriptor array.| 2887 2888**Returns** 2889 2890Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 2891 2892**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2893 2894**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 28951. The **audioRoutingManager** parameter is set to a null pointer. 28962. The **deviceUsage** parameter is set to an invalid value. 28973. The **audioDeviceDescriptorArray** parameter is set to a null pointer. 2898 2899**AUDIOCOMMON_RESULT_ERROR_NO_MEMORY**: The memory is insufficient. 2900 2901 2902### OH_AudioRoutingManager_GetDevices() 2903 2904``` 2905OH_AudioCommon_Result OH_AudioRoutingManager_GetDevices (OH_AudioRoutingManager *audioRoutingManager, OH_AudioDevice_Flag deviceFlag, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray) 2906``` 2907 2908**Description** 2909 2910Obtains available devices based on the device flag. 2911 2912**Since**: 12 2913 2914**Parameters** 2915 2916| Name| Description| 2917| -------- | -------- | 2918| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) object. which is obtained by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager).| 2919| deviceFlag | Device flag, which is used to filter the target device. For details about the available options, see [OH_AudioDevice_Flag](#oh_audiodevice_flag).| 2920| audioDeviceDescriptorArray | Pointer to the audio device descriptor array, which is [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md). Do not release the pointer to the **audioDeviceDescriptorArray** struct separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release the **DeviceDescriptor** array.| 2921 2922**Returns** 2923 2924Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 2925 2926**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2927 2928**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2929 2930 1. The **audioRoutingManager** parameter is set to a null pointer. 2931 2. The **deviceFlag** parameter is set to an invalid value. 2932 3. The **audioDeviceDescriptorArray** parameter is set to a null pointer. 2933 2934**AUDIOCOMMON_RESULT_ERROR_NO_MEMORY**: The memory is insufficient. 2935 2936### OH_AudioRoutingManager_GetPreferredInputDevice() 2937 2938``` 2939OH_AudioCommon_Result OH_AudioRoutingManager_GetPreferredInputDevice (OH_AudioRoutingManager *audioRoutingManager, OH_AudioStream_SourceType sourceType, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray ) 2940``` 2941 2942**Description** 2943 2944Obtains the input device with the highest priority based on the usage scenario of an audio input stream. 2945 2946**Since**: 12 2947 2948**Parameters** 2949 2950| Name| Description| 2951| -------- | -------- | 2952| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) instance, which is created by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager). | 2953| sourceType | Usage scenario of an audio input stream. For details about the available options, see [OH_AudioStream_SourceType](#oh_audiostream_sourcetype). | 2954| audioDeviceDescriptorArray | Double pointer to the audio device descriptors in the array. For details, see [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md). Do not release the pointer to the **audioDeviceDescriptorArray** struct separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release the device descriptor array.| 2955 2956**Returns** 2957 2958Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 2959 2960**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2961 2962**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2963 29641. The **audioRoutingManager** parameter is set to a null pointer. 29652. The **sourceType** parameter is set to an invalid value. 29663. The **audioDeviceDescriptorArray** parameter is set to a null pointer. 2967 2968**AUDIOCOMMON_RESULT_ERROR_NO_MEMORY**: The memory is insufficient. 2969 2970 2971### OH_AudioRoutingManager_GetPreferredOutputDevice() 2972 2973``` 2974OH_AudioCommon_Result OH_AudioRoutingManager_GetPreferredOutputDevice (OH_AudioRoutingManager *audioRoutingManager, OH_AudioStream_Usage streamUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray ) 2975``` 2976 2977**Description** 2978 2979Obtains the output device with the highest priority based on the usage scenario of an audio output stream. 2980 2981**Since**: 12 2982 2983**Parameters** 2984 2985| Name| Description| 2986| -------- | -------- | 2987| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) instance, which is created by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager). | 2988| streamUsage | Usage scenario of an audio output stream. For details about the available options, see [OH_AudioStream_Usage](#oh_audiostream_usage). | 2989| audioDeviceDescriptorArray | Double pointer to the audio device descriptors in the array. For details, see [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md). Do not release the pointer to the **audioDeviceDescriptorArray** struct separately. Instead, call [OH_AudioRoutingManager_ReleaseDevices](#oh_audioroutingmanager_releasedevices) to release the device descriptor array.| 2990 2991**Returns** 2992 2993Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 2994 2995**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 2996 2997**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 2998 29991. The **audioRoutingManager** parameter is set to a null pointer. 30002. The **streamUsage** parameter is set to an invalid value. 30013. The **audioDeviceDescriptorArray** parameter is set to a null pointer. 3002 3003**AUDIOCOMMON_RESULT_ERROR_NO_MEMORY**: The memory is insufficient. 3004 3005 3006### OH_AudioRoutingManager_RegisterDeviceChangeCallback() 3007 3008``` 3009OH_AudioCommon_Result OH_AudioRoutingManager_RegisterDeviceChangeCallback (OH_AudioRoutingManager *audioRoutingManager, OH_AudioDevice_Flag deviceFlag, OH_AudioRoutingManager_OnDeviceChangedCallback callback) 3010``` 3011 3012 3013**Description** 3014 3015Registers a callback to listen for device changes of an audio routing manager. 3016 3017**Since**: 12 3018 3019**Parameters** 3020 3021| Name| Description| 3022| -------- | -------- | 3023| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) object. which is obtained by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager).| 3024| deviceFlag | Device flag. For details about the available options, see [OH_AudioDevice_Flag](#oh_audiodevice_flag).| 3025| callback | Callback function used to return the changed audio device descriptor. For details, see [OH_AudioRoutingManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 3026 3027**Returns** 3028 3029Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3030 3031**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3032 3033**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3034 3035 1. The **audioRoutingManager** parameter is set to a null pointer. 3036 2. The **deviceFlag** parameter is set to an invalid value. 3037 3. The **callback** parameter is set to a null pointer. 3038 3039 3040### OH_AudioRoutingManager_ReleaseDevices() 3041 3042``` 3043OH_AudioCommon_Result OH_AudioRoutingManager_ReleaseDevices (OH_AudioRoutingManager *audioRoutingManager, OH_AudioDeviceDescriptorArray *audioDeviceDescriptorArray) 3044``` 3045 3046**Description** 3047 3048Releases audio devices available for an audio routing manager. 3049 3050**Since**: 12 3051 3052**Parameters** 3053 3054| Name| Description| 3055| -------- | -------- | 3056| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) object. which is obtained by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager).| 3057| audioDeviceDescriptorArray | Pointer to the array of audio devices, which are obtained by calling [OH_AudioRoutingManager_GetDevices](#oh_audioroutingmanager_getdevices).| 3058 3059**Returns** 3060 3061Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3062 3063**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3064 3065**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3066 3067 1. The **audioRoutingManager** parameter is set to a null pointer. 3068 2. The **audioDeviceDescriptorArray** parameter is set to a null pointer. 3069 3070 3071### OH_AudioRoutingManager_UnregisterDeviceChangeCallback() 3072 3073``` 3074OH_AudioCommon_Result OH_AudioRoutingManager_UnregisterDeviceChangeCallback (OH_AudioRoutingManager *audioRoutingManager, OH_AudioRoutingManager_OnDeviceChangedCallback callback) 3075``` 3076 3077**Description** 3078 3079Unregisters the callback used to listen for device changes of an audio routing manager. 3080 3081**Since**: 12 3082 3083**Parameters** 3084 3085| Name| Description| 3086| -------- | -------- | 3087| audioRoutingManager | Pointer to an [OH_AudioRoutingManager](#oh_audioroutingmanager) object. which is obtained by calling [OH_AudioManager_GetAudioRoutingManager](#oh_audiomanager_getaudioroutingmanager).| 3088| callback | Callback function used to return the changed audio device descriptor. For details, see [OH_AudioRoutingManager_OnDeviceChangedCallback](#oh_audioroutingmanager_ondevicechangedcallback).| 3089 3090**Returns** 3091 3092Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3093 3094**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3095 3096**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3097 3098 1. The **audioRoutingManager** parameter is set to a null pointer. 3099 2. The **callback** parameter is set to a null pointer. 3100 3101 3102### OH_AudioSessionManager_ActivateAudioSession() 3103 3104``` 3105OH_AudioCommon_Result OH_AudioSessionManager_ActivateAudioSession (OH_AudioSessionManager *audioSessionManager, const OH_AudioSession_Strategy *strategy ) 3106``` 3107 3108**Description** 3109 3110Activates an audio session. 3111 3112**Since**: 12 3113 3114**Parameters** 3115 3116| Name| Description| 3117| -------- | -------- | 3118| audioSessionManager | Pointer to an [OH_AudioSessionManager](#oh_audiosessionmanager) instance, which is created by calling [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager). | 3119| strategy | Pointer to a session strategy. For details about the available options, see [OH_AudioSession_Strategy](_o_h___audio_session___strategy.md). | 3120 3121**Returns** 3122 3123Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3124 3125**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3126 3127**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3128 31291. The **audioSessionManager** parameter is set to a null pointer. 31302. The **strategy** parameter is set to an invalid value. **AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE**: Invalid state. 3131 3132 3133### OH_AudioSessionManager_DeactivateAudioSession() 3134 3135``` 3136OH_AudioCommon_Result OH_AudioSessionManager_DeactivateAudioSession (OH_AudioSessionManager *audioSessionManager) 3137``` 3138 3139**Description** 3140 3141Deactivates an audio session. 3142 3143**Since**: 12 3144 3145**Parameters** 3146 3147| Name| Description| 3148| -------- | -------- | 3149| audioSessionManager | Pointer to an [OH_AudioSessionManager](#oh_audiosessionmanager) instance, which is created by calling [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager). | 3150 3151**Returns** 3152 3153Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3154 3155**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3156 3157**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **audioSessionManager** parameter is set to a null pointer. 3158 3159**AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE**: Invalid state. 3160 3161 3162### OH_AudioSessionManager_IsAudioSessionActivated() 3163 3164``` 3165bool OH_AudioSessionManager_IsAudioSessionActivated (OH_AudioSessionManager *audioSessionManager) 3166``` 3167 3168**Description** 3169 3170Checks whether an audio session is activated. 3171 3172**Since**: 12 3173 3174**Parameters** 3175 3176| Name| Description| 3177| -------- | -------- | 3178| audioSessionManager | Pointer to an [OH_AudioSessionManager](#oh_audiosessionmanager) instance, which is created by calling [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager). | 3179 3180**Returns** 3181 3182Returns **true** if the audio session is activated; returns **false** otherwise. 3183 3184 3185### OH_AudioSessionManager_RegisterSessionDeactivatedCallback() 3186 3187``` 3188OH_AudioCommon_Result OH_AudioSessionManager_RegisterSessionDeactivatedCallback (OH_AudioSessionManager *audioSessionManager, OH_AudioSession_DeactivatedCallback callback) 3189``` 3190 3191**Description** 3192 3193Registers a callback to listen for audio session deactivation events. 3194 3195**Since**: 12 3196 3197**Parameters** 3198 3199| Name| Description| 3200| -------- | -------- | 3201| audioSessionManager | Pointer to an [OH_AudioSessionManager](#oh_audiosessionmanager) instance, which is created by calling [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager). | 3202| callback | Callback used to receive the audio session deactivation event. For details, see [OH_AudioSessionDeactivatedCallback](#oh_audiosession_deactivatedcallback). | 3203 3204**Returns** 3205 3206Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3207 3208**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3209 3210**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3211 32121. The **audioSessionManager** parameter is set to a null pointer. 32132. The **callback** parameter is set to a null pointer. 3214 3215 3216### OH_AudioSessionManager_UnregisterSessionDeactivatedCallback() 3217 3218``` 3219OH_AudioCommon_Result OH_AudioSessionManager_UnregisterSessionDeactivatedCallback (OH_AudioSessionManager *audioSessionManager, OH_AudioSession_DeactivatedCallback callback) 3220``` 3221 3222**Description** 3223 3224Unregisters the callback used to listen for audio session deactivation events. 3225 3226**Since**: 12 3227 3228**Parameters** 3229 3230| Name| Description| 3231| -------- | -------- | 3232| audioSessionManager | Pointer to an [OH_AudioSessionManager](#oh_audiosessionmanager) instance, which is created by calling [OH_AudioManager_GetAudioSessionManager](#oh_audiomanager_getaudiosessionmanager). | 3233| callback | Callback used to receive the audio session deactivation event. For details, see [OH_AudioSessionDeactivatedCallback](#oh_audiosession_deactivatedcallback). | 3234 3235**Returns** 3236 3237Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3238 3239**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3240 3241**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3242 32431. The **audioSessionManager** parameter is set to a null pointer. 32442. The **callback** parameter is set to a null pointer. 3245 3246 3247### OH_AudioStreamBuilder_Create() 3248 3249``` 3250OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder **builder, OH_AudioStream_Type type) 3251``` 3252 3253**Description** 3254 3255Creates an audio stream builder, which can be an audio renderer or capturer. 3256 3257You need to call **OH_AudioStreamBuilder_Destroy()** to destroy the builder when it is no longer required. 3258 3259**Since**: 10 3260 3261**System capability**: SystemCapability.Multimedia.Audio.Core 3262 3263**Parameters** 3264 3265| Name| Description| 3266| -------- | -------- | 3267| builder | Double pointer to the audio stream builder created. | 3268| type | Type of the audio stream builder,AUDIOSTREAM_TYPE_RENDERER or AUDIOSTREAM_TYPE_CAPTURER | 3269 3270**Returns** 3271 3272Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3273 3274**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3275 3276 3277### OH_AudioStreamBuilder_Destroy() 3278 3279``` 3280OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder *builder) 3281``` 3282 3283**Description** 3284 3285Destroys an audio stream builder when it is no longer required. 3286 3287**Since**: 10 3288 3289**System capability**: SystemCapability.Multimedia.Audio.Core 3290 3291**Parameters** 3292 3293| Name| Description| 3294| -------- | -------- | 3295| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3296 3297**Returns** 3298 3299Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3300 3301**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3302 3303**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3304 3305**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. 3306 3307 3308### OH_AudioStreamBuilder_GenerateCapturer() 3309 3310``` 3311OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder *builder, OH_AudioCapturer **audioCapturer) 3312``` 3313 3314**Description** 3315 3316Creates an audio capturer instance. 3317 3318**Since**: 10 3319 3320**System capability**: SystemCapability.Multimedia.Audio.Core 3321 3322**Parameters** 3323 3324| Name| Description| 3325| -------- | -------- | 3326| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3327| audioCapturer | Double pointer to the audio capturer instance created. | 3328 3329**Returns** 3330 3331Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3332 3333**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3334 3335**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3336 3337 1. The **builder** parameter is set to a null pointer. 3338 2. The **StreamType** parameter is set to an invalid value. 3339 3. The **OHAudioRenderer** instance fails to be created. 3340 3341 3342### OH_AudioStreamBuilder_GenerateRenderer() 3343 3344``` 3345OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder *builder, OH_AudioRenderer **audioRenderer) 3346``` 3347 3348**Description** 3349 3350Creates an audio renderer instance. 3351 3352**Since**: 10 3353 3354**System capability**: SystemCapability.Multimedia.Audio.Core 3355 3356**Parameters** 3357 3358| Name| Description| 3359| -------- | -------- | 3360| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3361| audioRenderer | Double pointer to the audio renderer instance created. | 3362 3363**Returns** 3364 3365Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3366 3367**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3368 3369**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3370 3371 1. The **builder** parameter is set to a null pointer. 3372 2. The **StreamType** parameter is set to an invalid value. 3373 3. The **OHAudioRenderer** instance fails to be created. 3374 3375 3376### OH_AudioStreamBuilder_SetCapturerCallback() 3377 3378``` 3379OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder *builder, OH_AudioCapturer_Callbacks callbacks, void *userData) 3380``` 3381 3382**Description** 3383 3384Sets callbacks for an audio capturer. 3385 3386**Since**: 10 3387 3388**System capability**: SystemCapability.Multimedia.Audio.Core 3389 3390**Parameters** 3391 3392| Name| Description| 3393| -------- | -------- | 3394| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3395| callbacks | Callback functions that will be used to process events related to audio input streams. | 3396| userData | Pointer to the application data passed through the callback functions. | 3397 3398**Returns** 3399 3400Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3401 3402**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3403 3404**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3405 3406 1. The **builder** parameter is set to a null pointer. 3407 2. The **StreamType** parameter is set to an invalid value. 3408 3409 3410### OH_AudioStreamBuilder_SetCapturerInfo() 3411 3412``` 3413OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder *builder, OH_AudioStream_SourceType sourceType) 3414``` 3415 3416**Description** 3417 3418Sets the usage scenario of an audio capturer. 3419 3420**Since**: 10 3421 3422**System capability**: SystemCapability.Multimedia.Audio.Core 3423 3424**Parameters** 3425 3426| Name| Description| 3427| -------- | -------- | 3428| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3429| sourceType | Usage scenario of the audio capturer. | 3430 3431**Returns** 3432 3433Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3434 3435**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3436 3437**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3438 3439 1. The **builder** parameter is set to a null pointer. 3440 2. The **sourceType** parameter is set to an invalid value. 3441 3442 3443### OH_AudioStreamBuilder_SetChannelCount() 3444 3445``` 3446OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder *builder, int32_t channelCount) 3447``` 3448 3449**Description** 3450 3451Sets the number of channels for an audio stream. 3452 3453**Since**: 10 3454 3455**System capability**: SystemCapability.Multimedia.Audio.Core 3456 3457**Parameters** 3458 3459| Name| Description| 3460| -------- | -------- | 3461| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3462| channelCount | Number of channels. | 3463 3464**Returns** 3465 3466Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3467 3468**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3469 3470**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3471 3472 1. The **builder** parameter is set to a null pointer. 3473 2. The **channelCount** parameter is set to an invalid value. 3474 3475 3476### OH_AudioStreamBuilder_SetChannelLayout() 3477 3478``` 3479OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelLayout (OH_AudioStreamBuilder *builder, OH_AudioChannelLayout channelLayout) 3480``` 3481 3482**Description** 3483 3484Sets the channel layout for an audio stream. 3485 3486**Since**: 12 3487 3488**System capability**: SystemCapability.Multimedia.Audio.Core 3489 3490**Parameters** 3491 3492| Name| Description| 3493| -------- | -------- | 3494| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3495| channelLayout | Channel layout. For details about the available options, see [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1). | 3496 3497**Returns** 3498 3499Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3500 3501**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3502 3503**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3504 3505 3506### OH_AudioStreamBuilder_SetEncodingType() 3507 3508``` 3509OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder *builder, OH_AudioStream_EncodingType encodingType) 3510``` 3511 3512**Description** 3513 3514Sets the encoding type of an audio stream. 3515 3516**Since**: 10 3517 3518**System capability**: SystemCapability.Multimedia.Audio.Core 3519 3520**Parameters** 3521 3522| Name| Description| 3523| -------- | -------- | 3524| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**.| 3525| encodingType | Encoding type.| 3526 3527**Returns** 3528 3529Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3530 3531**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3532 3533**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3534 3535### OH_AudioStreamBuilder_SetFrameSizeInCallback() 3536 3537``` 3538OH_AudioStream_Result OH_AudioStreamBuilder_SetFrameSizeInCallback(OH_AudioStreamBuilder *builder, int32_t frameSize) 3539``` 3540 3541**Description** 3542 3543Sets the frame size for each callback during playback. The frame size must be at least equal to the size of the data processed by the audio hardware at a time and less than half of the internal buffer capacity. 3544 3545- In the case of low-latency playback, **frameSize** can be set to the frame length corresponding to the audio that lasts for 5 ms, 10 ms, 15 ms, or 20 ms. 3546- In the case of common playback, **frameSize** can be set to the frame length corresponding to the audio that lasts for 20 ms to 100 ms. 3547 3548**Since**: 11 3549 3550**System capability**: SystemCapability.Multimedia.Audio.Core 3551 3552**Parameters** 3553 3554| Name| Description| 3555| -------- | -------- | 3556| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3557| frameSize | Frame size. | 3558 3559**Returns** 3560 3561Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3562 3563**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3564 3565**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3566 3567 3568### OH_AudioStreamBuilder_SetLatencyMode() 3569 3570``` 3571OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder *builder, OH_AudioStream_LatencyMode latencyMode) 3572``` 3573 3574**Description** 3575 3576Sets the latency mode of an audio stream. 3577 3578**Since**: 10 3579 3580**System capability**: SystemCapability.Multimedia.Audio.Core 3581 3582**Parameters** 3583 3584| Name| Description| 3585| -------- | -------- | 3586| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3587| latencyMode | Latency mode. | 3588 3589**Returns** 3590 3591Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3592 3593**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3594 3595**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3596 3597 3598### OH_AudioStreamBuilder_SetRendererCallback() 3599 3600``` 3601OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder *builder, OH_AudioRenderer_Callbacks callbacks, void *userData) 3602``` 3603 3604**Description** 3605 3606Sets callbacks for an audio renderer. 3607 3608**Since**: 10 3609 3610**System capability**: SystemCapability.Multimedia.Audio.Core 3611 3612**Parameters** 3613 3614| Name| Description| 3615| -------- | -------- | 3616| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3617| callbacks | Callback functions that will be used to process events related to audio output streams. | 3618| userData | Pointer to the application data passed through the callback functions. | 3619 3620**Returns** 3621 3622Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3623 3624**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3625 3626**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3627 3628 1. The **builder** parameter is set to a null pointer. 3629 2. The **StreamType** parameter is set to an invalid value. 3630 3631 3632### OH_AudioStreamBuilder_SetRendererInfo() 3633 3634``` 3635OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder *builder, OH_AudioStream_Usage usage) 3636``` 3637 3638**Description** 3639 3640Sets the usage scenario of an audio renderer. 3641 3642**Since**: 10 3643 3644**System capability**: SystemCapability.Multimedia.Audio.Core 3645 3646**Parameters** 3647 3648| Name| Description| 3649| -------- | -------- | 3650| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3651| usage | Usage scenario of the audio renderer. | 3652 3653**Returns** 3654 3655Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3656 3657**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3658 3659**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3660 3661 1. The **builder** parameter is set to a null pointer. 3662 2. The **usage** parameter is set to an invalid value. 3663 3664 3665### OH_AudioStreamBuilder_SetRendererInterruptMode() 3666 3667``` 3668OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptMode (OH_AudioStreamBuilder *builder, OH_AudioInterrupt_Mode mode) 3669``` 3670 3671**Description** 3672 3673Sets the interrupt mode of the stream client. 3674 3675**Since**: 12 3676 3677**System capability**: SystemCapability.Multimedia.Audio.Core 3678 3679**Parameters** 3680 3681| Name| Description| 3682| -------- | -------- | 3683| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3684| mode | Audio interruption mode. For details about the available options, see [OH_AudioInterrupt_Mode](#oh_audiointerrupt_mode). | 3685 3686**Returns** 3687 3688Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3689 3690**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3691 3692**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3693 3694 1. The **builder** parameter is set to a null pointer. 3695 2. The **mode** parameter is set to an invalid value. 3696 3. The **StreamType** parameter is set to an invalid value. 3697 3698 3699### OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback() 3700 3701``` 3702OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback (OH_AudioStreamBuilder * builder, OH_AudioRenderer_OutputDeviceChangeCallback callback, void * userData ) 3703``` 3704 3705**Description** 3706 3707Sets the callback invoked when the audio stream device changes. 3708 3709**Since**: 11 3710 3711**System capability**: SystemCapability.Multimedia.Audio.Core 3712 3713**Parameters** 3714 3715| Name| Description| 3716| -------- | -------- | 3717| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3718| callbacks | Callback that will be used to process events related to audio stream device changes. | 3719| userData | Pointer to the application data passed through the callback functions. | 3720 3721**Returns** 3722 3723Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3724 3725**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3726 3727**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3728 3729 1. The **builder** parameter is set to a null pointer. 3730 2. The **StreamType** parameter is set to an invalid value. 3731 3732 3733### OH_AudioStreamBuilder_SetRendererPrivacy() 3734 3735``` 3736OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererPrivacy (OH_AudioStreamBuilder * builder, OH_AudioStream_PrivacyType privacy) 3737``` 3738 3739**Description** 3740 3741Sets the privacy type for the audio stream being played. The privacy type specifies whether the audio stream can be recorded by other applications. 3742 3743**Since**: 12 3744 3745**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture 3746 3747**Parameters** 3748 3749| Name| Description| 3750| -------- | -------- | 3751| builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create()](#oh_audiostreambuilder_create). | 3752| privacy | Privacy type, which specifies whether the audio stream can be recorded by other applications. | 3753 3754**Returns** 3755 3756Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3757 3758**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3759 3760**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3761 3762 1. The **builder** parameter is set to a null pointer. 3763 2. The **StreamType** parameter is set to an invalid value. 3764 3765 3766### OH_AudioStreamBuilder_SetRendererWriteDataCallback() 3767 3768``` 3769OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallback (OH_AudioStreamBuilder *builder, OH_AudioRenderer_OnWriteDataCallback callback, void *userData) 3770``` 3771 3772**Description** 3773 3774Sets the callback used to write audio data. 3775 3776This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). Only the last callback function set through **OH_AudioStreamBuilder_SetRendererCallback** or this function can be invoked. 3777 3778**Since**: 12 3779 3780**System capability**: SystemCapability.Multimedia.Audio.Core 3781 3782**Parameters** 3783 3784| Name| Description| 3785| -------- | -------- | 3786| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3787| callback | Callback function to be used to write audio data. | 3788| userData | Pointer to the application data passed through the callback functions. | 3789 3790**Returns** 3791 3792Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3793 3794**AUDIOSTREAM_SUCCESS**: The function is executed successfully. 3795 3796**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3797 3798 1. The **builder** parameter is set to a null pointer. 3799 2. The **StreamType** parameter is set to an invalid value. 3800 3801 3802### OH_AudioStreamBuilder_SetSampleFormat() 3803 3804``` 3805OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder *builder, OH_AudioStream_SampleFormat format) 3806``` 3807 3808**Description** 3809 3810Sets the sampling format of an audio stream. 3811 3812**Since**: 10 3813 3814**System capability**: SystemCapability.Multimedia.Audio.Core 3815 3816**Parameters** 3817 3818| Name| Description| 3819| -------- | -------- | 3820| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3821| format | Sampling format. | 3822 3823**Returns** 3824 3825Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3826 3827**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3828 3829**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is set to a null pointer. 3830 3831 3832### OH_AudioStreamBuilder_SetSamplingRate() 3833 3834``` 3835OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder *builder, int32_t rate) 3836``` 3837 3838**Description** 3839 3840Sets the sampling rate of an audio stream. 3841 3842**Since**: 10 3843 3844**System capability**: SystemCapability.Multimedia.Audio.Core 3845 3846**Parameters** 3847 3848| Name| Description| 3849| -------- | -------- | 3850| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3851| channelCount | Sampling rate. | 3852 3853**Returns** 3854 3855Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3856 3857**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3858 3859**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3860 3861 1. The **builder** parameter is set to a null pointer. 3862 2. The **rate** parameter is set to an invalid value. 3863 3864 3865### OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback() 3866 3867``` 3868OH_AudioStream_Result OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback (OH_AudioStreamBuilder *builder, OH_AudioRenderer_WriteDataWithMetadataCallback callback, void *userData) 3869``` 3870 3871**Description** 3872 3873Sets the callback invoked to write both audio data and metadata. 3874 3875**Since**: 12 3876 3877**System capability**: SystemCapability.Multimedia.Audio.Core 3878 3879**Parameters** 3880 3881| Name| Description| 3882| -------- | -------- | 3883| builder | Pointer to an audio stream builder instance, which is created by calling **OH_AudioStreamBuilder_Create()**. | 3884| callback | Callback used to write both audio data and metadata. | 3885| userData | Pointer to the application data passed through the callback functions. | 3886 3887**Returns** 3888 3889Returns a result code defined in [OH_AudioStream_Result](#oh_audiostream_result): 3890 3891**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3892 3893**AUDIOSTREAM_ERROR_INVALID_PARAM**: 3894 3895 1. The **builder** parameter is set to a null pointer. 3896 2. The **StreamType** parameter is set to an invalid value. 3897 3898 3899### OH_GetAudioManager() 3900 3901``` 3902OH_AudioCommon_Result OH_GetAudioManager (OH_AudioManager ** audioManager) 3903``` 3904 3905**Description** 3906 3907Obtains an **OH_AudioManager** instance. 3908 3909Before using the features related to the audio manager, you must obtain an **OH_AudioManager** instance. 3910 3911**Since**: 12 3912 3913**Parameters** 3914 3915| Name| Description| 3916| -------- | -------- | 3917| audioManager | Double pointer to the [OH_AudioManager](#oh_audiomanager) instance created. | 3918 3919**Returns** 3920 3921Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3922 3923**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3924 3925**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: The **audioManager** parameter is set to a null pointer. 3926 3927 3928### OH_GetAudioScene() 3929 3930``` 3931OH_AudioCommon_Result OH_GetAudioScene (OH_AudioManager * manager, OH_AudioScene * scene ) 3932``` 3933 3934**Description** 3935 3936Obtains the audio scene. 3937 3938**Since**: 12 3939 3940**Parameters** 3941 3942| Name| Description| 3943| -------- | -------- | 3944| audioManager | Pointer to an [OH_AudioManager](#oh_audiomanager) instance, which is created by calling [OH_GetAudioManager](#oh_getaudiomanager). | 3945| scene | Pointer to an audio scene. For details about the available options, see [OH_AudioScene](#oh_audioscene). | 3946 3947**Returns** 3948 3949Returns a result code defined in [OH_AudioCommon_Result](#oh_audiocommon_result). The following result codes are possible: 3950 3951**AUDIOCOMMON_RESULT_SUCCESS**: The function is executed successfully. 3952 3953**AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM**: 3954 39551. The **audioManager** parameter is set to a null pointer. 39562. The **scene** parameter is set to a null pointer. 3957