From 9d65ddb47024cd3c3d2049ae37a1d2253891d119 Mon Sep 17 00:00:00 2001 From: ruiyangsun Date: Fri, 5 Sep 2025 14:53:24 +0800 Subject: [PATCH 1/3] fix power consumption bug Signed-off-by: ruiyangsun --- .../server/include/audio_endpoint_private.h | 3 ++- services/audio_service/server/src/audio_endpoint.cpp | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/services/audio_service/server/include/audio_endpoint_private.h b/services/audio_service/server/include/audio_endpoint_private.h index 2cac6d59ff..9b86e1e6b4 100644 --- a/services/audio_service/server/include/audio_endpoint_private.h +++ b/services/audio_service/server/include/audio_endpoint_private.h @@ -54,11 +54,12 @@ private: class AudioEndpointInner : public AudioEndpoint { public: + static constexpr int64_t INVALID_DELAY_STOP_TIME = -1; AudioEndpointInner(EndpointType type, uint64_t id, const AudioProcessConfig &clientConfig); ~AudioEndpointInner(); bool Config(const AudioDeviceDescriptor &deviceInfo, AudioStreamInfo &streamInfo) override; - bool StartDevice(EndpointStatus preferredState = INVALID); + bool StartDevice(EndpointStatus preferredState = INVALID, int64_t delayStopTime_ = INVALID_DELAY_STOP_TIME); void HandleStartDeviceFailed(); bool StopDevice(); diff --git a/services/audio_service/server/src/audio_endpoint.cpp b/services/audio_service/server/src/audio_endpoint.cpp index 7425b93b76..2aecb7ab8f 100644 --- a/services/audio_service/server/src/audio_endpoint.cpp +++ b/services/audio_service/server/src/audio_endpoint.cpp @@ -835,7 +835,7 @@ void AudioEndpointInner::ReSyncPosition() return; } -bool AudioEndpointInner::StartDevice(EndpointStatus preferredState) +bool AudioEndpointInner::StartDevice(EndpointStatus preferredState, int64_t delayStopTime) { AUDIO_INFO_LOG("StartDevice enter."); // how to modify the status while unlinked and started? @@ -880,6 +880,7 @@ bool AudioEndpointInner::StartDevice(EndpointStatus preferredState) workThreadCV_.notify_all(); AUDIO_DEBUG_LOG("StartDevice out, status is %{public}s", GetStatusStr(endpointStatus_).c_str()); AudioPerformanceMonitor::GetInstance().RecordTimeStamp(adapterType_, INIT_LASTWRITTEN_TIME); + delayStopTime_ = delayStopTime == INVALID_DELAY_STOP_TIME ? delayStopTime_ : delayStopTime; listLock.unlock(); return true; } @@ -982,13 +983,9 @@ int32_t AudioEndpointInner::OnStart(IAudioProcessStream *processStream) if (endpointStatus_ == IDEL) { // call sink start if (!isStarted_) { - CHECK_AND_RETURN_RET_LOG(StartDevice(RUNNING), ERR_OPERATION_FAILED, "StartDevice failed"); + CHECK_AND_RETURN_RET_LOG(StartDevice(RUNNING, INT64_MAX), ERR_OPERATION_FAILED, "StartDevice failed"); } } - - AudioPerformanceMonitor::GetInstance().RecordTimeStamp(adapterType_, INIT_LASTWRITTEN_TIME); - endpointStatus_ = RUNNING; - delayStopTime_ = INT64_MAX; return SUCCESS; } -- Gitee From 0014c006411c3eff9c899c929d26d74884b93dae Mon Sep 17 00:00:00 2001 From: ruiyangsun Date: Fri, 5 Sep 2025 16:02:09 +0800 Subject: [PATCH 2/3] clean code Signed-off-by: ruiyangsun --- .../audio_service/server/include/audio_endpoint_private.h | 5 +++-- services/audio_service/server/src/audio_endpoint.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/audio_service/server/include/audio_endpoint_private.h b/services/audio_service/server/include/audio_endpoint_private.h index 9b86e1e6b4..840c96fdcd 100644 --- a/services/audio_service/server/include/audio_endpoint_private.h +++ b/services/audio_service/server/include/audio_endpoint_private.h @@ -54,12 +54,13 @@ private: class AudioEndpointInner : public AudioEndpoint { public: - static constexpr int64_t INVALID_DELAY_STOP_TIME = -1; + static constexpr int64_t INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS = -1; AudioEndpointInner(EndpointType type, uint64_t id, const AudioProcessConfig &clientConfig); ~AudioEndpointInner(); bool Config(const AudioDeviceDescriptor &deviceInfo, AudioStreamInfo &streamInfo) override; - bool StartDevice(EndpointStatus preferredState = INVALID, int64_t delayStopTime_ = INVALID_DELAY_STOP_TIME); + bool StartDevice(EndpointStatus preferredState = INVALID, + int64_t delayStopTime_ = INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS); void HandleStartDeviceFailed(); bool StopDevice(); diff --git a/services/audio_service/server/src/audio_endpoint.cpp b/services/audio_service/server/src/audio_endpoint.cpp index 2aecb7ab8f..091842e491 100644 --- a/services/audio_service/server/src/audio_endpoint.cpp +++ b/services/audio_service/server/src/audio_endpoint.cpp @@ -880,7 +880,7 @@ bool AudioEndpointInner::StartDevice(EndpointStatus preferredState, int64_t dela workThreadCV_.notify_all(); AUDIO_DEBUG_LOG("StartDevice out, status is %{public}s", GetStatusStr(endpointStatus_).c_str()); AudioPerformanceMonitor::GetInstance().RecordTimeStamp(adapterType_, INIT_LASTWRITTEN_TIME); - delayStopTime_ = delayStopTime == INVALID_DELAY_STOP_TIME ? delayStopTime_ : delayStopTime; + delayStopTime_ = delayStopTime == INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS ? delayStopTime_ : delayStopTime; listLock.unlock(); return true; } -- Gitee From aed4f740ada07e7f1b2263ab06ac6d3d708957a3 Mon Sep 17 00:00:00 2001 From: ruiyangsun Date: Fri, 5 Sep 2025 17:38:44 +0800 Subject: [PATCH 3/3] fix bug Signed-off-by: ruiyangsun --- services/audio_service/server/src/audio_endpoint.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/audio_service/server/src/audio_endpoint.cpp b/services/audio_service/server/src/audio_endpoint.cpp index 091842e491..dac08eae48 100644 --- a/services/audio_service/server/src/audio_endpoint.cpp +++ b/services/audio_service/server/src/audio_endpoint.cpp @@ -984,8 +984,13 @@ int32_t AudioEndpointInner::OnStart(IAudioProcessStream *processStream) // call sink start if (!isStarted_) { CHECK_AND_RETURN_RET_LOG(StartDevice(RUNNING, INT64_MAX), ERR_OPERATION_FAILED, "StartDevice failed"); + return SUCCESS; } } + + AudioPerformanceMonitor::GetInstance().RecordTimeStamp(adapterType_, INIT_LASTWRITTEN_TIME); + endpointStatus_ = RUNNING; + delayStopTime_ = INT64_MAX; return SUCCESS; } -- Gitee