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