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