From 00dbfc57f577c73110c09c4596f24e3dc665c29d Mon Sep 17 00:00:00 2001 From: kw Date: Thu, 21 Aug 2025 14:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A1=E9=A1=BF=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kw --- frameworks/native/audioutils/BUILD.gn | 2 + .../include/audio_performance_monitor.h | 3 +- .../native/audioutils/include/xperf_adapter.h | 42 +++++++++++ .../src/audio_performance_monitor.cpp | 9 ++- .../native/audioutils/src/xperf_adapter.cpp | 74 +++++++++++++++++++ .../unittest/audio_utils_second_unit_test.cpp | 45 +++++++++++ .../pulseaudio/modules/capturer/BUILD.gn | 1 + .../capturer/module_inner_capturer_sink.c | 2 +- .../native/pulseaudio/modules/hdi/hdi_sink.c | 2 +- .../pulseaudio/modules/hdi/hdi_source.c | 2 +- .../pulseaudio/modules/hdi/module_hdi_sink.c | 2 +- .../modules/hdi/module_hdi_source.c | 2 +- .../modules/hdi/module_split_stream_sink.c | 2 +- .../modules/hdi/{config.h => pa_config.h} | 0 .../native/audiocommon/include/audio_info.h | 8 ++ .../server/include/audio_process_in_server.h | 1 + .../server/include/renderer_in_server.h | 1 - .../server/src/audio_process_in_server.cpp | 14 ++++ .../server/src/renderer_in_server.cpp | 20 ++++- 19 files changed, 222 insertions(+), 10 deletions(-) create mode 100644 frameworks/native/audioutils/include/xperf_adapter.h create mode 100644 frameworks/native/audioutils/src/xperf_adapter.cpp rename frameworks/native/pulseaudio/modules/hdi/{config.h => pa_config.h} (100%) diff --git a/frameworks/native/audioutils/BUILD.gn b/frameworks/native/audioutils/BUILD.gn index 2c16a5d0b6..34e8ab75fe 100644 --- a/frameworks/native/audioutils/BUILD.gn +++ b/frameworks/native/audioutils/BUILD.gn @@ -46,6 +46,7 @@ ohos_shared_library("audio_utils") { "./src/dfx_stat.cpp", "./src/dfx_utils.cpp", "./src/volume_ramp.cpp", + "./src/xperf_adapter.cpp", ] public_external_deps = [ "bounds_checking_function:libsec_shared" ] @@ -59,6 +60,7 @@ ohos_shared_library("audio_utils") { "hicollie:libhicollie", "hilog:libhilog", "hitrace:hitrace_meter", + "hiview:xperfservice_client", "init:libbegetutil", "ipc:ipc_single", "media_foundation:media_monitor_client", diff --git a/frameworks/native/audioutils/include/audio_performance_monitor.h b/frameworks/native/audioutils/include/audio_performance_monitor.h index 144a0ea2ff..bcd950bc2f 100644 --- a/frameworks/native/audioutils/include/audio_performance_monitor.h +++ b/frameworks/native/audioutils/include/audio_performance_monitor.h @@ -91,8 +91,9 @@ private: void JudgeNoise(uint32_t index, bool curState, uint32_t uid); void ReportEvent(DetectEvent reasonCode, int32_t periodMs, AudioPipeType pipeType, AdapterType adapterType, - uint32_t uid = 0); + uint32_t uid = 0, uint32_t sessionId = 0); std::string GetRunningHapNames(AdapterType adapterType); + void NotifyXperf(int32_t faultcode, uint32_t uid, uint32_t sessionId); int64_t silenceLastReportTime_ = -1; int64_t overTimeLastReportTime_ = -1; diff --git a/frameworks/native/audioutils/include/xperf_adapter.h b/frameworks/native/audioutils/include/xperf_adapter.h new file mode 100644 index 0000000000..ca856a1857 --- /dev/null +++ b/frameworks/native/audioutils/include/xperf_adapter.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef XPERF_ADAPTER_H +#define XPERF_ADAPTER_H + +#include "audio_info.h" + +namespace OHOS { +namespace AudioStandard { +class XperfAdapter { +public: + static XperfAdapter& GetInstance(); + + void ReportStateChangeEventIfNeed(int32_t eventId, StreamUsage usage, uint32_t sessionId, int32_t pid, int32_t uid); + + void ReportFaultEvent(int32_t faultcode, uint32_t uid, uint32_t sessionId); +private: + XperfAdapter() = default; + ~XperfAdapter() = default; + + XperfAdapter(XperfAdapter&&) = delete; + XperfAdapter& operator=(const XperfAdapter&) = delete; + XperfAdapter& operator=(XperfAdapter&&) = delete; + + bool NeedNotifyXperf(StreamUsage usage); +}; +} // namespace AudioStandard +} // namespace OHOS +#endif //XPERF_ADAPTER_H \ No newline at end of file diff --git a/frameworks/native/audioutils/src/audio_performance_monitor.cpp b/frameworks/native/audioutils/src/audio_performance_monitor.cpp index cff561a939..96a58e169c 100644 --- a/frameworks/native/audioutils/src/audio_performance_monitor.cpp +++ b/frameworks/native/audioutils/src/audio_performance_monitor.cpp @@ -18,6 +18,7 @@ #include "audio_performance_monitor.h" #include "audio_performance_monitor_c.h" +#include "xperf_adapter.h" #include #include #include "audio_errors.h" @@ -211,11 +212,17 @@ std::string AudioPerformanceMonitor::GetRunningHapNames(AdapterType adapterType) return hapNames.str(); } +void AudioPerformanceMonitor::NotifyXperf(int32_t faultcode, uint32_t uid, uint32_t sessionId) +{ + XperfAdapter::GetInstance().ReportFaultEvent(faultcode, uid, sessionId); +} + void AudioPerformanceMonitor::ReportEvent(DetectEvent reasonCode, int32_t periodMs, AudioPipeType pipeType, - AdapterType adapterType, uint32_t uid) + AdapterType adapterType, uint32_t uid, uint32_t sessionId) { int64_t curRealTime = ClockTime::GetRealNano(); std::string hapNames = ""; + NotifyXperf(reasonCode, uid, sessionId); switch (reasonCode) { case SILENCE_EVENT: CHECK_AND_RETURN_LOG(curRealTime - silenceLastReportTime_ >= MIN_REPORT_INTERVAL_MS * AUDIO_NS_PER_MS, diff --git a/frameworks/native/audioutils/src/xperf_adapter.cpp b/frameworks/native/audioutils/src/xperf_adapter.cpp new file mode 100644 index 0000000000..78cb328303 --- /dev/null +++ b/frameworks/native/audioutils/src/xperf_adapter.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LOG_TAG +#define LOG_TAG "XperfAdapter" +#endif + +#include "xperf_adapter.h" +#include "xperf_service_client.h" +#include "audio_info.h" + +namespace OHOS { +namespace AudioStandard { +XperfAdapter& XperfAdapter::GetInstance() +{ + static XperfAdapter instance; + return instance; +} + +bool XperfAdapter::NeedNotifyXperf(StreamUsage usage) +{ + if ((usage == STREAM_USAGE_MUSIC) || (usage == STREAM_USAGE_VOICE_COMMUNICATION) || + (usage == STREAM_USAGE_MOVIE)) { + return true; + } + + return false; +} + +void XperfAdapter::ReportStateChangeEventIfNeed(int32_t eventId, StreamUsage usage, uint32_t sessionId, + int32_t pid, int32_t uid) +{ + if (!NeedNotifyXperf(usage)) { + return; + } + auto timeNow = std::chrono::system_clock::now(); + auto durationSinceEpochMs = std::chrono::duration_cast(timeNow.time_since_epoch()); + + const std::string msg = "#UNIQUEID:" + std::to_string(sessionId) + + "#PID:" + std::to_string(pid) + + "#BUNDLE_NAME:" + std::to_string(uid) + + "#HAPPEN_TIME:" + std::to_string(durationSinceEpochMs.count()) + + "#STATUS:" + std::to_string(eventId); + + OHOS::HiviewDFX::XperfServiceClient::GetInstance().NotifyToXperf(HiviewDFX::DomainId::AUDIO, eventId, msg); +} + +void XperfAdapter::ReportFaultEvent(int32_t faultcode, uint32_t uid, uint32_t sessionId) +{ + auto timeNow = std::chrono::system_clock::now(); + auto durationSinceEpochMs = std::chrono::duration_cast(timeNow.time_since_epoch()); + + const std::string msg = "#UNIQUEID:" + std::to_string(sessionId) + + "#FAULT_ID:" + std::to_string(0) + + "#FAULT_CODE:" + std::to_string(faultcode) + + "#HAPPEN_TIME:" + std::to_string(durationSinceEpochMs.count()); + + OHOS::HiviewDFX::XperfServiceClient::GetInstance().NotifyToXperf(HiviewDFX::DomainId::AUDIO, + XPERF_EVENT_FAULT, msg); +} +} // namespace AudioStandard +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/audioutils/test/unittest/audio_utils_second_unit_test.cpp b/frameworks/native/audioutils/test/unittest/audio_utils_second_unit_test.cpp index 887a4612d6..4034d4f16b 100644 --- a/frameworks/native/audioutils/test/unittest/audio_utils_second_unit_test.cpp +++ b/frameworks/native/audioutils/test/unittest/audio_utils_second_unit_test.cpp @@ -26,6 +26,7 @@ #include "audio_scope_exit.h" #include "audio_safe_block_queue.h" #include "audio_utils_c.h" +#include "xperf_adapter.h" using namespace testing::ext; using namespace testing; @@ -274,5 +275,49 @@ HWTEST(AudioUtilsUnitTest, AudioLatencyMeasurement_001, TestSize.Level1) AudioLatencyMeasurement audioLatencyMeasurement(44100, 2, 16, "com.example.null", 1); EXPECT_EQ(audioLatencyMeasurement.sessionId_, 1); } + +/** + * @tc.name : Test NeedNotifyXperf API + * @tc.type : FUNC + * @tc.number: XperfAdapterNeedNotifyXperf_001 + * @tc.desc : Test NeedNotifyXperf. + */ +HWTEST(AudioUtilsUnitTest, XperfAdapterNeedNotifyXperf_001, TestSize.Level1) +{ + EXPECT_EQ(XperfAdapter::GetInstance().NeedNotifyXperf(STREAM_USAGE_MEDIA), true); +} + +/** + * @tc.name : Test NeedNotifyXperf API + * @tc.type : FUNC + * @tc.number: XperfAdapterNeedNotifyXperf_002 + * @tc.desc : Test NeedNotifyXperf. + */ +HWTEST(AudioUtilsUnitTest, XperfAdapterNeedNotifyXperf_002, TestSize.Level1) +{ + EXPECT_EQ(XperfAdapter::GetInstance().NeedNotifyXperf(STREAM_USAGE_VOICE_COMMUNICATION), true); +} + +/** + * @tc.name : Test NeedNotifyXperf API + * @tc.type : FUNC + * @tc.number: XperfAdapterNeedNotifyXperf_003 + * @tc.desc : Test NeedNotifyXperf. + */ +HWTEST(AudioUtilsUnitTest, XperfAdapterNeedNotifyXperf_003, TestSize.Level1) +{ + EXPECT_EQ(XperfAdapter::GetInstance().NeedNotifyXperf(STREAM_USAGE_MOVIE), true); +} + +/** + * @tc.name : Test NeedNotifyXperf API + * @tc.type : FUNC + * @tc.number: XperfAdapterNeedNotifyXperf_004 + * @tc.desc : Test NeedNotifyXperf. + */ +HWTEST(AudioUtilsUnitTest, XperfAdapterNeedNotifyXperf_004, TestSize.Level1) +{ + EXPECT_EQ(XperfAdapter::GetInstance().NeedNotifyXperf(STREAM_USAGE_NOTIFICATION_RINGTONE), false); +} } // namespace AudioStandard } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/pulseaudio/modules/capturer/BUILD.gn b/frameworks/native/pulseaudio/modules/capturer/BUILD.gn index 133f5edbf0..4f42a890d9 100644 --- a/frameworks/native/pulseaudio/modules/capturer/BUILD.gn +++ b/frameworks/native/pulseaudio/modules/capturer/BUILD.gn @@ -18,6 +18,7 @@ config("capturer_config") { visibility = [ ":*" ] include_dirs = [ + "../hdi/", "../../../../../interfaces/inner_api/native/audiocommon/include", "../../../../../services/audio_service/common/include", "../../../audioschedule/include", diff --git a/frameworks/native/pulseaudio/modules/capturer/module_inner_capturer_sink.c b/frameworks/native/pulseaudio/modules/capturer/module_inner_capturer_sink.c index 56443737e9..b20bd09a1c 100644 --- a/frameworks/native/pulseaudio/modules/capturer/module_inner_capturer_sink.c +++ b/frameworks/native/pulseaudio/modules/capturer/module_inner_capturer_sink.c @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include #endif #ifndef LOG_TAG diff --git a/frameworks/native/pulseaudio/modules/hdi/hdi_sink.c b/frameworks/native/pulseaudio/modules/hdi/hdi_sink.c index 4c3814f484..f84286a81a 100644 --- a/frameworks/native/pulseaudio/modules/hdi/hdi_sink.c +++ b/frameworks/native/pulseaudio/modules/hdi/hdi_sink.c @@ -16,7 +16,7 @@ #define LOG_TAG "HdiSink" #endif -#include +#include #include #include #include diff --git a/frameworks/native/pulseaudio/modules/hdi/hdi_source.c b/frameworks/native/pulseaudio/modules/hdi/hdi_source.c index 9ec6dacac5..76ea84996d 100644 --- a/frameworks/native/pulseaudio/modules/hdi/hdi_source.c +++ b/frameworks/native/pulseaudio/modules/hdi/hdi_source.c @@ -16,7 +16,7 @@ #define LOG_TAG "HdiSource" #endif -#include +#include #include #include #include diff --git a/frameworks/native/pulseaudio/modules/hdi/module_hdi_sink.c b/frameworks/native/pulseaudio/modules/hdi/module_hdi_sink.c index 6ac5305bca..8579129764 100644 --- a/frameworks/native/pulseaudio/modules/hdi/module_hdi_sink.c +++ b/frameworks/native/pulseaudio/modules/hdi/module_hdi_sink.c @@ -13,7 +13,7 @@ * limitations under the License. */ -#include +#include #include #include #include diff --git a/frameworks/native/pulseaudio/modules/hdi/module_hdi_source.c b/frameworks/native/pulseaudio/modules/hdi/module_hdi_source.c index f5b849e65a..53a000c1f8 100644 --- a/frameworks/native/pulseaudio/modules/hdi/module_hdi_source.c +++ b/frameworks/native/pulseaudio/modules/hdi/module_hdi_source.c @@ -15,7 +15,7 @@ #undef LOG_TAG #define LOG_TAG "ModuleHdiSource" -#include +#include #include #include #include diff --git a/frameworks/native/pulseaudio/modules/hdi/module_split_stream_sink.c b/frameworks/native/pulseaudio/modules/hdi/module_split_stream_sink.c index 0ef04f1a5b..9619fcbfeb 100644 --- a/frameworks/native/pulseaudio/modules/hdi/module_split_stream_sink.c +++ b/frameworks/native/pulseaudio/modules/hdi/module_split_stream_sink.c @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include #endif #undef LOG_TAG diff --git a/frameworks/native/pulseaudio/modules/hdi/config.h b/frameworks/native/pulseaudio/modules/hdi/pa_config.h similarity index 100% rename from frameworks/native/pulseaudio/modules/hdi/config.h rename to frameworks/native/pulseaudio/modules/hdi/pa_config.h diff --git a/interfaces/inner_api/native/audiocommon/include/audio_info.h b/interfaces/inner_api/native/audiocommon/include/audio_info.h index 85bfda844c..3f52472783 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_info.h @@ -1949,6 +1949,14 @@ enum BoostTriggerMethod : uint32_t { METHOD_WRITE_OR_READ, METHOD_MAX }; + +enum XperfEventId : int32_t { + XPERF_EVENT_START = 0, + XPERF_EVENT_STOP = 1, + XPERF_EVENT_RELEASE = 2, + XPERF_EVENT_FAULT = 3, + XPERF_EVENT_MAX = 4, +}; } // namespace AudioStandard } // namespace OHOS #endif // AUDIO_INFO_H diff --git a/services/audio_service/server/include/audio_process_in_server.h b/services/audio_service/server/include/audio_process_in_server.h index 12869f6f9c..eb5bc69881 100644 --- a/services/audio_service/server/include/audio_process_in_server.h +++ b/services/audio_service/server/include/audio_process_in_server.h @@ -155,6 +155,7 @@ private: bool CheckBGCapturer(); void WriterRenderStreamStandbySysEvent(uint32_t sessionId, int32_t standby); void ReportDataToResSched(std::unordered_map payload, uint32_t type); + void NotifyXperfOnPlayback(AudioMode audioMode, XperfEventId eventId); private: std::atomic muteFlag_ = false; diff --git a/services/audio_service/server/include/renderer_in_server.h b/services/audio_service/server/include/renderer_in_server.h index d713046253..83cdfd36bb 100644 --- a/services/audio_service/server/include/renderer_in_server.h +++ b/services/audio_service/server/include/renderer_in_server.h @@ -148,7 +148,6 @@ public: int32_t SetAudioHapticsSyncId(const int32_t &audioHapticsSyncId); void InitDupBuffer(int32_t innerCapId); - public: const AudioProcessConfig processConfig_; private: diff --git a/services/audio_service/server/src/audio_process_in_server.cpp b/services/audio_service/server/src/audio_process_in_server.cpp index fe5501d79a..18e8423dc3 100644 --- a/services/audio_service/server/src/audio_process_in_server.cpp +++ b/services/audio_service/server/src/audio_process_in_server.cpp @@ -20,6 +20,7 @@ #include "policy_handler.h" #include "securec.h" +#include "xperf_adapter.h" #include "iprocess_cb.h" #include "audio_errors.h" #include "audio_capturer_log.h" @@ -93,6 +94,7 @@ AudioProcessInServer::~AudioProcessInServer() if (processConfig_.audioMode == AUDIO_MODE_RECORD && needCheckBackground_) { TurnOffMicIndicator(CAPTURER_INVALID); } + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_RELEASE); AudioStreamMonitor::GetInstance().DeleteCheckForMonitor(processConfig_.originalSessionId); } @@ -338,6 +340,7 @@ int32_t AudioProcessInServer::StartInner() processBuffer_->SetLastWrittenTime(ClockTime::GetCurNano()); AudioPerformanceMonitor::GetInstance().StartSilenceMonitor(sessionId_, processConfig_.appInfo.appTokenId); + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_START); AUDIO_INFO_LOG("Start in server success!"); return SUCCESS; } @@ -376,6 +379,7 @@ int32_t AudioProcessInServer::Pause(bool isFlush) CoreServiceHandler::GetInstance().UpdateSessionOperation(sessionId_, SESSION_OPERATION_PAUSE); StreamDfxManager::GetInstance().CheckStreamOccupancy(sessionId_, processConfig_, false); AudioPerformanceMonitor::GetInstance().PauseSilenceMonitor(sessionId_); + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_STOP); AUDIO_PRERELEASE_LOGI("Pause in server success!"); return SUCCESS; } @@ -403,6 +407,7 @@ int32_t AudioProcessInServer::Resume() processBuffer_->SetLastWrittenTime(ClockTime::GetCurNano()); CoreServiceHandler::GetInstance().UpdateSessionOperation(sessionId_, SESSION_OPERATION_START); audioStreamChecker_->MonitorOnAllCallback(AUDIO_STREAM_START, false); + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_START); AUDIO_PRERELEASE_LOGI("Resume in server success!"); return SUCCESS; } @@ -446,6 +451,7 @@ int32_t AudioProcessInServer::Stop(int32_t stage) CoreServiceHandler::GetInstance().UpdateSessionOperation(sessionId_, SESSION_OPERATION_STOP); StreamDfxManager::GetInstance().CheckStreamOccupancy(sessionId_, processConfig_, false); AudioPerformanceMonitor::GetInstance().PauseSilenceMonitor(sessionId_); + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_STOP); AUDIO_INFO_LOG("Stop in server success!"); return SUCCESS; } @@ -469,6 +475,7 @@ int32_t AudioProcessInServer::Release(bool isSwitchStream) CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, ret, "Policy remove client failed, reason: %{public}d", ret); StreamDfxManager::GetInstance().CheckStreamOccupancy(sessionId_, processConfig_, false); ret = releaseCallback_->OnProcessRelease(this, isSwitchStream); + NotifyXperfOnPlayback(processConfig_.audioMode, XPERF_EVENT_RELEASE); AUDIO_INFO_LOG("notify service release result: %{public}d", ret); return SUCCESS; } @@ -877,5 +884,12 @@ uint32_t AudioProcessInServer::GetByteSizePerFrame() { return byteSizePerFrame_; } + +void AudioProcessInServer::NotifyXperfOnPlayback(AudioMode audioMode, XperfEventId eventId) { + CHECK_AND_RETURN(audioMode == AUDIO_MODE_PLAYBACK); + XperfAdapter::GetInstance().ReportStateChangeEventIfNeed(eventId, + processConfig_.rendererInfo.streamUsage, sessionId_, processConfig_.appInfo.appPid, + processConfig_.appInfo.appUid); +} } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_service/server/src/renderer_in_server.cpp b/services/audio_service/server/src/renderer_in_server.cpp index 70a59ae23e..c7bdba5f01 100644 --- a/services/audio_service/server/src/renderer_in_server.cpp +++ b/services/audio_service/server/src/renderer_in_server.cpp @@ -17,13 +17,16 @@ #endif #include "renderer_in_server.h" +#include #include #include "securec.h" +#include #include "audio_errors.h" #include "audio_renderer_log.h" #include "audio_utils.h" #include "audio_service.h" #include "futex_tool.h" +#include "xperf_adapter.h" #include "i_stream_manager.h" #ifdef RESSCHE_ENABLE #include "res_type.h" @@ -969,6 +972,11 @@ int32_t RendererInServer::Start() if (ret == SUCCESS) { StreamDfxManager::GetInstance().CheckStreamOccupancy(streamIndex_, processConfig_, true); } + + XperfAdapter::GetInstance().ReportStateChangeEventIfNeed(XPERF_EVENT_START, + processConfig_.rendererInfo.streamUsage, streamIndex_, processConfig_.appInfo.appPid, + processConfig_.appInfo.appUid); + return ret; } @@ -1112,6 +1120,9 @@ int32_t RendererInServer::Pause() audioStreamChecker_->MonitorOnAllCallback(AUDIO_STREAM_PAUSE, isStandbyTmp); StreamDfxManager::GetInstance().CheckStreamOccupancy(streamIndex_, processConfig_, false); AudioPerformanceMonitor::GetInstance().PauseSilenceMonitor(streamIndex_); + XperfAdapter::GetInstance().ReportStateChangeEventIfNeed(XPERF_EVENT_STOP, + processConfig_.rendererInfo.streamUsage, streamIndex_, processConfig_.appInfo.appPid, + processConfig_.appInfo.appUid); return SUCCESS; } @@ -1240,7 +1251,11 @@ int32_t RendererInServer::Stop() } status_ = I_STATUS_STOPPING; } - return StopInner(); + int32_t ret = StopInner(); + XperfAdapter::GetInstance().ReportStateChangeEventIfNeed(XPERF_EVENT_STOP, + processConfig_.rendererInfo.streamUsage, streamIndex_, processConfig_.appInfo.appPid, + processConfig_.appInfo.appUid); + return ret; } int32_t RendererInServer::StopInner() @@ -1331,6 +1346,9 @@ int32_t RendererInServer::Release(bool isSwitchStream) if (isDualToneEnabled_) { DisableDualTone(); } + XperfAdapter::GetInstance().ReportStateChangeEventIfNeed(XPERF_EVENT_RELEASE, + processConfig_.rendererInfo.streamUsage, streamIndex_, processConfig_.appInfo.appPid, + processConfig_.appInfo.appUid); return SUCCESS; } -- Gitee