diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index a2b5dff7d94bb3a890bc911f763c0e16a4f5682d..f3dd68f123215fd36d373bd28b8e799d94bf4b58 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -599,6 +599,39 @@ typedef void (*OH_AudioRenderer_OnFastStatusChange)( OH_AudioStream_FastStatus status ); +/** + * @brief Sets the loudness gain of current renderer. + * The default loudness gain is 0.0dB. The stream usage of the audio renderer must be + * {@link OH_AudioStream_Usage#AUDIOSTREAM_USAGE_MUSIC}, {@link OH_AudioStream_Usage#AUDIOSTREAM_USAGE_MOVIE} + * or {@link OH_AudioStream_Usage#AUDIOSTREAM_USAGE_AUDIOBOOK}. + * The latency mode of the audio renderer must be {@link OH_AudioStream_LatencyMode#AUDIOSTREAM_LATENCY_MODE_NORMAL}. + * If AudioRenderer is played through the high-resolution pipe, this operation is not supported. + * + * @param renderer AudioRender created by OH_AudioStreamBuilder_GenerateRenderer() + * @param loudnessGain Loudness gain to set which changes from -90.0 to 24.0, expressing in dB. + * @return Function result code: + * {@link AUDIOSTREAM_SUCCESS} If the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM}: + * 1.The param of renderer is nullptr or not supported to set gain; + * 2.The param of loudnessGain is invalid. + * @since 20 + */ +OH_AudioStream_Result OH_AudioRenderer_SetLoudnessGain(OH_AudioRenderer* renderer, float loudnessGain); + +/** + * @brief Get the loudness gain of current renderer. + * + * @param renderer AudioRender created by OH_AudioStreamBuilder_GenerateRenderer() + * @param loudnessGain Pointer to a variable to receive the loudness gain. + * @return Function result code: + * {@link AUDIOSTREAM_SUCCESS} If the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM}: + * 1.The param of renderer is nullptr; + * 2.The param of loudnessGain is nullptr. + * @since 20 + */ +OH_AudioStream_Result OH_AudioRenderer_GetLoudnessGain(OH_AudioRenderer* renderer, float* loudnessGain); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 73e3be08e86836e8e8812bff4ed8b606c5574574..d619281dbd77603ffc73da0083b01ad2a822e4f8 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -498,5 +498,13 @@ { "first_introduced": "20", "name": "OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback" + }, + { + "first_introduced": "20", + "name": "OH_AudioRenderer_SetLoudnessGain" + }, + { + "first_introduced": "20", + "name": "OH_AudioRenderer_GetLoudnessGain" } ]