From bbd87929a450b032c856709e634759687c39eb56 Mon Sep 17 00:00:00 2001 From: zyx0106 Date: Tue, 24 Jun 2025 15:10:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=93=8D=E5=BA=A6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyx0106 --- .../audio_manager/native_audio_manager.h | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/multimedia/audio_framework/audio_manager/native_audio_manager.h b/multimedia/audio_framework/audio_manager/native_audio_manager.h index b317f856bda..6a3ef75ca99 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_manager.h @@ -124,6 +124,49 @@ OH_AudioCommon_Result OH_AudioManager_RegisterAudioSceneChangeCallback(OH_AudioM OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_AudioManager *manager, OH_AudioManager_OnAudioSceneChangeCallback callback); +/** + * @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}. + * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. + * + * @since 20 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param loudnessGain loudness gain to set which changes from -90.0 to 24.0. It is expressed 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; + * 2.The param of loudnessGain is invalid. + * {@link AUDIOSTREAM_ERROR_ILLEGAL_STATE} This audio renderer is not supported to set loudness gain. + * {@link AUDIOSTREAM_ERROR_SYSTEM}: + * 1.Crash or blocking occurs in system process. + * 2.Other unexpected error from internal system. + */ +OH_AudioStream_Result OH_AudioRenderer_SetLoudnessGain(OH_AudioRenderer* renderer, float loudnessGain); + +/** + * Get the loudness gain of current renderer. + * + * @since 20 + * + * @param renderer Reference 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. + * {@link AUDIOSTREAM_ERROR_SYSTEM}: + * 1.Crash or blocking occurs in system process. + * 2.Other unexpected error from internal system. + */ +OH_AudioStream_Result OH_AudioRenderer_GetLoudnessGain(OH_AudioRenderer* renderer, float* loudnessGain); + #ifdef __cplusplus } #endif -- Gitee From f1ce3c64236291455784e13bc597744dcc9a9dee Mon Sep 17 00:00:00 2001 From: zyx0106 Date: Tue, 24 Jun 2025 16:10:09 +0800 Subject: [PATCH 2/5] fix interface description Signed-off-by: zyx0106 --- .../audio_manager/native_audio_manager.h | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/multimedia/audio_framework/audio_manager/native_audio_manager.h b/multimedia/audio_framework/audio_manager/native_audio_manager.h index 6a3ef75ca99..b4353ed2601 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_manager.h @@ -125,45 +125,35 @@ OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_Audi OH_AudioManager_OnAudioSceneChangeCallback callback); /** - * @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}. - * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. - * - * @since 20 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param loudnessGain loudness gain to set which changes from -90.0 to 24.0. It is expressed in dB. + * @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}. + * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. + * + * @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; + * 1.The param of renderer is nullptr or not supported to set gain; * 2.The param of loudnessGain is invalid. - * {@link AUDIOSTREAM_ERROR_ILLEGAL_STATE} This audio renderer is not supported to set loudness gain. - * {@link AUDIOSTREAM_ERROR_SYSTEM}: - * 1.Crash or blocking occurs in system process. - * 2.Other unexpected error from internal system. + * @since 20 */ OH_AudioStream_Result OH_AudioRenderer_SetLoudnessGain(OH_AudioRenderer* renderer, float loudnessGain); /** - * Get the loudness gain of current renderer. - * - * @since 20 + * @brief Get the loudness gain of current renderer. * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @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. - * {@link AUDIOSTREAM_ERROR_SYSTEM}: - * 1.Crash or blocking occurs in system process. - * 2.Other unexpected error from internal system. + * @since 20 */ OH_AudioStream_Result OH_AudioRenderer_GetLoudnessGain(OH_AudioRenderer* renderer, float* loudnessGain); -- Gitee From 9b9440ffeb7b3d96c3ac64739736a69b5016950e Mon Sep 17 00:00:00 2001 From: zyx0106 Date: Tue, 24 Jun 2025 19:10:50 +0800 Subject: [PATCH 3/5] fix which file new apis are in Signed-off-by: zyx0106 --- .../audio_manager/native_audio_manager.h | 33 ------------------- .../audio_renderer/native_audiorenderer.h | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/multimedia/audio_framework/audio_manager/native_audio_manager.h b/multimedia/audio_framework/audio_manager/native_audio_manager.h index b4353ed2601..b317f856bda 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_manager.h @@ -124,39 +124,6 @@ OH_AudioCommon_Result OH_AudioManager_RegisterAudioSceneChangeCallback(OH_AudioM OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_AudioManager *manager, OH_AudioManager_OnAudioSceneChangeCallback callback); -/** - * @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}. - * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. - * - * @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/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index a2b5dff7d94..1cc7311ffc0 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}. + * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. + * + * @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 -- Gitee From 1698b1ead2bc30c62a69af41859faff95906e18a Mon Sep 17 00:00:00 2001 From: zyx0106 Date: Sat, 28 Jun 2025 14:29:18 +0800 Subject: [PATCH 4/5] add json modification Signed-off-by: zyx0106 --- multimedia/audio_framework/ohaudio.ndk.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 73e3be08e86..d619281dbd7 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" } ] -- Gitee From 29552d30ff391e2f9a57dffdedcc6156f5999047 Mon Sep 17 00:00:00 2001 From: zyx0106 Date: Sat, 28 Jun 2025 15:19:06 +0800 Subject: [PATCH 5/5] fix API description Signed-off-by: zyx0106 --- .../audio_framework/audio_renderer/native_audiorenderer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index 1cc7311ffc0..f3dd68f1232 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -605,7 +605,7 @@ typedef void (*OH_AudioRenderer_OnFastStatusChange)( * {@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}. - * OH_AudioRenderer routing through the high-resolution playback path does not support this operation. + * 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. -- Gitee