From be3fb38cdc959aeaa4f0f9ecf2fc844e5a25462c Mon Sep 17 00:00:00 2001 From: www Date: Tue, 29 Jul 2025 17:42:59 +0800 Subject: [PATCH 1/5] fixLppLoudnessGain Signed-off-by: www --- .../lppplayer/native_lpp_audio_streamer.cpp | 12 ++++++++++++ .../audio_streamer_impl.cpp | 9 +++++++++ .../lpp_audio_streamer/audio_streamer_impl.h | 2 ++ .../inner_api/native/lpp_audio_streamer.h | 2 ++ interfaces/kits/c/lowpower_audio_sink.h | 14 ++++++++++++++ .../lpp_audio_streamer/hilpp_astreamer_impl.h | 1 + .../lpp_audio_render_adapter.h | 2 ++ .../src/hilpp_astreamer_impl.cpp | 12 +++++++++++- .../src/lpp_audio_render_adapter.cpp | 12 ++++++++++++ .../include/i_lpp_audio_streamer_service.h | 2 ++ .../engine_intf/i_lpp_audio_streamer.h | 1 + .../client/lpp_audio_streamer_client.cpp | 7 +++++++ .../client/lpp_audio_streamer_client.h | 2 ++ .../i_standard_lpp_audio_streamer_service.h | 3 +++ .../ipc/lpp_audio_streamer_service_proxy.cpp | 19 ++++++++++++++++++- .../ipc/lpp_audio_streamer_service_proxy.h | 2 ++ .../ipc/lpp_audio_streamer_service_stub.cpp | 15 +++++++++++++++ .../ipc/lpp_audio_streamer_service_stub.h | 3 +++ .../server/lpp_audio_streamer_server.cpp | 9 +++++++++ .../server/lpp_audio_streamer_server.h | 2 ++ 20 files changed, 129 insertions(+), 2 deletions(-) diff --git a/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp b/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp index 6c8144d52..438ad328f 100644 --- a/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp +++ b/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp @@ -452,6 +452,18 @@ OH_AVErrCode OH_LowPowerAudioSink_SetVolume(OH_LowPowerAudioSink *streamer, cons return LppMsErrToOHAvErr(res); } + +OH_AVErrCode OH_LowPowerAudioSink_SetLoudnessGain(OH_LowPowerAudioSink* streamer, float loudnessGain) +{ + MEDIA_LOGD("OH_LowPowerAudioSink_SetLoudnessGain"); + CHECK_AND_RETURN_RET_LOG(streamer != nullptr, AV_ERR_INVALID_VAL, "streamer is nullptr!"); + LowPowerAudioSinkObject *streamerObj = reinterpret_cast(streamer); + CHECK_AND_RETURN_RET_LOG(streamerObj != nullptr, AV_ERR_INVALID_VAL, "streamerObj is nullptr"); + CHECK_AND_RETURN_RET_LOG(streamerObj->audioStreamer_ != nullptr, AV_ERR_INVALID_VAL, "audioStreamer_ is nullptr"); + int32_t res = streamerObj->audioStreamer_->SetLoudnessGain(loudnessGain); + return LppMsErrToOHAvErr(res); +} + OH_AVErrCode OH_LowPowerAudioSink_ReturnSamples(OH_LowPowerAudioSink *streamer, OH_AVSamplesBuffer *frames) { MEDIA_LOGD("OH_LowPowerAudioSink_ReturnSamples"); diff --git a/frameworks/native/lpp_audio_streamer/audio_streamer_impl.cpp b/frameworks/native/lpp_audio_streamer/audio_streamer_impl.cpp index 66b804c60..4c9729ae9 100644 --- a/frameworks/native/lpp_audio_streamer/audio_streamer_impl.cpp +++ b/frameworks/native/lpp_audio_streamer/audio_streamer_impl.cpp @@ -155,6 +155,15 @@ int32_t AudioStreamerImpl::SetVolume(float volume) return ret; } +int32_t AudioStreamerImpl::SetLoudnessGain(const float loudnessGain) +{ + MEDIA_LOGD("SetLoudnessGain"); + CHECK_AND_RETURN_RET_LOG(enableLppSink_, MSERR_UNSUPPORT, "Lpp is disabled"); + CHECK_AND_RETURN_RET_LOG(streamerService_ != nullptr, MSERR_SERVICE_DIED, "service died"); + int32_t ret = streamerService_->SetLoudnessGain(loudnessGain); + return ret; +} + int32_t AudioStreamerImpl::SetPlaybackSpeed(float speed) { MEDIA_LOGI("AudioStreamerImpl SetPlaybackSpeed"); diff --git a/frameworks/native/lpp_audio_streamer/audio_streamer_impl.h b/frameworks/native/lpp_audio_streamer/audio_streamer_impl.h index 3ddda9db7..2792bcc4a 100644 --- a/frameworks/native/lpp_audio_streamer/audio_streamer_impl.h +++ b/frameworks/native/lpp_audio_streamer/audio_streamer_impl.h @@ -52,6 +52,8 @@ public: int32_t SetVolume(float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; + int32_t SetPlaybackSpeed(float speed) override; int32_t ReturnFrames(sptr framePacket) override; diff --git a/interfaces/inner_api/native/lpp_audio_streamer.h b/interfaces/inner_api/native/lpp_audio_streamer.h index ba4e46b23..617943ade 100644 --- a/interfaces/inner_api/native/lpp_audio_streamer.h +++ b/interfaces/inner_api/native/lpp_audio_streamer.h @@ -80,6 +80,8 @@ public: virtual int32_t SetVolume(float volume) = 0; + virtual int32_t SetLoudnessGain(const float loudnessGain) = 0; + virtual int32_t SetPlaybackSpeed(float speed) = 0; virtual int32_t ReturnFrames(sptr framePacket) = 0; diff --git a/interfaces/kits/c/lowpower_audio_sink.h b/interfaces/kits/c/lowpower_audio_sink.h index 43042ae6a..1122e117d 100644 --- a/interfaces/kits/c/lowpower_audio_sink.h +++ b/interfaces/kits/c/lowpower_audio_sink.h @@ -238,6 +238,20 @@ OH_AVErrCode OH_LowPowerAudioSink_Destroy(OH_LowPowerAudioSink* sink); * @since 20 */ OH_AVErrCode OH_LowPowerAudioSink_SetVolume(OH_LowPowerAudioSink* sink, const float volume); + +/** + * @brief Set the loudness gain for lowpower audio sink. + * + * @param {OH_LowPowerAudioSink*} sink Pointer to an OH_LowPowerAudioSink instance. + * @param {float} loudnessGain Loudness gain to set which changes from -90.0 to 24.0, expressing in dB. + * The default loudness gain is 0.0dB. + * @return Returns AV_ERR_OK if the gain is set successfully; + * otherwise, returns a specific error code as defined in {@link OH_AVErrCode} + * {@link AV_ERR_INVALID_VAL} the sink is nullptr or loudnessGain is out of valid range. + * {@link AV_ERR_SERVICE_DIED} media service is died. + * @since 20 + */ +OH_AVErrCode OH_LowPowerAudioSink_SetLoudnessGain(OH_LowPowerAudioSink* streamer, float loudnessGain); /** * @brief Set playback speed for the lowpower audio sink. diff --git a/services/engine/histreamer/lpp/lpp_audio_streamer/hilpp_astreamer_impl.h b/services/engine/histreamer/lpp/lpp_audio_streamer/hilpp_astreamer_impl.h index 02c608aa8..90a9ef756 100644 --- a/services/engine/histreamer/lpp/lpp_audio_streamer/hilpp_astreamer_impl.h +++ b/services/engine/histreamer/lpp/lpp_audio_streamer/hilpp_astreamer_impl.h @@ -44,6 +44,7 @@ public: int32_t Stop() override; int32_t Reset() override; int32_t SetVolume(const float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; int32_t SetPlaybackSpeed(const float playbackSpeed) override; int32_t ReturnFrames(sptr framePacket) override; int32_t SetLppVideoStreamerId(std::string videoStreamerId) override; diff --git a/services/engine/histreamer/lpp/lpp_audio_streamer/lpp_audio_render_adapter.h b/services/engine/histreamer/lpp/lpp_audio_streamer/lpp_audio_render_adapter.h index fa0b2f4b6..64238f5a8 100644 --- a/services/engine/histreamer/lpp/lpp_audio_streamer/lpp_audio_render_adapter.h +++ b/services/engine/histreamer/lpp/lpp_audio_streamer/lpp_audio_render_adapter.h @@ -51,6 +51,7 @@ public: int32_t Deinit(); int32_t SetSpeed(float speed); int32_t SetVolume(const float volume); + int32_t SetLoudnessGain(const float loudnessGain); int32_t GetCurrentPosition(int64_t ¤tPositionMs); void OnWriteData(size_t length); @@ -127,6 +128,7 @@ private: std::shared_ptr eventReceiver_ {nullptr}; float speed_ {1.0f}; float volume_ = {1.0f}; + float loudnessGain_ = {0.0f}; }; } // namespace Media } // namespace OHOS diff --git a/services/engine/histreamer/lpp/lpp_audio_streamer/src/hilpp_astreamer_impl.cpp b/services/engine/histreamer/lpp/lpp_audio_streamer/src/hilpp_astreamer_impl.cpp index 0c6335456..45f5bf3f7 100644 --- a/services/engine/histreamer/lpp/lpp_audio_streamer/src/hilpp_astreamer_impl.cpp +++ b/services/engine/histreamer/lpp/lpp_audio_streamer/src/hilpp_astreamer_impl.cpp @@ -254,12 +254,22 @@ int32_t HiLppAudioStreamerImpl::Reset() } int32_t HiLppAudioStreamerImpl::SetVolume(const float volume) { - MEDIA_LOG_I("HiLppAudioStreamerImpl::SetVolume" PUBLIC_LOG_F, volume); + MEDIA_LOG_D("HiLppAudioStreamerImpl::SetVolume" PUBLIC_LOG_F, volume); FALSE_RETURN_V_MSG(aRender_ != nullptr, MSERR_INVALID_OPERATION, "aRender_ nullptr"); auto ret = aRender_->SetVolume(volume); FALSE_RETURN_V_MSG(ret == MSERR_OK, ret, "aRender_ SetVolume failed"); return MSERR_OK; } + +int32_t HiLppAudioStreamerImpl::SetLoudnessGain(const float loudnessGain) +{ + MEDIA_LOG_D("SetLoudnessGain " PUBLIC_LOG_F, loudnessGain); + FALSE_RETURN_V_MSG(aRender_ != nullptr, MSERR_INVALID_OPERATION, "aRender_ nullptr"); + auto ret = aRender_->SetLoudnessGain(loudnessGain); + FALSE_RETURN_V_MSG(ret == MSERR_OK, ret, "aRender_ SetLoudnessGain failed"); + return MSERR_OK; +} + int32_t HiLppAudioStreamerImpl::SetPlaybackSpeed(const float playbackSpeed) { MEDIA_LOG_I("HiLppAudioStreamerImpl::SetPlaybackSpeed" PUBLIC_LOG_F, playbackSpeed); diff --git a/services/engine/histreamer/lpp/lpp_audio_streamer/src/lpp_audio_render_adapter.cpp b/services/engine/histreamer/lpp/lpp_audio_streamer/src/lpp_audio_render_adapter.cpp index ca5771f25..4da4721b4 100644 --- a/services/engine/histreamer/lpp/lpp_audio_streamer/src/lpp_audio_render_adapter.cpp +++ b/services/engine/histreamer/lpp/lpp_audio_streamer/src/lpp_audio_render_adapter.cpp @@ -351,6 +351,18 @@ int32_t LppAudioRenderAdapter::SetVolume(const float volume) return MSERR_OK; } +int32_t LppAudioRenderAdapter::SetLoudnessGain(const float loudnessGain) +{ + MEDIA_LOG_D("SetLoudnessGain entered."); + FALSE_RETURN_V_MSG(audioRenderer_ != nullptr, MSERR_NO_MEMORY, "audiorender is nullptr"); + int32_t ret = audioRenderer_->SetLoudnessGain(loudnessGain); + FALSE_RETURN_V_MSG_E(ret == OHOS::AudioStandard::SUCCESS, AudioStandardStatusToMSError(ret), + "set loudnessGain failed with code " PUBLIC_LOG_D32, ret); + MEDIA_LOG_D("SetLoudnessGain succ"); + loudnessGain_ = loudnessGain; + return MSERR_OK; +} + int32_t LppAudioRenderAdapter::GetAudioPosition(timespec &time, uint32_t &framePosition) { FALSE_RETURN_V_MSG(audioRenderer_ != nullptr, MSERR_INVALID_OPERATION, "GetAudioPosition audioRender_ is nullptr"); diff --git a/services/include/i_lpp_audio_streamer_service.h b/services/include/i_lpp_audio_streamer_service.h index 7a608a25a..3abde0db7 100644 --- a/services/include/i_lpp_audio_streamer_service.h +++ b/services/include/i_lpp_audio_streamer_service.h @@ -51,6 +51,8 @@ public: virtual int32_t SetVolume(float volume) = 0; + virtual int32_t SetLoudnessGain(const float loudnessGain) = 0; + virtual int32_t SetPlaybackSpeed(float speed) = 0; virtual int32_t ReturnFrames(sptr framePacket) = 0; diff --git a/services/services/engine_intf/i_lpp_audio_streamer.h b/services/services/engine_intf/i_lpp_audio_streamer.h index 46c7365ba..63b8b0ab4 100644 --- a/services/services/engine_intf/i_lpp_audio_streamer.h +++ b/services/services/engine_intf/i_lpp_audio_streamer.h @@ -48,6 +48,7 @@ public: virtual int32_t Stop() = 0; virtual int32_t Reset() = 0; virtual int32_t SetVolume(const float volume) = 0; + virtual int32_t SetLoudnessGain(const float loudnessGain) = 0; virtual int32_t SetPlaybackSpeed(const float playbackSpeed) = 0; virtual int32_t ReturnFrames(sptr framePacket) = 0; virtual int32_t SetLppVideoStreamerId(std::string videoStreamerId) = 0; diff --git a/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.cpp b/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.cpp index 5af9f275a..6cc9b88d2 100644 --- a/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.cpp +++ b/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.cpp @@ -129,6 +129,13 @@ int32_t LppAudioStreamerClient::SetVolume(float volume) return playerProxy_->SetVolume(volume); } +int32_t LppAudioStreamerClient::SetLoudnessGain(const float loudnessGain) +{ + std::lock_guard lock(mutex_); + CHECK_AND_RETURN_RET_LOG(playerProxy_ != nullptr, MSERR_SERVICE_DIED, "player service does not exist.."); + return playerProxy_->SetLoudnessGain(loudnessGain); +} + int32_t LppAudioStreamerClient::SetPlaybackSpeed(float speed) { std::lock_guard lock(mutex_); diff --git a/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.h b/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.h index 0bafd8594..dcb2371e5 100644 --- a/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.h +++ b/services/services/lpp_audio_streamer/client/lpp_audio_streamer_client.h @@ -52,6 +52,8 @@ public: int32_t SetVolume(float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; + int32_t SetPlaybackSpeed(float speed) override; int32_t ReturnFrames(sptr framePacket) override; diff --git a/services/services/lpp_audio_streamer/ipc/i_standard_lpp_audio_streamer_service.h b/services/services/lpp_audio_streamer/ipc/i_standard_lpp_audio_streamer_service.h index bcd44895b..48c9d760d 100644 --- a/services/services/lpp_audio_streamer/ipc/i_standard_lpp_audio_streamer_service.h +++ b/services/services/lpp_audio_streamer/ipc/i_standard_lpp_audio_streamer_service.h @@ -54,6 +54,8 @@ public: virtual int32_t SetVolume(float volume) = 0; + virtual int32_t SetLoudnessGain(const float loudnessGain) = 0; + virtual int32_t SetPlaybackSpeed(float speed) = 0; virtual int32_t ReturnFrames(sptr framePacket) = 0; @@ -91,6 +93,7 @@ public: SET_LISTENER_OBJ, SET_VIDOE_STREAMER_ID, GET_STREAM_ID, + SET_LOUDNESS_GAIN, MAX_IPC_ID, // all IPC codes should be added before MAX_IPC_ID }; diff --git a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.cpp b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.cpp index 0dbd4f5e6..049e9f73f 100644 --- a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.cpp +++ b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.cpp @@ -215,6 +215,23 @@ int32_t LppAudioStreamerServiceProxy::SetVolume(float volume) return reply.ReadInt32(); } +int32_t LppAudioStreamerServiceProxy::SetLoudnessGain(const float loudnessGain) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool token = data.WriteInterfaceToken(LppAudioStreamerServiceProxy::GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(token, MSERR_INVALID_OPERATION, "Failed to write descriptor!"); + + data.WriteFloat(loudnessGain); + + int32_t error = Remote()->SendRequest(SET_LOUDNESS_GAIN, data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, + "SetLoudnessGain failed, error: %{public}d", error); + return reply.ReadInt32(); +} + int32_t LppAudioStreamerServiceProxy::SetPlaybackSpeed(float speed) { MessageParcel data; @@ -228,7 +245,7 @@ int32_t LppAudioStreamerServiceProxy::SetPlaybackSpeed(float speed) int32_t error = Remote()->SendRequest(SET_PLAYBACK_SPEED, data, reply, option); CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, - "SetVolume failed, error: %{public}d", error); + "SetPlaybackSpeed failed, error: %{public}d", error); return reply.ReadInt32(); } diff --git a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.h b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.h index 6155e8e4d..b344ca0e0 100644 --- a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.h +++ b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_proxy.h @@ -50,6 +50,8 @@ public: int32_t SetVolume(float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; + int32_t SetPlaybackSpeed(float speed) override; int32_t ReturnFrames(sptr framePacket) override; diff --git a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.cpp b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.cpp index 3bc61d623..fa0823cf8 100644 --- a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.cpp +++ b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.cpp @@ -123,6 +123,8 @@ void LppAudioStreamerServiceStub::FillPlayerFuncPart1() [this](MessageParcel &data, MessageParcel &reply) { return SetLppVideoStreamerId(data, reply); }}; playerFuncs_[GET_STREAM_ID] = {"Player::GetStreamerId", [this](MessageParcel &data, MessageParcel &reply) { return GetStreamerId(data, reply); }}; + playerFuncs_[SET_LOUDNESS_GAIN] = {"Player::SetLoudnessGain", + [this](MessageParcel &data, MessageParcel &reply) { return SetLoudnessGain(data, reply); }}; } int LppAudioStreamerServiceStub::OnRemoteRequest( @@ -324,6 +326,19 @@ int32_t LppAudioStreamerServiceStub::SetVolume(MessageParcel &data, MessageParce return MSERR_OK; } +int32_t LppAudioStreamerServiceStub::SetLoudnessGain(const float loudnessGain) +{ + CHECK_AND_RETURN_RET_LOG(lppAudioPlayerServer_ != nullptr, MSERR_INVALID_OPERATION, "player server is nullptr"); + return lppAudioPlayerServer_->SetLoudnessGain(loudnessGain); +} + +int32_t LppAudioStreamerServiceStub::SetLoudnessGain(MessageParcel &data, MessageParcel &reply) +{ + float loudnessGain = data.ReadFloat(); + reply.WriteInt32(SetLoudnessGain(loudnessGain)); + return MSERR_OK; +} + int32_t LppAudioStreamerServiceStub::SetPlaybackSpeed(float speed) { CHECK_AND_RETURN_RET_LOG(lppAudioPlayerServer_ != nullptr, MSERR_INVALID_OPERATION, "player server is nullptr"); diff --git a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.h b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.h index 4d2c8e05f..bca7bd6ef 100644 --- a/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.h +++ b/services/services/lpp_audio_streamer/ipc/lpp_audio_streamer_service_stub.h @@ -54,6 +54,8 @@ public: int32_t SetVolume(float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; + int32_t SetPlaybackSpeed(float speed) override; int32_t ReturnFrames(sptr framePacket) override; @@ -88,6 +90,7 @@ public: int32_t Reset(MessageParcel &data, MessageParcel &reply); int32_t Release(MessageParcel &data, MessageParcel &reply); int32_t SetVolume(MessageParcel &data, MessageParcel &reply); + int32_t SetLoudnessGain(MessageParcel &data, MessageParcel &reply); int32_t SetPlaybackSpeed(MessageParcel &data, MessageParcel &reply); int32_t ReturnFrames(MessageParcel &data, MessageParcel &reply); int32_t RegisterCallback(MessageParcel &data, MessageParcel &reply); diff --git a/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.cpp b/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.cpp index a8f6e3c51..41a23c82c 100644 --- a/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.cpp +++ b/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.cpp @@ -221,6 +221,15 @@ int32_t LppAudioStreamerServer::SetVolume(float volume) return MSERR_OK; } +int32_t LppAudioStreamerServer::SetLoudnessGain(const float loudnessGain) +{ + MEDIA_LOGD("SetLoudnessGain"); + CHECK_AND_RETURN_RET_LOG(streamerEngine_ != nullptr, MSERR_INVALID_OPERATION, "streamerEngine_ is nullptr"); + auto ret = streamerEngine_->SetLoudnessGain(loudnessGain); + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "loudnessGain Failed!"); + return MSERR_OK; +} + int32_t LppAudioStreamerServer::SetPlaybackSpeed(float speed) { MEDIA_LOGI("LppAudioStreamerServer SetPlaybackSpeed"); diff --git a/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.h b/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.h index 96cef2431..970828e4c 100644 --- a/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.h +++ b/services/services/lpp_audio_streamer/server/lpp_audio_streamer_server.h @@ -71,6 +71,8 @@ public: int32_t SetVolume(float volume) override; + int32_t SetLoudnessGain(const float loudnessGain) override; + int32_t SetPlaybackSpeed(float speed) override; int32_t ReturnFrames(sptr framePacket) override; -- Gitee From 988fc08e0514f6c16a3c92f0b25fbf81a5d16f80 Mon Sep 17 00:00:00 2001 From: huangtianyu Date: Tue, 29 Jul 2025 09:47:55 +0000 Subject: [PATCH 2/5] fixUnitTest Signed-off-by: huangtianyu --- .../lpp_astream_impl_unit_test/mock/hilpp_astreamer_impl.h | 3 ++- .../lpp_astream_impl_unit_test/mock/i_lpp_audio_streamer.h | 3 ++- .../mock/lpp_audio_render_adapter.h | 3 ++- .../mock/i_lpp_audio_streamer.h | 3 ++- .../lpp_audio_render_adapter_unit_test/mock/audio_renderer.h | 1 + .../mock/lpp_audio_render_adapter.h | 4 +++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/hilpp_astreamer_impl.h b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/hilpp_astreamer_impl.h index 0db1d9f64..23d9372e5 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/hilpp_astreamer_impl.h +++ b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/hilpp_astreamer_impl.h @@ -46,6 +46,7 @@ public: int32_t Stop(); int32_t Reset(); int32_t SetVolume(const float volume); + int32_t SetLoudnessGain(const float loudnessGain); int32_t SetPlaybackSpeed(const float playbackSpeed); int32_t ReturnFrames(sptr framePacket); int32_t SetLppVideoStreamerId(std::string videoStreamerId); @@ -79,4 +80,4 @@ private: }; } // namespace Media } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/i_lpp_audio_streamer.h b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/i_lpp_audio_streamer.h index f542fe149..699c373d2 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/i_lpp_audio_streamer.h +++ b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/i_lpp_audio_streamer.h @@ -46,6 +46,7 @@ public: virtual int32_t Stop() = 0; virtual int32_t Reset() = 0; virtual int32_t SetVolume(const float volume) = 0; + virtual int32_t SetLoudnessGain(const float loudnessGain) = 0; virtual int32_t SetPlaybackSpeed(const float playbackSpeed) = 0; virtual int32_t ReturnFrames(sptr framePacket) = 0; virtual int32_t SetLppVideoStreamerId(std::string videoStreamerId) = 0; @@ -54,4 +55,4 @@ public: }; } // namespace Media } // namespace OHOS -#endif // I_LPP_AUDIO_STREAMER_H \ No newline at end of file +#endif // I_LPP_AUDIO_STREAMER_H diff --git a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/lpp_audio_render_adapter.h b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/lpp_audio_render_adapter.h index 68377687d..c94d1c7b3 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/lpp_audio_render_adapter.h +++ b/test/unittest/lpp_unit_test/engine/lpp_astream_impl_unit_test/mock/lpp_audio_render_adapter.h @@ -39,6 +39,7 @@ public: MOCK_METHOD(int32_t, Deinit, ()); MOCK_METHOD(int32_t, SetSpeed, (float speed)); MOCK_METHOD(int32_t, SetVolume, (const float volume)); + MOCK_METHOD(int32_t, SetLoudnessGain, (const float loudnessGain)); MOCK_METHOD(int32_t, GetCurrentPosition, (int64_t ¤tPosition)); MOCK_METHOD(void, OnWriteData, (size_t length)); @@ -57,4 +58,4 @@ public: }; } // namespace Media } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/test/unittest/lpp_unit_test/engine/lpp_audio_callback_looper_unit_test/mock/i_lpp_audio_streamer.h b/test/unittest/lpp_unit_test/engine/lpp_audio_callback_looper_unit_test/mock/i_lpp_audio_streamer.h index 811ab7aca..49525d2fe 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_audio_callback_looper_unit_test/mock/i_lpp_audio_streamer.h +++ b/test/unittest/lpp_unit_test/engine/lpp_audio_callback_looper_unit_test/mock/i_lpp_audio_streamer.h @@ -50,6 +50,7 @@ public: MOCK_METHOD(int32_t, Stop, ()); MOCK_METHOD(int32_t, Reset, ()); MOCK_METHOD(int32_t, SetVolume, (const float volume)); + MOCK_METHOD(int32_t, SetLoudnessGain, (const float loudnessGain)); MOCK_METHOD(int32_t, SetPlaybackSpeed, (const float playbackSpeed)); MOCK_METHOD(int32_t, ReturnFrames, (sptr framePacket)); MOCK_METHOD(int32_t, SetLppVideoStreamerId, (std::string videoStreamerId)); @@ -58,4 +59,4 @@ public: }; } // namespace Media } // namespace OHOS -#endif // I_LPP_AUDIO_STREAMER_H \ No newline at end of file +#endif // I_LPP_AUDIO_STREAMER_H diff --git a/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/audio_renderer.h b/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/audio_renderer.h index 8a3b238a2..01efa2919 100644 --- a/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/audio_renderer.h +++ b/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/audio_renderer.h @@ -162,6 +162,7 @@ public: MOCK_METHOD(bool, Stop, ()); MOCK_METHOD(int32_t, SetSpeed, (float speed)); MOCK_METHOD(int32_t, SetVolume, (float volume)); + MOCK_METHOD(int32_t, SetLoudnessGain, (float loudnessGain)); MOCK_METHOD(int32_t, GetAudioTimestampInfo, (Timestamp ×tamp, Timestamp::Timestampbase base)); MOCK_METHOD(int32_t, GetBufferDesc, (BufferDesc &bufDesc)); MOCK_METHOD(int32_t, Enqueue, (BufferDesc &bufDesc)); diff --git a/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/lpp_audio_render_adapter.h b/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/lpp_audio_render_adapter.h index 2484e6073..24a86b25f 100644 --- a/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/lpp_audio_render_adapter.h +++ b/test/unittest/lpp_unit_test/module/lpp_audio_render_adapter_unit_test/mock/lpp_audio_render_adapter.h @@ -56,6 +56,7 @@ public: int32_t Deinit(); virtual int32_t SetSpeed(float speed); virtual int32_t SetVolume(const float volume); + virtual int32_t SetLoudnessGain(const float loudnessGain); virtual int32_t GetCurrentPosition(int64_t ¤tPosition); void OnWriteData(size_t length); @@ -130,7 +131,8 @@ private: std::shared_ptr eventReceiver_ {nullptr}; float speed_ {1.0f}; float volume_ = {1.0f}; + float loudnessGain_ = {0.0f}; }; } // namespace Media } // namespace OHOS -#endif \ No newline at end of file +#endif -- Gitee From 81729cc70c455e38f3ee055a60bb2428b240bd55 Mon Sep 17 00:00:00 2001 From: huangtianyu Date: Thu, 31 Jul 2025 02:00:33 +0000 Subject: [PATCH 3/5] update interfaces/kits/c/lowpower_audio_sink.h. Signed-off-by: huangtianyu --- interfaces/kits/c/lowpower_audio_sink.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/c/lowpower_audio_sink.h b/interfaces/kits/c/lowpower_audio_sink.h index 1122e117d..6b8cad273 100644 --- a/interfaces/kits/c/lowpower_audio_sink.h +++ b/interfaces/kits/c/lowpower_audio_sink.h @@ -244,7 +244,7 @@ OH_AVErrCode OH_LowPowerAudioSink_SetVolume(OH_LowPowerAudioSink* sink, const fl * * @param {OH_LowPowerAudioSink*} sink Pointer to an OH_LowPowerAudioSink instance. * @param {float} loudnessGain Loudness gain to set which changes from -90.0 to 24.0, expressing in dB. - * The default loudness gain is 0.0dB. + * The default loudness gain is 0.0dB. * @return Returns AV_ERR_OK if the gain is set successfully; * otherwise, returns a specific error code as defined in {@link OH_AVErrCode} * {@link AV_ERR_INVALID_VAL} the sink is nullptr or loudnessGain is out of valid range. -- Gitee From 74af11f07c8841f582fccc38934f82d32b5de565 Mon Sep 17 00:00:00 2001 From: huangtianyu Date: Mon, 4 Aug 2025 08:15:12 +0000 Subject: [PATCH 4/5] FixRePlayError Signed-off-by: huangtianyu --- .../lpp/lpp_video_streamer/src/hilpp_vstreamer_impl.cpp | 2 +- .../lpp_video_streamer/server/lpp_video_streamer_server.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/engine/histreamer/lpp/lpp_video_streamer/src/hilpp_vstreamer_impl.cpp b/services/engine/histreamer/lpp/lpp_video_streamer/src/hilpp_vstreamer_impl.cpp index c2bdbfd01..92d57ac95 100644 --- a/services/engine/histreamer/lpp/lpp_video_streamer/src/hilpp_vstreamer_impl.cpp +++ b/services/engine/histreamer/lpp/lpp_video_streamer/src/hilpp_vstreamer_impl.cpp @@ -304,9 +304,9 @@ int32_t HiLppVideoStreamerImpl::Reset() FALSE_RETURN_V_MSG(syncMgr_ != nullptr, MSERR_INVALID_OPERATION, "syncMgr_ nullptr"); FALSE_RETURN_V_MSG(dataMgr_ != nullptr, MSERR_INVALID_OPERATION, "dataMgr_ nullptr"); FALSE_RETURN_V_MSG(surface_ != nullptr, MSERR_INVALID_OPERATION, "surface_ nullptr"); + surface_->SetLppShareFd(shareBufferFd_, false); auto ret = syncMgr_->Reset(); syncMgr_.reset(); - surface_->SetLppShareFd(shareBufferFd_, false); std::mutex surfaceBufferMutex; std::condition_variable surfaceCond; bool bufferConsumed = false; diff --git a/services/services/lpp_video_streamer/server/lpp_video_streamer_server.cpp b/services/services/lpp_video_streamer/server/lpp_video_streamer_server.cpp index 9b4a3d902..b1d2e2d77 100644 --- a/services/services/lpp_video_streamer/server/lpp_video_streamer_server.cpp +++ b/services/services/lpp_video_streamer/server/lpp_video_streamer_server.cpp @@ -198,6 +198,7 @@ int32_t LppVideoStreamerServer::Stop() int32_t LppVideoStreamerServer::Reset() { MEDIA_LOGI("LppVideoStreamerServer Reset"); + Stop(); CHECK_AND_RETURN_RET_LOG(StateEnter(VideoState::CREATED), MSERR_INVALID_OPERATION, "wrong state"); CHECK_AND_RETURN_RET_LOG(streamerEngine_ != nullptr, MSERR_OK, "streamerEngine_ is nullptr"); streamerEngine_->Reset(); -- Gitee From bcdb9dfefa48bc723343eeebc43bc4c750e0fd47 Mon Sep 17 00:00:00 2001 From: huangtianyu Date: Wed, 6 Aug 2025 02:55:59 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangtianyu --- frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp b/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp index 438ad328f..3811f5cf5 100644 --- a/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp +++ b/frameworks/native/capi/lppplayer/native_lpp_audio_streamer.cpp @@ -452,7 +452,6 @@ OH_AVErrCode OH_LowPowerAudioSink_SetVolume(OH_LowPowerAudioSink *streamer, cons return LppMsErrToOHAvErr(res); } - OH_AVErrCode OH_LowPowerAudioSink_SetLoudnessGain(OH_LowPowerAudioSink* streamer, float loudnessGain) { MEDIA_LOGD("OH_LowPowerAudioSink_SetLoudnessGain"); -- Gitee