1# native_audiorenderer.h 2 3## Overview 4 5The file declares the functions related to an audio renderer. 6 7**File to include**: <ohaudio/native_audiorenderer.h> 8 9**Library**: libohaudio.so 10 11**System capability**: SystemCapability.Multimedia.Audio.Core 12 13**Since**: 10 14 15**Related module**: [OHAudio](capi-ohaudio.md) 16 17## Summary 18 19### Functions 20 21| Name| typedef Keyword| Description| 22| -- | -- | -- | 23| [OH_AudioStream_Result OH_AudioRenderer_Release(OH_AudioRenderer* renderer)](#oh_audiorenderer_release) | - | Releases an audio renderer.| 24| [OH_AudioStream_Result OH_AudioRenderer_Start(OH_AudioRenderer* renderer)](#oh_audiorenderer_start) | - | Starts an audio renderer.| 25| [OH_AudioStream_Result OH_AudioRenderer_Pause(OH_AudioRenderer* renderer)](#oh_audiorenderer_pause) | - | Pauses an audio renderer.| 26| [OH_AudioStream_Result OH_AudioRenderer_Stop(OH_AudioRenderer* renderer)](#oh_audiorenderer_stop) | - | Stops an audio renderer.| 27| [OH_AudioStream_Result OH_AudioRenderer_Flush(OH_AudioRenderer* renderer)](#oh_audiorenderer_flush) | - | Clears audio data in the buffer.| 28| [OH_AudioStream_Result OH_AudioRenderer_GetCurrentState(OH_AudioRenderer* renderer,OH_AudioStream_State* state)](#oh_audiorenderer_getcurrentstate) | - | Obtains the state of an audio renderer.| 29| [OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate(OH_AudioRenderer* renderer, int32_t* rate)](#oh_audiorenderer_getsamplingrate) | - | Obtains the sampling rate of an audio renderer.| 30| [OH_AudioStream_Result OH_AudioRenderer_GetStreamId(OH_AudioRenderer* renderer, uint32_t* streamId)](#oh_audiorenderer_getstreamid) | - | Obtains the stream ID of an audio renderer.| 31| [OH_AudioStream_Result OH_AudioRenderer_GetChannelCount(OH_AudioRenderer* renderer, int32_t* channelCount)](#oh_audiorenderer_getchannelcount) | - | Obtains the number of channels for an audio renderer.| 32| [OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat(OH_AudioRenderer* renderer,OH_AudioStream_SampleFormat* sampleFormat)](#oh_audiorenderer_getsampleformat) | - | Obtains the sampling format of an audio renderer.| 33| [OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode(OH_AudioRenderer* renderer,OH_AudioStream_LatencyMode* latencyMode)](#oh_audiorenderer_getlatencymode) | - | Obtains the latency mode of an audio renderer.| 34| [OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo(OH_AudioRenderer* renderer,OH_AudioStream_Usage* usage)](#oh_audiorenderer_getrendererinfo) | - | Obtains the usage type of an audio renderer.| 35| [OH_AudioStream_Result OH_AudioRenderer_GetEncodingType(OH_AudioRenderer* renderer,OH_AudioStream_EncodingType* encodingType)](#oh_audiorenderer_getencodingtype) | - | Obtains the encoding type of an audio renderer.| 36| [OH_AudioStream_Result OH_AudioRenderer_GetFramesWritten(OH_AudioRenderer* renderer, int64_t* frames)](#oh_audiorenderer_getframeswritten) | - | Obtains the number of frames that have been written since the stream was created.| 37| [OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer* renderer, clockid_t clockId,int64_t* framePosition, int64_t* timestamp)](#oh_audiorenderer_gettimestamp) | - | Obtains the timestamp and position information of an output audio stream.<br>This 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).<br>When you switch devices or resume playback after a pause, the playback position and timestamp retrieved via this function will temporarily stay in the state they were in before the switch or pause, since the playback channel requires a moment to stabilize. | 38| [OH_AudioStream_Result OH_AudioRenderer_GetAudioTimestampInfo(OH_AudioRenderer* renderer,int64_t* framePosition, int64_t* timestamp)](#oh_audiorenderer_getaudiotimestampinfo) | - | Obtains the timestamp and position information of an output audio stream. It adapts to the speed adjustment interface.<br>This information is commonly used for audio and video synchronization. | 39| [OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer* renderer, int32_t* frameSize)](#oh_audiorenderer_getframesizeincallback) | - | Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback.| 40| [OH_AudioStream_Result OH_AudioRenderer_GetSpeed(OH_AudioRenderer* renderer, float* speed)](#oh_audiorenderer_getspeed) | - | Obtains the rate of an audio renderer.| 41| [OH_AudioStream_Result OH_AudioRenderer_SetSpeed(OH_AudioRenderer* renderer, float speed)](#oh_audiorenderer_setspeed) | - | Sets the rate for an audio renderer.| 42| [OH_AudioStream_Result OH_AudioRenderer_SetMarkPosition(OH_AudioRenderer* renderer, uint32_t samplePos,OH_AudioRenderer_OnMarkReachedCallback callback, void* userData)](#oh_audiorenderer_setmarkposition) | - | Sets the mark position for an audio renderer. When this function is called, the mark position that has been set will be overwritten.| 43| [OH_AudioStream_Result OH_AudioRenderer_CancelMark(OH_AudioRenderer* renderer)](#oh_audiorenderer_cancelmark) | - | Cancels the mark set by [OH_AudioRenderer_SetMarkPosition](#oh_audiorenderer_setmarkposition).| 44| [OH_AudioStream_Result OH_AudioRenderer_SetVolume(OH_AudioRenderer* renderer, float volume)](#oh_audiorenderer_setvolume) | - | Sets the volume for an audio renderer.| 45| [OH_AudioStream_Result OH_AudioRenderer_SetVolumeWithRamp(OH_AudioRenderer* renderer, float volume, int32_t durationMs)](#oh_audiorenderer_setvolumewithramp) | - | Sets the volume with a ramp within the specified duration for an audio renderer.| 46| [OH_AudioStream_Result OH_AudioRenderer_GetVolume(OH_AudioRenderer* renderer, float* volume)](#oh_audiorenderer_getvolume) | - | Obtains the volume of an audio renderer.| 47| [OH_AudioStream_Result OH_AudioRenderer_GetUnderflowCount(OH_AudioRenderer* renderer, uint32_t* count)](#oh_audiorenderer_getunderflowcount) | - | Obtains the number of underloaded audio streams of an audio renderer.| 48| [OH_AudioStream_Result OH_AudioRenderer_GetChannelLayout(OH_AudioRenderer* renderer,OH_AudioChannelLayout* channelLayout)](#oh_audiorenderer_getchannellayout) | - | Obtains the channel layout of an audio renderer.| 49| [OH_AudioStream_Result OH_AudioRenderer_GetEffectMode(OH_AudioRenderer* renderer,OH_AudioStream_AudioEffectMode* effectMode)](#oh_audiorenderer_geteffectmode) | - | Obtains the effect mode of an audio renderer.| 50| [OH_AudioStream_Result OH_AudioRenderer_SetEffectMode(OH_AudioRenderer* renderer,OH_AudioStream_AudioEffectMode effectMode)](#oh_audiorenderer_seteffectmode) | - | Sets the effect mode for an audio renderer.| 51| [OH_AudioStream_Result OH_AudioRenderer_GetRendererPrivacy(OH_AudioRenderer* renderer,OH_AudioStream_PrivacyType* privacy)](#oh_audiorenderer_getrendererprivacy) | - | Checks whether the audio stream being played can be recorded by other applications.| 52| [OH_AudioStream_Result OH_AudioRenderer_SetSilentModeAndMixWithOthers(OH_AudioRenderer* renderer, bool on)](#oh_audiorenderer_setsilentmodeandmixwithothers) | - | Sets the silent mode in concurrent playback for an audio renderer.<br>If the silent mode in concurrent playback is enabled, the system mutes the audio stream and does not interrupt other audio streams. If the silent mode in concurrent playback is disabled, the audio stream can gain focus based on the system focus policy. | 53| [OH_AudioStream_Result OH_AudioRenderer_GetSilentModeAndMixWithOthers(OH_AudioRenderer* renderer, bool* on)](#oh_audiorenderer_getsilentmodeandmixwithothers) | - | Checks whether the silent mode in concurrent playback is enabled for an audio renderer.| 54| [OH_AudioStream_Result OH_AudioRenderer_SetDefaultOutputDevice(OH_AudioRenderer* renderer, OH_AudioDevice_Type deviceType)](#oh_audiorenderer_setdefaultoutputdevice) | - | Sets the default built-in audio output device.<br>This function applies only to the scenario where [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#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.<br>This 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.<br> | 55| [typedef void (\*OH_AudioRenderer_OnInterruptCallback)(OH_AudioRenderer* renderer, void* userData,OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint)](#oh_audiorenderer_oninterruptcallback) | OH_AudioRenderer_OnInterruptCallback | Defines the callback for interruption events of an audio renderer.| 56| [typedef void (\*OH_AudioRenderer_OnErrorCallback)(OH_AudioRenderer* renderer, void* userData,OH_AudioStream_Result error)](#oh_audiorenderer_onerrorcallback) | OH_AudioRenderer_OnErrorCallback | Defines the callback for error events of an audio renderer.| 57| [OH_AudioStream_Result OH_AudioRenderer_GetFastStatus(OH_AudioRenderer* renderer,OH_AudioStream_FastStatus* status)](#oh_audiorenderer_getfaststatus) | - | Obtains the running status of an audio renderer to determine whether it is running in low-latency mode.| 58| [typedef void (\*OH_AudioRenderer_OnFastStatusChange)(OH_AudioRenderer* renderer,void* userData,OH_AudioStream_FastStatus status)](#oh_audiorenderer_onfaststatuschange) | OH_AudioRenderer_OnFastStatusChange | Defines a callback function for low-latency status changes during audio playback.| 59| [OH_AudioStream_Result OH_AudioRenderer_SetLoudnessGain(OH_AudioRenderer* renderer, float loudnessGain)](#oh_audiorenderer_setloudnessgain) | - | Sets the loudness of audio playback. The default loudness value is 0.0 dB. The audio stream playback type must be one of the following: Music: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_MUSIC<br>Movies or videos: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_MUSIC<br>Audiobooks (including books, crosstalk, and storytelling), listening to news, podcasts, and others: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_AUDIOBOOK<br>The latency mode of the audio stream must be [OH_AudioStream_LatencyMode](capi-native-audiostream-base-h.md#oh_audiostream_latencymode).AUDIOSTREAM_LATENCY_MODE_NORMAL.<br>Loudness settings are not supported for high-definition audio channels.<br>Due to the buffer between the audio framework and hardware, there may be a delay in the actual effect of loudness adjustment. The delay duration depends on the buffer length.<br>You are advised to set the loudness before starting playback of different audio streams to achieve the optimal balance effect. | 60| [OH_AudioStream_Result OH_AudioRenderer_GetLoudnessGain(OH_AudioRenderer* renderer, float* loudnessGain)](#oh_audiorenderer_getloudnessgain) | - | Obtains the loudness of audio playback.| 61 62## Function Description 63 64### OH_AudioRenderer_Release() 65 66``` 67OH_AudioStream_Result OH_AudioRenderer_Release(OH_AudioRenderer* renderer) 68``` 69 70**Description** 71 72Releases an audio renderer. 73 74**Since**: 10 75 76 77**Parameters** 78 79| Name| Description| 80| -- | -- | 81| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 82 83**Returns** 84 85| Type| Description| 86| -- | -- | 87| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 88 89### OH_AudioRenderer_Start() 90 91``` 92OH_AudioStream_Result OH_AudioRenderer_Start(OH_AudioRenderer* renderer) 93``` 94 95**Description** 96 97Starts an audio renderer. 98 99**Since**: 10 100 101 102**Parameters** 103 104| Name| Description| 105| -- | -- | 106| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 107 108**Returns** 109 110| Type| Description| 111| -- | -- | 112| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 113 114### OH_AudioRenderer_Pause() 115 116``` 117OH_AudioStream_Result OH_AudioRenderer_Pause(OH_AudioRenderer* renderer) 118``` 119 120**Description** 121 122Pauses an audio renderer. 123 124**Since**: 10 125 126 127**Parameters** 128 129| Name| Description| 130| -- | -- | 131| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 132 133**Returns** 134 135| Type| Description| 136| -- | -- | 137| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 138 139### OH_AudioRenderer_Stop() 140 141``` 142OH_AudioStream_Result OH_AudioRenderer_Stop(OH_AudioRenderer* renderer) 143``` 144 145**Description** 146 147Stops an audio renderer. 148 149**Since**: 10 150 151 152**Parameters** 153 154| Name| Description| 155| -- | -- | 156| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 157 158**Returns** 159 160| Type| Description| 161| -- | -- | 162| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 163 164### OH_AudioRenderer_Flush() 165 166``` 167OH_AudioStream_Result OH_AudioRenderer_Flush(OH_AudioRenderer* renderer) 168``` 169 170**Description** 171 172Clears audio data in the buffer. 173 174**Since**: 10 175 176 177**Parameters** 178 179| Name| Description| 180| -- | -- | 181| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 182 183**Returns** 184 185| Type| Description| 186| -- | -- | 187| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 188 189### OH_AudioRenderer_GetCurrentState() 190 191``` 192OH_AudioStream_Result OH_AudioRenderer_GetCurrentState(OH_AudioRenderer* renderer,OH_AudioStream_State* state) 193``` 194 195**Description** 196 197Obtains the state of an audio renderer. 198 199**Since**: 10 200 201 202**Parameters** 203 204| Name| Description| 205| -- | -- | 206| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 207| [OH_AudioStream_State](capi-native-audiostream-base-h.md#oh_audiostream_state)* state | Pointer to a variable used to receive the state.| 208 209**Returns** 210 211| Type| Description| 212| -- | -- | 213| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 214 215### OH_AudioRenderer_GetSamplingRate() 216 217``` 218OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate(OH_AudioRenderer* renderer, int32_t* rate) 219``` 220 221**Description** 222 223Obtains the sampling rate of an audio renderer. 224 225**Since**: 10 226 227 228**Parameters** 229 230| Name| Description| 231| -- | -- | 232| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 233| int32_t* rate | Pointer to a variable used to receive the sampling rate.| 234 235**Returns** 236 237| Type| Description| 238| -- | -- | 239| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 240 241### OH_AudioRenderer_GetStreamId() 242 243``` 244OH_AudioStream_Result OH_AudioRenderer_GetStreamId(OH_AudioRenderer* renderer, uint32_t* streamId) 245``` 246 247**Description** 248 249Obtains the stream ID of an audio renderer. 250 251**Since**: 10 252 253 254**Parameters** 255 256| Name| Description| 257| -- | -- | 258| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 259| uint32_t* streamId | Pointer to a variable used to receive the stream ID.| 260 261**Returns** 262 263| Type| Description| 264| -- | -- | 265| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 266 267### OH_AudioRenderer_GetChannelCount() 268 269``` 270OH_AudioStream_Result OH_AudioRenderer_GetChannelCount(OH_AudioRenderer* renderer, int32_t* channelCount) 271``` 272 273**Description** 274 275Obtains the number of channels for an audio renderer. 276 277**Since**: 10 278 279 280**Parameters** 281 282| Name| Description| 283| -- | -- | 284| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 285| int32_t* channelCount | Pointer to a variable used to receive the channel count.| 286 287**Returns** 288 289| Type| Description| 290| -- | -- | 291| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 292 293### OH_AudioRenderer_GetSampleFormat() 294 295``` 296OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat(OH_AudioRenderer* renderer,OH_AudioStream_SampleFormat* sampleFormat) 297``` 298 299**Description** 300 301Obtains the sampling format of an audio renderer. 302 303**Since**: 10 304 305 306**Parameters** 307 308| Name| Description| 309| -- | -- | 310| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 311| [OH_AudioStream_SampleFormat](capi-native-audiostream-base-h.md#oh_audiostream_sampleformat)* sampleFormat | Pointer to a variable used to receive the sampling format.| 312 313**Returns** 314 315| Type| Description| 316| -- | -- | 317| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 318 319### OH_AudioRenderer_GetLatencyMode() 320 321``` 322OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode(OH_AudioRenderer* renderer,OH_AudioStream_LatencyMode* latencyMode) 323``` 324 325**Description** 326 327Obtains the latency mode of an audio renderer. 328 329**Since**: 10 330 331 332**Parameters** 333 334| Name| Description| 335| -- | -- | 336| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 337| [OH_AudioStream_LatencyMode](capi-native-audiostream-base-h.md#oh_audiostream_latencymode)* latencyMode | Pointer to a variable used to receive the latency mode.| 338 339**Returns** 340 341| Type| Description| 342| -- | -- | 343| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 344 345### OH_AudioRenderer_GetRendererInfo() 346 347``` 348OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo(OH_AudioRenderer* renderer,OH_AudioStream_Usage* usage) 349``` 350 351**Description** 352 353Obtains the usage type of an audio renderer. 354 355**Since**: 10 356 357 358**Parameters** 359 360| Name| Description| 361| -- | -- | 362| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 363| [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage)* usage | Pointer to a variable used to receive the usage type.| 364 365**Returns** 366 367| Type| Description| 368| -- | -- | 369| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 370 371### OH_AudioRenderer_GetEncodingType() 372 373``` 374OH_AudioStream_Result OH_AudioRenderer_GetEncodingType(OH_AudioRenderer* renderer,OH_AudioStream_EncodingType* encodingType) 375``` 376 377**Description** 378 379Obtains the encoding type of an audio renderer. 380 381**Since**: 10 382 383 384**Parameters** 385 386| Name| Description| 387| -- | -- | 388| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 389| [OH_AudioStream_EncodingType](capi-native-audiostream-base-h.md#oh_audiostream_encodingtype)* encodingType | Pointer to a variable used to receive the encoding type.| 390 391**Returns** 392 393| Type| Description| 394| -- | -- | 395| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 396 397### OH_AudioRenderer_GetFramesWritten() 398 399``` 400OH_AudioStream_Result OH_AudioRenderer_GetFramesWritten(OH_AudioRenderer* renderer, int64_t* frames) 401``` 402 403**Description** 404 405Obtains the number of frames that have been written since the stream was created. 406 407**Since**: 10 408 409 410**Parameters** 411 412| Name| Description| 413| -- | -- | 414| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 415| int64_t* frames | Pointer to a variable used to receive the frame count.| 416 417**Returns** 418 419| Type| Description| 420| -- | -- | 421| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 422 423### OH_AudioRenderer_GetTimestamp() 424 425``` 426OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer* renderer, clockid_t clockId,int64_t* framePosition, int64_t* timestamp) 427``` 428 429**Description** 430 431Obtains the timestamp and position information of an output audio stream. 432 433This 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). 434 435When you switch devices or resume playback after a pause, the playback position and timestamp retrieved via this function will temporarily stay in the state they were in before the switch or pause, since the playback channel requires a moment to stabilize. 436 437This 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. 438 439**Since**: 10 440 441 442**Parameters** 443 444| Name| Description| 445| -- | -- | 446| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 447| clockid_t clockId | Clock identifier. Use **CLOCK_MONOTONIC**.| 448| int64_t* framePosition | Pointer to a variable used to receive the position information.| 449| int64_t* timestamp | Pointer to a variable used to receive the timestamp.| 450 451**Returns** 452 453| Type| Description| 454| -- | -- | 455| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **clockId** parameter is set to an invalid value.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 456 457### OH_AudioRenderer_GetAudioTimestampInfo() 458 459``` 460OH_AudioStream_Result OH_AudioRenderer_GetAudioTimestampInfo(OH_AudioRenderer* renderer,int64_t* framePosition, int64_t* timestamp) 461``` 462 463**Description** 464 465Obtains the timestamp and position information of an output audio stream. It adapts to the speed adjustment interface. 466 467This information is commonly used for audio and video synchronization. 468 469Note that when the actual playback position (**framePosition**) is 0, the timestamp remains fixed until the stream begins to play. The playback position is also reset when **Flush** is called. 470 471Additionally, changes in the audio stream route, such as switching devices or output types, will reset the playback position, whereas the timestamp keeps increasing. You are advised to call this function to obtain the corresponding value only when the actual playback position and timestamp are stable. This function adapts to the speed adjustment interface. For example, if the playback speed is set to 2x, the rate at which the playback position increases is also twice the normal speed. 472 473**Since**: 15 474 475 476**Parameters** 477 478| Name| Description| 479| -- | -- | 480| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 481| int64_t* framePosition | Pointer to a variable used to receive the position information.| 482| int64_t* timestamp | Pointer to a variable used to receive the timestamp.| 483 484**Returns** 485 486| Type| Description| 487| -- | -- | 488| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **framePosition** or **timestamp** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The current stream status is invalid.<br>**AUDIOSTREAM_ERROR_SYSTEM**:<br>1. The system process breaks down or is blocked.<br>2. An internal system error occurs. | 489 490### OH_AudioRenderer_GetFrameSizeInCallback() 491 492``` 493OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer* renderer, int32_t* frameSize) 494``` 495 496**Description** 497 498Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback. 499 500**Since**: 10 501 502 503**Parameters** 504 505| Name| Description| 506| -- | -- | 507| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 508| int32_t* frameSize | Pointer to a variable used to receive the frame size.| 509 510**Returns** 511 512| Type| Description| 513| -- | -- | 514| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 515 516### OH_AudioRenderer_GetSpeed() 517 518``` 519OH_AudioStream_Result OH_AudioRenderer_GetSpeed(OH_AudioRenderer* renderer, float* speed) 520``` 521 522**Description** 523 524Obtains the rate of an audio renderer. 525 526**Since**: 11 527 528 529**Parameters** 530 531| Name| Description| 532| -- | -- | 533| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 534| float* speed | Pointer to the variable that receives the playback rate.| 535 536**Returns** 537 538| Type| Description| 539| -- | -- | 540| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 541 542### OH_AudioRenderer_SetSpeed() 543 544``` 545OH_AudioStream_Result OH_AudioRenderer_SetSpeed(OH_AudioRenderer* renderer, float speed) 546``` 547 548**Description** 549 550Sets the rate for an audio renderer. 551 552**Since**: 11 553 554 555**Parameters** 556 557| Name| Description| 558| -- | -- | 559| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 560| float speed | Playback rate, which ranges from 0.25 to 4.0.| 561 562**Returns** 563 564| Type| Description| 565| -- | -- | 566| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 567 568### OH_AudioRenderer_SetMarkPosition() 569 570``` 571OH_AudioStream_Result OH_AudioRenderer_SetMarkPosition(OH_AudioRenderer* renderer, uint32_t samplePos,OH_AudioRenderer_OnMarkReachedCallback callback, void* userData) 572``` 573 574**Description** 575 576Sets the mark position for an audio renderer. When this function is called, the mark position that has been set will be overwritten. 577 578**Since**: 12 579 580 581**Parameters** 582 583| Name| Description| 584| -- | -- | 585| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 586| uint32_t samplePos | Mark position.| 587| [OH_AudioRenderer_OnMarkReachedCallback](capi-native-audiostream-base-h.md#oh_audiorenderer_onmarkreachedcallback) callback | Callback invoked when the target mark position is reached.| 588| void* userData | Pointer to the application data passed through the callbacks.| 589 590**Returns** 591 592| Type| Description| 593| -- | -- | 594| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **samplePos** parameter is set to an invalid value.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal.<br>**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. | 595 596### OH_AudioRenderer_CancelMark() 597 598``` 599OH_AudioStream_Result OH_AudioRenderer_CancelMark(OH_AudioRenderer* renderer) 600``` 601 602**Description** 603 604Cancels the mark set by [OH_AudioRenderer_SetMarkPosition](#oh_audiorenderer_setmarkposition). 605 606**Since**: 12 607 608 609**Parameters** 610 611| Name| Description| 612| -- | -- | 613| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 614 615**Returns** 616 617| Type| Description| 618| -- | -- | 619| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 620 621### OH_AudioRenderer_SetVolume() 622 623``` 624OH_AudioStream_Result OH_AudioRenderer_SetVolume(OH_AudioRenderer* renderer, float volume) 625``` 626 627**Description** 628 629Sets the volume for an audio renderer. 630 631**Since**: 12 632 633 634**Parameters** 635 636| Name| Description| 637| -- | -- | 638| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 639| float volume | Target volume, in the range of [0.0, 1.0].| 640 641**Returns** 642 643| Type| Description| 644| -- | -- | 645| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **volume** parameter is set to an invalid value.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal.<br>**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. | 646 647### OH_AudioRenderer_SetVolumeWithRamp() 648 649``` 650OH_AudioStream_Result OH_AudioRenderer_SetVolumeWithRamp(OH_AudioRenderer* renderer, float volume, int32_t durationMs) 651``` 652 653**Description** 654 655Sets the volume with a ramp within the specified duration for an audio renderer. 656 657**Since**: 12 658 659 660**Parameters** 661 662| Name| Description| 663| -- | -- | 664| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 665| float volume | Target volume, in the range of [0.0, 1.0].| 666| int32_t durationMs | Duration, in milliseconds.| 667 668**Returns** 669 670| Type| Description| 671| -- | -- | 672| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **volume** parameter is set to an invalid value.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal.<br>**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. | 673 674### OH_AudioRenderer_GetVolume() 675 676``` 677OH_AudioStream_Result OH_AudioRenderer_GetVolume(OH_AudioRenderer* renderer, float* volume) 678``` 679 680**Description** 681 682Obtains the volume of an audio renderer. 683 684**Since**: 12 685 686 687**Parameters** 688 689| Name| Description| 690| -- | -- | 691| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 692| float* volume | Pointer to the audio volume, in the range of [0.0, 1.0].| 693 694**Returns** 695 696| Type| Description| 697| -- | -- | 698| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **volume** parameter is nullptr. | 699 700### OH_AudioRenderer_GetUnderflowCount() 701 702``` 703OH_AudioStream_Result OH_AudioRenderer_GetUnderflowCount(OH_AudioRenderer* renderer, uint32_t* count) 704``` 705 706**Description** 707 708Obtains the number of underloaded audio streams of an audio renderer. 709 710**Since**: 12 711 712 713**Parameters** 714 715| Name| Description| 716| -- | -- | 717| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 718| uint32_t* count | Pointer to a variable used to receive the number of underloaded audio streams.| 719 720**Returns** 721 722| Type| Description| 723| -- | -- | 724| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **count** parameter is nullptr. | 725 726### OH_AudioRenderer_GetChannelLayout() 727 728``` 729OH_AudioStream_Result OH_AudioRenderer_GetChannelLayout(OH_AudioRenderer* renderer,OH_AudioChannelLayout* channelLayout) 730``` 731 732**Description** 733 734Obtains the channel layout of an audio renderer. 735 736**Since**: 12 737 738 739**Parameters** 740 741| Name| Description| 742| -- | -- | 743| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 744| [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1)* channelLayout | Pointer to a variable used to receive the channel layout.| 745 746**Returns** 747 748| Type| Description| 749| -- | -- | 750| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 751 752### OH_AudioRenderer_GetEffectMode() 753 754``` 755OH_AudioStream_Result OH_AudioRenderer_GetEffectMode(OH_AudioRenderer* renderer,OH_AudioStream_AudioEffectMode* effectMode) 756``` 757 758**Description** 759 760Obtains the effect mode of an audio renderer. 761 762**Since**: 12 763 764 765**Parameters** 766 767| Name| Description| 768| -- | -- | 769| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 770| [OH_AudioStream_AudioEffectMode](capi-native-audiostream-base-h.md#oh_audiostream_audioeffectmode)* effectMode | Pointer to a variable used to receive the effect mode.| 771 772**Returns** 773 774| Type| Description| 775| -- | -- | 776| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 777 778### OH_AudioRenderer_SetEffectMode() 779 780``` 781OH_AudioStream_Result OH_AudioRenderer_SetEffectMode(OH_AudioRenderer* renderer,OH_AudioStream_AudioEffectMode effectMode) 782``` 783 784**Description** 785 786Sets the effect mode for an audio renderer. 787 788**Since**: 12 789 790 791**Parameters** 792 793| Name| Description| 794| -- | -- | 795| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 796| [OH_AudioStream_AudioEffectMode](capi-native-audiostream-base-h.md#oh_audiostream_audioeffectmode) effectMode | Effect mode to set.| 797 798**Returns** 799 800| Type| Description| 801| -- | -- | 802| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 803 804### OH_AudioRenderer_GetRendererPrivacy() 805 806``` 807OH_AudioStream_Result OH_AudioRenderer_GetRendererPrivacy(OH_AudioRenderer* renderer,OH_AudioStream_PrivacyType* privacy) 808``` 809 810**Description** 811 812Checks whether the audio stream being played can be recorded by other applications. 813 814**Since**: 12 815 816 817**Parameters** 818 819| Name| Description| 820| -- | -- | 821| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 822| [OH_AudioStream_PrivacyType](capi-native-audiostream-base-h.md#oh_audiostream_privacytype)* privacy | Pointer to the privacy type, which specifies whether the audio stream being played can be recorded by other applications.| 823 824**Returns** 825 826| Type| Description| 827| -- | -- | 828| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 829 830### OH_AudioRenderer_SetSilentModeAndMixWithOthers() 831 832``` 833OH_AudioStream_Result OH_AudioRenderer_SetSilentModeAndMixWithOthers(OH_AudioRenderer* renderer, bool on) 834``` 835 836**Description** 837 838Sets the silent mode in concurrent playback for an audio renderer. 839 840If the silent mode in concurrent playback is enabled, the system mutes the audio stream and does not interrupt other audio streams. If the silent mode in concurrent playback is disabled, the audio stream can gain focus based on the system focus policy. 841 842**Since**: 12 843 844 845**Parameters** 846 847| Name| Description| 848| -- | -- | 849| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 850| bool on | Status of the silent mode in concurrent playback.<br>The value **true** means that the audio stream being played is muted and the playback of other audio streams is not interrupted.<br>The value **false** means that the audio stream being played is unmuted and can gain focus based on the system focus policy. | 851 852**Returns** 853 854| Type| Description| 855| -- | -- | 856| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 857 858### OH_AudioRenderer_GetSilentModeAndMixWithOthers() 859 860``` 861OH_AudioStream_Result OH_AudioRenderer_GetSilentModeAndMixWithOthers(OH_AudioRenderer* renderer, bool* on) 862``` 863 864**Description** 865 866Checks whether the silent mode in concurrent playback is enabled for an audio renderer. 867 868**Since**: 12 869 870 871**Parameters** 872 873| Name| Description| 874| -- | -- | 875| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 876| bool* on | Whether the silent mode in concurrent playback is enabled. The value **true** means that the silent mode in concurrent playback is enabled, and **false** means the opposite.| 877 878**Returns** 879 880| Type| Description| 881| -- | -- | 882| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr. | 883 884### OH_AudioRenderer_SetDefaultOutputDevice() 885 886``` 887OH_AudioStream_Result OH_AudioRenderer_SetDefaultOutputDevice(OH_AudioRenderer* renderer, OH_AudioDevice_Type deviceType) 888``` 889 890**Description** 891 892Sets the default built-in audio output device. 893 894This function applies only to the scenario where [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#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. 895 896This 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. 897 898**Since**: 12 899 900 901**Parameters** 902 903| Name| Description| 904| -- | -- | 905| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 906| [OH_AudioDevice_Type](capi-native-audio-device-base-h.md#oh_audiodevice_type) deviceType | Device type. For details about the available options, see [OH_AudioDevice_Type](capi-native-audio-device-base-h.md#oh_audiodevice_type). 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. | 907 908**Returns** 909 910| Type| Description| 911| -- | -- | 912| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **deviceType** parameter is set to an invalid value.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal.<br>**AUDIOSTREAM_ERROR_SYSTEM**: A system error occurs. | 913 914### OH_AudioRenderer_OnInterruptCallback() 915 916``` 917typedef void (*OH_AudioRenderer_OnInterruptCallback)(OH_AudioRenderer* renderer, void* userData,OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint) 918``` 919 920**Description** 921 922Defines the callback for interruption events of an audio renderer. 923 924**Since**: 20 925 926 927**Parameters** 928 929| Name| Description| 930| -- | -- | 931| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 932| void* userData | Pointer to the data storage area customized by the application.| 933| [OH_AudioInterrupt_ForceType](capi-native-audiostream-base-h.md#oh_audiointerrupt_forcetype) type | Type of force that causes audio interruption.| 934| [OH_AudioInterrupt_Hint](capi-native-audiostream-base-h.md#oh_audiointerrupt_hint) hint | Hint provided along with audio interruption.| 935 936### OH_AudioRenderer_OnErrorCallback() 937 938``` 939typedef void (*OH_AudioRenderer_OnErrorCallback)(OH_AudioRenderer* renderer, void* userData,OH_AudioStream_Result error) 940``` 941 942**Description** 943 944Defines the callback for error events of an audio renderer. 945 946**Since**: 20 947 948 949**Parameters** 950 951| Name| Description| 952| -- | -- | 953| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 954| void* userData | Pointer to the data storage area customized by the application.| 955| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) error | Audio renderer error.| 956 957### OH_AudioRenderer_GetFastStatus() 958 959``` 960OH_AudioStream_Result OH_AudioRenderer_GetFastStatus(OH_AudioRenderer* renderer,OH_AudioStream_FastStatus* status) 961``` 962 963**Description** 964 965Obtains the running status of an audio renderer to determine whether it is running in low-latency mode. 966 967**Since**: 20 968 969 970**Parameters** 971 972| Name| Description| 973| -- | -- | 974| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 975| [OH_AudioStream_FastStatus](capi-native-audiostream-base-h.md#oh_audiostream_faststatus)* status | Pointer to the running status.| 976 977**Returns** 978 979| Type| Description| 980| -- | -- | 981| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **renderer** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The function is called in an incorrect state. | 982 983### OH_AudioRenderer_OnFastStatusChange() 984 985``` 986typedef void (*OH_AudioRenderer_OnFastStatusChange)(OH_AudioRenderer* renderer,void* userData,OH_AudioStream_FastStatus status) 987``` 988 989**Description** 990 991Defines a callback function for low-latency status changes during audio playback. 992 993**Since**: 20 994 995 996**Parameters** 997 998| Name| Description| 999| -- | -- | 1000| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 1001| void* userData | Pointer to the data storage area customized by the application.| 1002| status | Low-latency status.| 1003 1004### OH_AudioRenderer_SetLoudnessGain() 1005 1006``` 1007OH_AudioStream_Result OH_AudioRenderer_SetLoudnessGain(OH_AudioRenderer* renderer, float loudnessGain) 1008``` 1009 1010**Description** 1011 1012Sets the loudness of audio playback. The default loudness value is 0.0 dB. 1013 1014The audio stream playback type must be one of the following: 1015 1016- Music: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_MUSIC 1017- Movies or videos: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_MUSIC 1018- Audiobooks (including books, crosstalk, and storytelling), listening to news, podcasts, and others: [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage).AUDIOSTREAM_USAGE_AUDIOBOOK 1019 1020The latency mode of the audio stream must be [OH_AudioStream_LatencyMode](capi-native-audiostream-base-h.md#oh_audiostream_latencymode).AUDIOSTREAM_LATENCY_MODE_NORMAL. 1021 1022Loudness settings are not supported for high-definition audio channels. 1023 1024Due to the buffer between the audio framework and hardware, there may be a delay in the actual effect of loudness adjustment. The delay duration depends on the buffer length. 1025 1026You are advised to set the loudness before starting playback of different audio streams to achieve the optimal balance effect. 1027 1028**Since**: 20 1029 1030 1031**Parameters** 1032 1033| Name| Description| 1034| -- | -- | 1035| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 1036| float loudnessGain | Loudness, in the range [-90.0, 24.0], in dB. | 1037 1038**Returns** 1039 1040| Type| Description| 1041| -- | -- | 1042| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr, or audio streams do not support setting the loudness.<br>2. The **loudnessGain** parameter is not within the allowed range. | 1043 1044### OH_AudioRenderer_GetLoudnessGain() 1045 1046``` 1047OH_AudioStream_Result OH_AudioRenderer_GetLoudnessGain(OH_AudioRenderer* renderer, float* loudnessGain) 1048``` 1049 1050**Description** 1051 1052Obtains the loudness of audio playback. 1053 1054**Since**: 20 1055 1056 1057**Parameters** 1058 1059| Name| Description| 1060| -- | -- | 1061| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)* renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](capi-native-audiostreambuilder-h.md#oh_audiostreambuilder_generaterenderer).| 1062| float* loudnessGain | Pointer to the variable that receives the loudness.| 1063 1064**Returns** 1065 1066| Type| Description| 1067| -- | -- | 1068| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **renderer** parameter is nullptr.<br>2. The **loudnessGain** parameter is nullptr. | 1069