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