From 215595cb34cf774e2c3d39ee396c34d50ddbb5de Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Thu, 14 Apr 2022 17:51:50 +0800 Subject: [PATCH 1/5] join error: add joinable Signed-off-by: wangwenjun --- .../decoder/src/image_sink_decoder.cpp | 4 +++- .../screensourcetrans/src/screen_source_trans.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index a210198f..6f5d6543 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -279,7 +279,9 @@ int32_t ImageSinkDecoder::StopInputThread() { DHLOGI("%s: StopInputThread.", LOG_TAG); isDecoderReady_ = false; - decodeThread_.join(); + if (decodeThread_.joinable()) { + decodeThread_.join(); + } std::lock_guard dataLock(dataMutex_); while (!bufferIndexQueue_.empty()) { bufferIndexQueue_.pop(); diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index 6d2ef574..0d0133e9 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -121,7 +121,9 @@ int32_t ScreenSourceTrans::Stop() stopStatus = false; } isChannelReady_ = false; - sendDataThread_.join(); + if (sendDataThread_.joinable()) { + sendDataThread_.join(); + } if (!stopStatus) { DHLOGE("%s: Stop source trans failed.", LOG_TAG); @@ -309,7 +311,9 @@ void ScreenSourceTrans::OnSessionClosed() { DHLOGI("%s: OnChannelSessionClosed.", LOG_TAG); isChannelReady_ = false; - sendDataThread_.join(); + if (sendDataThread_.joinable()) { + sendDataThread_.join(); + } std::shared_ptr callback = transCallback_.lock(); if (!callback) { -- Gitee From 9e9447badf1c32cb9d80a49eb0c318a4cfbd8701 Mon Sep 17 00:00:00 2001 From: wangwenjun <178124181@qq.com> Date: Mon, 18 Apr 2022 15:28:54 +0800 Subject: [PATCH 2/5] add hitrace Signed-off-by: wangwenjun <178124181@qq.com> --- common/BUILD.gn | 1 + common/include/dscreen_hitrace.h | 78 +++++++++++++++++++ .../sourceservice/dscreenmgr/src/dscreen.cpp | 24 +++++- .../dscreenmgr/src/dscreen_manager.cpp | 21 +++++ .../dscreenmgr/src/screen_manager_adapter.cpp | 2 + 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 common/include/dscreen_hitrace.h diff --git a/common/BUILD.gn b/common/BUILD.gn index 7dd03dcd..17038a32 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -33,6 +33,7 @@ ohos_shared_library("distributed_screen_utils") { external_deps = [ "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", + "bytrace_standard:bytrace_core", ] defines = [ diff --git a/common/include/dscreen_hitrace.h b/common/include/dscreen_hitrace.h new file mode 100644 index 00000000..250f5ed0 --- /dev/null +++ b/common/include/dscreen_hitrace.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 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 OHOS_DSCREEN_HITRACE_H +#define OHOS_DSCREEN_HITRACE_H + +#include + +#include "bytrace.h" + +namespace OHOS { +namespace DistributedHardware { +const std::string DSCREEN_HANDLER_TASK_START = "DSCREEN_HANDLER_START"; +const std::string DSCREEN_HANDLER_TASK_ENABLE_START = "DSCREEN_HANDLER_TASK_ENABLE_START"; +const std::string DSCREEN_HANDLER_TASK_DISABLE_START = "DSCREEN_HANDLER_TASK_DISABLE_START"; +const std::string DSCREEN_HANDLER_TASK_CONNECT_START = "DSCREEN_HANDLER_TASK_CONNECT_START"; +const std::string DSCREEN_HANDLER_TASK_DISCONNECT_START = "DSCREEN_HANDLER_TASK_DISCONNECT_START"; + +constexpr uint64_t DSCREEN_HANDLER_TASK_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_TASK_ENABLE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_TASK_DISABLE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_TASK_CONNECT_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_TASK_DISCONNECT_LABEL = BYTRACE_TAG_OHOS; + +const std::string DSCREEN_HANDLER_ENABLE_START = "DSCREEN_HANDLER_ENABLE_START"; +const std::string DSCREEN_HANDLER_DISENABLE_START = "DSCREEN_HANDLER_DISENABLE_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK0_START = "DSCREEN_HANDLER_ENABLE_CALLBACK0_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK1_START = "DSCREEN_HANDLER_ENABLE_CALLBACK1_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK2_START = "DSCREEN_HANDLER_ENABLE_CALLBACK2_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK3_START = "DSCREEN_HANDLER_ENABLE_CALLBACK3_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK4_START = "DSCREEN_HANDLER_ENABLE_CALLBACK4_START"; +const std::string DSCREEN_HANDLER_ENABLE_CALLBACK5_START = "DSCREEN_HANDLER_ENABLE_CALLBACK5_START"; +const std::string DSCREEN_NEGOTIATE_CODEC_START = "DSCREEN_NEGOTIATE_CODEC_START"; +const std::string DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START = "DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START"; +const std::string DSCREEN_DISABLE_DISTRIBUTED_SCREEN_START = "DSCREEN_DISABLE_DISTRIBUTED_SCREEN_START"; +const std::string DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START = "DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START"; +const std::string DSCREEN_GETDISCREEN_SINK_START = "DSCREEN_GETDISCREEN_SINK_START"; +const std::string DSCREEN_CREATE_VIRTUAL_SCREEN_START = "DSCREEN_CREATE_VIRTUAL_SCREEN_START"; + +constexpr uint64_t DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_GETDISCREEN_SINK_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_DISENABLE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_NEGOTIATE_CODEC_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL = BYTRACE_TAG_OHOS; + +enum TASKID { + DSCREEN_CALLBACK0, + DSCREEN_CALLBACK1, + DSCREEN_CALLBACK2, + DSCREEN_CALLBACK3, + DSCREEN_CALLBACK4, + DSCREEN_CALLBACK5, + DSCREEN_CALLBACK5, +}; +} +} +#endif \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index d6e73fdb..77bfb8a0 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -20,6 +20,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hitrace.h" #include "dscreen_log.h" #include "dscreen_util.h" #include "screen_manager_adapter.h" @@ -158,32 +159,44 @@ void DScreen::TaskThreadLoop() void DScreen::HandleTask(const std::shared_ptr &task) { + StartTrace(DSCREEN_HANDLER_TASK_LABEL, DSCREEN_HANDLER_TASK_START); int32_t taskType = task->GetTaskType(); DHLOGI("HandleTask, devId: %s, dhId: %s, task type: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), taskType); switch (taskType) { case TaskType::TASK_ENABLE: + StartTrace(DSCREEN_HANDLER_TASK_ENABLE_LABEL, DSCREEN_HANDLER_TASK_ENABLE_START); HandleEnable(task->GetTaskParam(), task->GetTaskId()); + FinishTrace(DSCREEN_HANDLER_TASK_ENABLE_LABEL); break; case TaskType::TASK_DISABLE: + StartTrace(DSCREEN_HANDLER_TASK_DISABLE_LABEL, DSCREEN_HANDLER_TASK_DISABLE_START); HandleDisable(task->GetTaskId()); + FinishTrace(DSCREEN_HANDLER_TASK_DISABLE_LABEL); break; case TaskType::TASK_CONNECT: + StartTrace(DSCREEN_HANDLER_TASK_CONNECT_LABEL, DSCREEN_HANDLER_TASK_CONNECT_START); HandleConnect(); + FinishTrace(DSCREEN_HANDLER_TASK_CONNECT_LABEL); break; case TaskType::TASK_DISCONNECT: + StartTrace(DSCREEN_HANDLER_TASK_DISCONNECT_LABEL, DSCREEN_HANDLER_TASK_DISCONNECT_START); HandleDisconnect(); + FinishTrace(DSCREEN_HANDLER_TASK_DISCONNECT_LABEL); break; default: DHLOGD("task type unkown."); } + FinishTrace(DSCREEN_HANDLER_TASK_LABEL); } void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) { + StartTrace(DSCREEN_HANDLER_ENABLE_LABEL, DSCREEN_HANDLER_ENABLE_START); DHLOGI("HandleEnable, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); if (curState_ == ENABLED || curState_ == ENABLING || curState_ == CONNECTING || curState_ == CONNECTED) { + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK0_START, DSCREEN_CALLBACK0); dscreenCallback_->OnRegResult(shared_from_this(), taskId, DH_SUCCESS, ""); return; } @@ -196,6 +209,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) json attrJson = json::parse(param, nullptr, false); if (attrJson.is_discarded()) { DHLOGE("enable param json is invalid."); + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK1_START, DSCREEN_CALLBACK1); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "enable param json is invalid."); return; @@ -204,6 +218,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) if (!attrJson.contains(KEY_SCREEN_WIDTH) || !attrJson.contains(KEY_SCREEN_HEIGHT) || !attrJson.contains(KEY_CODECTYPE)) { + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK2_START, DSCREEN_CALLBACK2); DHLOGE("enable param is invalid."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "enable param is invalid."); @@ -216,6 +231,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) // negotiate codecType int32_t ret = NegotiateCodecType(attrJson[KEY_CODECTYPE]); if (ret != DH_SUCCESS) { + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK3_START, DSCREEN_CALLBACK3); DHLOGE("negotiate codec type failed."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "negotiate codec type failed."); @@ -224,6 +240,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) uint64_t screenId = ScreenMgrAdapter::GetInstance().CreateVirtualScreen(devId_, dhId_, videoParam_); if (screenId == SCREEN_ID_INVALID) { + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK4_START, DSCREEN_CALLBACK4); DHLOGE("create virtual screen failed."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "create virtual screen failed."); @@ -231,11 +248,14 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) } screenId_ = screenId; SetState(ENABLED); + StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK5_START, DSCREEN_CALLBACK5); dscreenCallback_->OnRegResult(shared_from_this(), taskId, DH_SUCCESS, ""); + FinishTrace(DSCREEN_HANDLER_ENABLE_LABEL); } int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) { + StartTrace(DSCREEN_NEGOTIATE_CODEC_LABEL, DSCREEN_NEGOTIATE_CODEC_START); json remoteCodecArray = json::parse(remoteCodecInfoStr, nullptr, false); if (remoteCodecArray.is_discarded() || !remoteCodecArray.is_array()) { DHLOGE("remoteCodecInfoStrjson is invalid."); @@ -271,12 +291,13 @@ int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) DHLOGI("codec type not support."); return ERR_DH_SCREEN_SA_DSCREEN_NEGOTIATE_CODEC_FAIL; } - + FinishTrace(DSCREEN_NEGOTIATE_CODEC_LABEL); return DH_SUCCESS; } void DScreen::HandleDisable(const std::string &taskId) { + StartTrace(DSCREEN_HANDLER_DISENABLE_LABEL, DSCREEN_HANDLER_ENABLE_START); DHLOGI("HandleDisable, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); SetState(DISABLING); Stop(); @@ -289,6 +310,7 @@ void DScreen::HandleDisable(const std::string &taskId) } SetState(DISABLED); dscreenCallback_->OnUnregResult(shared_from_this(), taskId, DH_SUCCESS, ""); + FinishTrace(DSCREEN_HANDLER_DISENABLE_LABEL); } void DScreen::HandleConnect() diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp index 49812b88..23847604 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp @@ -21,6 +21,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hitrace.h" #include "dscreen_log.h" #include "dscreen_util.h" #include "idscreen_sink.h" @@ -160,6 +161,18 @@ void DScreenCallback::OnRegResult(const std::shared_ptr &dScreen, DHLOGI("DScreenCallback::OnRegResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); DScreenManager::GetInstance().OnRegResult(dScreen, reqId, status, data); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK0_START, + DSCREEN_CALLBACK0); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK1_START, + DSCREEN_CALLBACK1); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK2_START, + DSCREEN_CALLBACK2); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK3_START, + DSCREEN_CALLBACK3); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK4_START, + DSCREEN_CALLBACK4); + FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK5_START, + DSCREEN_CALLBACK5); } void DScreenCallback::OnUnregResult(const std::shared_ptr &dScreen, @@ -197,6 +210,7 @@ void DScreenManager::OnUnregResult(const std::shared_ptr &dScreen, int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const std::string &dhId, const std::string &attrs, const std::string &reqId) { + StartTrace(DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL, DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START); DHLOGI("EnableDistributedScreen, devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); if (!dScreenCallback_) { @@ -226,12 +240,14 @@ int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const DHLOGE("EnableDistributedScreen, add task failed. devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); } + FinishTrace(DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL); return ret; } int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const std::string &dhId, const std::string &reqId) { + StartTrace(DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL, DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START); DHLOGI("DisableDistributedScreen, devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); @@ -266,6 +282,7 @@ int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const ret = ERR_DH_SCREEN_SA_DISABLE_FAILED; break; } + FinishTrace(DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL); return ret; } @@ -328,6 +345,7 @@ int32_t DScreenManager::NotifyRemoteScreenService(const std::string &devId, int3 sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) { DHLOGI("GetDScreenSinkSA, devId: %s", GetAnonyString(devId).c_str()); + StartTrace(DSCREEN_GETDISCREEN_SINK_LABEL, DSCREEN_GETDISCREEN_SINK_START); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { @@ -345,6 +363,7 @@ sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) DHLOGE("Failed to get remote dscreen sink sa"); return nullptr; } + FinishTrace(DSCREEN_GETDISCREEN_SINK_LABEL); return remoteSinkSA; } @@ -378,6 +397,7 @@ void DScreenManager::NotifyRemoteSinkSetUp(const std::shared_ptr &dScre void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, const std::string &eventContent) { DHLOGI("HandleNotifySetUpResult, remoteDevId:%s", GetAnonyString(remoteDevId).c_str()); + StartTrace(DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL, DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START); json eventContentJson = json::parse(eventContent, nullptr, false); if (eventContentJson.is_discarded()) { DHLOGE("HandleNotifySetUpResult, eventContent is invalid"); @@ -409,6 +429,7 @@ void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, con } dScreens_[dScreenIdx]->AddTask(std::make_shared(TaskType::TASK_CONNECT, "")); + FinishTrace(DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp index 4f0850bf..50d39ad5 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp @@ -38,6 +38,7 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s { DHLOGI("CreateVirtualScreen, width: %u, height: %u", videoParam->GetScreenWidth(), videoParam->GetScreenHeight()); + StartTrace(DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL, DSCREEN_CREATE_VIRTUAL_SCREEN_START); std::string screenName = DSCREEN_PREFIX + SEPERATOR + devId + SEPERATOR + dhId; Rosen::VirtualScreenOption option = { screenName, @@ -50,6 +51,7 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s }; uint64_t screenId = Rosen::ScreenManager::GetInstance().CreateVirtualScreen(option); + FinishTrace(DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL); return screenId; } -- Gitee From 28e5db881e302f53156467600821dc9b55a9cab7 Mon Sep 17 00:00:00 2001 From: wangwenjun <178124181@qq.com> Date: Mon, 18 Apr 2022 17:22:40 +0800 Subject: [PATCH 3/5] add hitrace code. Signed-off-by: wangwenjun <178124181@qq.com> --- common/include/dscreen_hitrace.h | 32 +++++++++++++++++++ .../src/dscreen_source_service.cpp | 8 +++++ .../src/screen_data_channel_impl.cpp | 17 ++++++++++ .../decoder/src/image_decoder_callback.cpp | 8 +++++ 4 files changed, 65 insertions(+) diff --git a/common/include/dscreen_hitrace.h b/common/include/dscreen_hitrace.h index 250f5ed0..f7b764f4 100644 --- a/common/include/dscreen_hitrace.h +++ b/common/include/dscreen_hitrace.h @@ -48,7 +48,39 @@ const std::string DSCREEN_DISABLE_DISTRIBUTED_SCREEN_START = "DSCREEN_DISABLE_DI const std::string DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START = "DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START"; const std::string DSCREEN_GETDISCREEN_SINK_START = "DSCREEN_GETDISCREEN_SINK_START"; const std::string DSCREEN_CREATE_VIRTUAL_SCREEN_START = "DSCREEN_CREATE_VIRTUAL_SCREEN_START"; +const std::string DSCREEN_INIT_SOURCE_START = "DSCREEN_INIT_SOURCE_START"; +const std::string DSCREEN_RELEASE_SOURCE_START = "DSCREEN_RELEASE_SOURCE_START"; +const std::string DSCREEN_REGISTER_DISTRIBUTED_START = "DSCREEN_REGISTER_DISTRIBUTED_START"; +const std::string DSCREEN_UNREGISTER_DISTRIBUTED_START = "DSCREEN_UNREGISTER_DISTRIBUTED_START"; +const std::string DSCREEN_CREAT_SESSION_START = "DSCREEN_CREAT_SESSION_START"; +const std::string DSCREEN_RELEASE_SESSION_START = "DSCREEN_RELEASE_SESSION_START"; +const std::string DSCREEN_OPEN_SESSION_START = "DSCREEN_OPEN_SESSION_START"; +const std::string DSCREEN_CLOSE_SESSION_START = "DSCREEN_CLOSE_SESSION_START"; +const std::string DSCREEN_SEND_DATA_START = "DSCREEN_SEND_DATA_START"; +const std::string DSCREEN_ON_SESSION_OPEN_START = "DSCREEN_ON_SESSION_OPEN_START"; +const std::string DSCREEN_ON_SESSION_CLOSE_START = "DSCREEN_ON_SESSION_CLOSE_START"; +const std::string DSCREEN_ON_STREAM_RECEIVED_START = "DSCREEN_ON_STREAM_RECEIVED_START"; +const std::string DSCREEN_IMAGE_DECODER_CALLBACK_START = "DSCREEN_IMAGE_DECODER_CALLBACK_START"; +const std::string DSCREEN_ON_OUTPUT_BUFFER_START = "DSCREEN_ON_OUTPUT_BUFFER_START"; +const std::string DSCREEN_ONINPUT_BUFFER_START = "DSCREEN_ONINPUT_BUFFER_START"; +const std::string DSCREEN_ON_OUTPUT_FORMAT_START = "DSCREEN_ON_OUTPUT_FORMAT_START"; +constexpr uint64_t DSCREEN_IMAGE_DECODER_CALLBACK_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ON_OUTPUT_BUFFER_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ONINPUT_BUFFER_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ON_OUTPUT_FORMAT_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_CREAT_SESSION_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_RELEASE_SESSION_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_OPEN_SESSION_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_CLOSE_SESSION_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_SEND_DATA_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ON_SESSION_OPEN_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ON_SESSION_CLOSE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_ON_STREAM_RECEIVED_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_INIT_SOURCE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_RELEASE_SOURCE_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_REGISTER_DISTRIBUTED_LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t DSCREEN_UNREGISTER_DISTRIBUTED_LABEL = BYTRACE_TAG_OHOS; constexpr uint64_t DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL = BYTRACE_TAG_OHOS; constexpr uint64_t DSCREEN_GETDISCREEN_SINK_LABEL = BYTRACE_TAG_OHOS; constexpr uint64_t DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL = BYTRACE_TAG_OHOS; diff --git a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index e1cb0ef3..c3dec782 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -75,6 +75,7 @@ bool DScreenSourceService::Init() int32_t DScreenSourceService::InitSource(const std::string ¶ms, const sptr &callback) { DHLOGI("InitSource"); + StartTrace(DSCREEN_INIT_SOURCE_LABEL, DSCREEN_INIT_SOURCE_START); int32_t ret = DScreenManager::GetInstance().Init(); if (ret != DH_SUCCESS) { DHLOGE("Init DScreenManager failed. err: %d", ret); @@ -82,17 +83,20 @@ int32_t DScreenSourceService::InitSource(const std::string ¶ms, const sptr &listener) { + StartTrace(DSCREEN_CREAT_SESSION_LABEL, DSCREEN_CREAT_SESSION_START); DHLOGI("%s: CreateSession, peerDevId(%s)", LOG_TAG, GetAnonyString(peerDevId_).c_str()); if (!listener) { DHLOGE("%s: Channel listener is null", LOG_TAG); @@ -48,11 +50,13 @@ int32_t ScreenDataChannelImpl::CreateSession(const std::shared_ptr &screenData) { + StartTrace(DSCREEN_SEND_DATA_LABEL, DSCREEN_SEND_DATA_START); DHLOGD("%s: SendData, sessionId(%d)", LOG_TAG, sessionId_); if (!screenData) { DHLOGE("%s: Screen data is null", LOG_TAG); @@ -122,11 +132,13 @@ int32_t ScreenDataChannelImpl::SendData(const std::shared_ptr &scree return ret; } + FinishTrace(DSCREEN_SEND_DATA_LABEL); return DH_SUCCESS; } void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) { + StartTrace(DSCREEN_ON_SESSION_OPEN_LABEL, DSCREEN_ON_SESSION_OPEN_START); DHLOGI("%s: OnScreenSessionOpened, sessionId: %d, result: %d", LOG_TAG, sessionId, result); if (result != 0) { DHLOGE("Session open failed.", LOG_TAG); @@ -140,10 +152,12 @@ void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) } listener->OnSessionOpened(); sessionId_ = sessionId; + FinishTrace(DSCREEN_ON_SESSION_OPEN_LABEL); } void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) { + StartTrace(DSCREEN_ON_SESSION_CLOSE_LABEL, DSCREEN_ON_SESSION_CLOSE_START); DHLOGI("%s: OnScreenSessionClosed, sessionId(%d).", LOG_TAG, sessionId); std::shared_ptr listener = channelListener_.lock(); if (!listener) { @@ -151,6 +165,7 @@ void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) return; } listener->OnSessionClosed(); + FinishTrace(DSCREEN_ON_SESSION_CLOSE_LABEL); } void ScreenDataChannelImpl::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) @@ -165,6 +180,7 @@ void ScreenDataChannelImpl::OnBytesReceived(int32_t sessionId, const void *data, void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param) { + StartTrace(DSCREEN_ON_STREAM_RECEIVED_LABEL, DSCREEN_ON_STREAM_RECEIVED_START); (void)ext; (void)param; @@ -192,6 +208,7 @@ void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData return; } listener->OnDataReceived(dataBuffer); + FinishTrace(DSCREEN_ON_STREAM_RECEIVED_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp index b19fb870..05a8dfb2 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp @@ -22,6 +22,7 @@ namespace OHOS { namespace DistributedHardware { void ImageDecoderCallback::OnError(Media::AVCodecErrorType errorType, int32_t errorCode) { + StartTrace(DSCREEN_IMAGE_DECODER_CALLBACK_LABEL, DSCREEN_IMAGE_DECODER_CALLBACK_START); DHLOGD("%s: OnError.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -29,11 +30,13 @@ void ImageDecoderCallback::OnError(Media::AVCodecErrorType errorType, int32_t er return; } decoder->OnError(errorType, errorCode); + FinishTrace(DSCREEN_IMAGE_DECODER_CALLBACK_LABEL); } void ImageDecoderCallback::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBufferInfo info, Media::AVCodecBufferFlag flag) { + StartTrace(DSCREEN_ON_OUTPUT_BUFFER_LABEL, DSCREEN_ON_OUTPUT_BUFFER_START); DHLOGD("%s: OnOutputBufferAvailable.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -41,10 +44,12 @@ void ImageDecoderCallback::OnOutputBufferAvailable(uint32_t index, Media::AVCode return; } decoder->OnOutputBufferAvailable(index, info, flag); + FinishTrace(DSCREEN_ON_OUTPUT_BUFFER_LABEL); } void ImageDecoderCallback::OnInputBufferAvailable(uint32_t index) { + StartTrace(DSCREEN_ONINPUT_BUFFER_LABEL, DSCREEN_ONINPUT_BUFFER_START); DHLOGD("%s: OnInputBufferAvailable.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -52,10 +57,12 @@ void ImageDecoderCallback::OnInputBufferAvailable(uint32_t index) return; } decoder->OnInputBufferAvailable(index); + FinishTrace(DSCREEN_ONINPUT_BUFFER_LABEL); } void ImageDecoderCallback::OnOutputFormatChanged(const Media::Format &format) { + StartTrace(DSCREEN_ON_OUTPUT_FORMAT_LABEL, DSCREEN_ON_OUTPUT_FORMAT_START); DHLOGD("%s: OnOutputFormatChanged.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -63,6 +70,7 @@ void ImageDecoderCallback::OnOutputFormatChanged(const Media::Format &format) return; } decoder->OnOutputFormatChanged(format); + FinishTrace(DSCREEN_ON_OUTPUT_FORMAT_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee From 2a607bcbe398db830b264ffdb3bd9782ff267973 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Tue, 19 Apr 2022 09:49:17 +0800 Subject: [PATCH 4/5] join error: add joinable Signed-off-by: wangwenjun --- common/include/dscreen_hitrace.h | 110 ------------------ .../sourceservice/dscreenmgr/src/dscreen.cpp | 22 ---- .../dscreenmgr/src/dscreen_manager.cpp | 21 ---- .../dscreenmgr/src/screen_manager_adapter.cpp | 2 - .../src/dscreen_source_service.cpp | 8 -- .../src/screen_data_channel_impl.cpp | 16 --- .../decoder/src/image_decoder_callback.cpp | 8 -- 7 files changed, 187 deletions(-) delete mode 100644 common/include/dscreen_hitrace.h diff --git a/common/include/dscreen_hitrace.h b/common/include/dscreen_hitrace.h deleted file mode 100644 index f7b764f4..00000000 --- a/common/include/dscreen_hitrace.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2022 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 OHOS_DSCREEN_HITRACE_H -#define OHOS_DSCREEN_HITRACE_H - -#include - -#include "bytrace.h" - -namespace OHOS { -namespace DistributedHardware { -const std::string DSCREEN_HANDLER_TASK_START = "DSCREEN_HANDLER_START"; -const std::string DSCREEN_HANDLER_TASK_ENABLE_START = "DSCREEN_HANDLER_TASK_ENABLE_START"; -const std::string DSCREEN_HANDLER_TASK_DISABLE_START = "DSCREEN_HANDLER_TASK_DISABLE_START"; -const std::string DSCREEN_HANDLER_TASK_CONNECT_START = "DSCREEN_HANDLER_TASK_CONNECT_START"; -const std::string DSCREEN_HANDLER_TASK_DISCONNECT_START = "DSCREEN_HANDLER_TASK_DISCONNECT_START"; - -constexpr uint64_t DSCREEN_HANDLER_TASK_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_TASK_ENABLE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_TASK_DISABLE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_TASK_CONNECT_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_TASK_DISCONNECT_LABEL = BYTRACE_TAG_OHOS; - -const std::string DSCREEN_HANDLER_ENABLE_START = "DSCREEN_HANDLER_ENABLE_START"; -const std::string DSCREEN_HANDLER_DISENABLE_START = "DSCREEN_HANDLER_DISENABLE_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK0_START = "DSCREEN_HANDLER_ENABLE_CALLBACK0_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK1_START = "DSCREEN_HANDLER_ENABLE_CALLBACK1_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK2_START = "DSCREEN_HANDLER_ENABLE_CALLBACK2_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK3_START = "DSCREEN_HANDLER_ENABLE_CALLBACK3_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK4_START = "DSCREEN_HANDLER_ENABLE_CALLBACK4_START"; -const std::string DSCREEN_HANDLER_ENABLE_CALLBACK5_START = "DSCREEN_HANDLER_ENABLE_CALLBACK5_START"; -const std::string DSCREEN_NEGOTIATE_CODEC_START = "DSCREEN_NEGOTIATE_CODEC_START"; -const std::string DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START = "DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START"; -const std::string DSCREEN_DISABLE_DISTRIBUTED_SCREEN_START = "DSCREEN_DISABLE_DISTRIBUTED_SCREEN_START"; -const std::string DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START = "DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START"; -const std::string DSCREEN_GETDISCREEN_SINK_START = "DSCREEN_GETDISCREEN_SINK_START"; -const std::string DSCREEN_CREATE_VIRTUAL_SCREEN_START = "DSCREEN_CREATE_VIRTUAL_SCREEN_START"; -const std::string DSCREEN_INIT_SOURCE_START = "DSCREEN_INIT_SOURCE_START"; -const std::string DSCREEN_RELEASE_SOURCE_START = "DSCREEN_RELEASE_SOURCE_START"; -const std::string DSCREEN_REGISTER_DISTRIBUTED_START = "DSCREEN_REGISTER_DISTRIBUTED_START"; -const std::string DSCREEN_UNREGISTER_DISTRIBUTED_START = "DSCREEN_UNREGISTER_DISTRIBUTED_START"; -const std::string DSCREEN_CREAT_SESSION_START = "DSCREEN_CREAT_SESSION_START"; -const std::string DSCREEN_RELEASE_SESSION_START = "DSCREEN_RELEASE_SESSION_START"; -const std::string DSCREEN_OPEN_SESSION_START = "DSCREEN_OPEN_SESSION_START"; -const std::string DSCREEN_CLOSE_SESSION_START = "DSCREEN_CLOSE_SESSION_START"; -const std::string DSCREEN_SEND_DATA_START = "DSCREEN_SEND_DATA_START"; -const std::string DSCREEN_ON_SESSION_OPEN_START = "DSCREEN_ON_SESSION_OPEN_START"; -const std::string DSCREEN_ON_SESSION_CLOSE_START = "DSCREEN_ON_SESSION_CLOSE_START"; -const std::string DSCREEN_ON_STREAM_RECEIVED_START = "DSCREEN_ON_STREAM_RECEIVED_START"; -const std::string DSCREEN_IMAGE_DECODER_CALLBACK_START = "DSCREEN_IMAGE_DECODER_CALLBACK_START"; -const std::string DSCREEN_ON_OUTPUT_BUFFER_START = "DSCREEN_ON_OUTPUT_BUFFER_START"; -const std::string DSCREEN_ONINPUT_BUFFER_START = "DSCREEN_ONINPUT_BUFFER_START"; -const std::string DSCREEN_ON_OUTPUT_FORMAT_START = "DSCREEN_ON_OUTPUT_FORMAT_START"; - -constexpr uint64_t DSCREEN_IMAGE_DECODER_CALLBACK_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ON_OUTPUT_BUFFER_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ONINPUT_BUFFER_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ON_OUTPUT_FORMAT_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_CREAT_SESSION_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_RELEASE_SESSION_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_OPEN_SESSION_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_CLOSE_SESSION_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_SEND_DATA_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ON_SESSION_OPEN_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ON_SESSION_CLOSE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ON_STREAM_RECEIVED_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_INIT_SOURCE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_RELEASE_SOURCE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_REGISTER_DISTRIBUTED_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_UNREGISTER_DISTRIBUTED_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_GETDISCREEN_SINK_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_DISENABLE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_NEGOTIATE_CODEC_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL = BYTRACE_TAG_OHOS; -constexpr uint64_t DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL = BYTRACE_TAG_OHOS; - -enum TASKID { - DSCREEN_CALLBACK0, - DSCREEN_CALLBACK1, - DSCREEN_CALLBACK2, - DSCREEN_CALLBACK3, - DSCREEN_CALLBACK4, - DSCREEN_CALLBACK5, - DSCREEN_CALLBACK5, -}; -} -} -#endif \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index 77bfb8a0..05506e33 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -20,7 +20,6 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" -#include "dscreen_hitrace.h" #include "dscreen_log.h" #include "dscreen_util.h" #include "screen_manager_adapter.h" @@ -159,44 +158,32 @@ void DScreen::TaskThreadLoop() void DScreen::HandleTask(const std::shared_ptr &task) { - StartTrace(DSCREEN_HANDLER_TASK_LABEL, DSCREEN_HANDLER_TASK_START); int32_t taskType = task->GetTaskType(); DHLOGI("HandleTask, devId: %s, dhId: %s, task type: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), taskType); switch (taskType) { case TaskType::TASK_ENABLE: - StartTrace(DSCREEN_HANDLER_TASK_ENABLE_LABEL, DSCREEN_HANDLER_TASK_ENABLE_START); HandleEnable(task->GetTaskParam(), task->GetTaskId()); - FinishTrace(DSCREEN_HANDLER_TASK_ENABLE_LABEL); break; case TaskType::TASK_DISABLE: - StartTrace(DSCREEN_HANDLER_TASK_DISABLE_LABEL, DSCREEN_HANDLER_TASK_DISABLE_START); HandleDisable(task->GetTaskId()); - FinishTrace(DSCREEN_HANDLER_TASK_DISABLE_LABEL); break; case TaskType::TASK_CONNECT: - StartTrace(DSCREEN_HANDLER_TASK_CONNECT_LABEL, DSCREEN_HANDLER_TASK_CONNECT_START); HandleConnect(); - FinishTrace(DSCREEN_HANDLER_TASK_CONNECT_LABEL); break; case TaskType::TASK_DISCONNECT: - StartTrace(DSCREEN_HANDLER_TASK_DISCONNECT_LABEL, DSCREEN_HANDLER_TASK_DISCONNECT_START); HandleDisconnect(); - FinishTrace(DSCREEN_HANDLER_TASK_DISCONNECT_LABEL); break; default: DHLOGD("task type unkown."); } - FinishTrace(DSCREEN_HANDLER_TASK_LABEL); } void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) { - StartTrace(DSCREEN_HANDLER_ENABLE_LABEL, DSCREEN_HANDLER_ENABLE_START); DHLOGI("HandleEnable, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); if (curState_ == ENABLED || curState_ == ENABLING || curState_ == CONNECTING || curState_ == CONNECTED) { - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK0_START, DSCREEN_CALLBACK0); dscreenCallback_->OnRegResult(shared_from_this(), taskId, DH_SUCCESS, ""); return; } @@ -209,7 +196,6 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) json attrJson = json::parse(param, nullptr, false); if (attrJson.is_discarded()) { DHLOGE("enable param json is invalid."); - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK1_START, DSCREEN_CALLBACK1); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "enable param json is invalid."); return; @@ -218,7 +204,6 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) if (!attrJson.contains(KEY_SCREEN_WIDTH) || !attrJson.contains(KEY_SCREEN_HEIGHT) || !attrJson.contains(KEY_CODECTYPE)) { - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK2_START, DSCREEN_CALLBACK2); DHLOGE("enable param is invalid."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "enable param is invalid."); @@ -231,7 +216,6 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) // negotiate codecType int32_t ret = NegotiateCodecType(attrJson[KEY_CODECTYPE]); if (ret != DH_SUCCESS) { - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK3_START, DSCREEN_CALLBACK3); DHLOGE("negotiate codec type failed."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "negotiate codec type failed."); @@ -240,7 +224,6 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) uint64_t screenId = ScreenMgrAdapter::GetInstance().CreateVirtualScreen(devId_, dhId_, videoParam_); if (screenId == SCREEN_ID_INVALID) { - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK4_START, DSCREEN_CALLBACK4); DHLOGE("create virtual screen failed."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "create virtual screen failed."); @@ -248,14 +231,11 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) } screenId_ = screenId; SetState(ENABLED); - StartAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK5_START, DSCREEN_CALLBACK5); dscreenCallback_->OnRegResult(shared_from_this(), taskId, DH_SUCCESS, ""); - FinishTrace(DSCREEN_HANDLER_ENABLE_LABEL); } int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) { - StartTrace(DSCREEN_NEGOTIATE_CODEC_LABEL, DSCREEN_NEGOTIATE_CODEC_START); json remoteCodecArray = json::parse(remoteCodecInfoStr, nullptr, false); if (remoteCodecArray.is_discarded() || !remoteCodecArray.is_array()) { DHLOGE("remoteCodecInfoStrjson is invalid."); @@ -297,7 +277,6 @@ int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) void DScreen::HandleDisable(const std::string &taskId) { - StartTrace(DSCREEN_HANDLER_DISENABLE_LABEL, DSCREEN_HANDLER_ENABLE_START); DHLOGI("HandleDisable, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); SetState(DISABLING); Stop(); @@ -310,7 +289,6 @@ void DScreen::HandleDisable(const std::string &taskId) } SetState(DISABLED); dscreenCallback_->OnUnregResult(shared_from_this(), taskId, DH_SUCCESS, ""); - FinishTrace(DSCREEN_HANDLER_DISENABLE_LABEL); } void DScreen::HandleConnect() diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp index 23847604..49812b88 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp @@ -21,7 +21,6 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" -#include "dscreen_hitrace.h" #include "dscreen_log.h" #include "dscreen_util.h" #include "idscreen_sink.h" @@ -161,18 +160,6 @@ void DScreenCallback::OnRegResult(const std::shared_ptr &dScreen, DHLOGI("DScreenCallback::OnRegResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); DScreenManager::GetInstance().OnRegResult(dScreen, reqId, status, data); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK0_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK0_START, - DSCREEN_CALLBACK0); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK1_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK1_START, - DSCREEN_CALLBACK1); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK2_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK2_START, - DSCREEN_CALLBACK2); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK3_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK3_START, - DSCREEN_CALLBACK3); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK4_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK4_START, - DSCREEN_CALLBACK4); - FinishAsyncTrace(DSCREEN_HANDLER_ENABLE_CALLBACK5_LABEL, DSCREEN_HANDLER_ENABLE_CALLBACK5_START, - DSCREEN_CALLBACK5); } void DScreenCallback::OnUnregResult(const std::shared_ptr &dScreen, @@ -210,7 +197,6 @@ void DScreenManager::OnUnregResult(const std::shared_ptr &dScreen, int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const std::string &dhId, const std::string &attrs, const std::string &reqId) { - StartTrace(DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL, DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START); DHLOGI("EnableDistributedScreen, devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); if (!dScreenCallback_) { @@ -240,14 +226,12 @@ int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const DHLOGE("EnableDistributedScreen, add task failed. devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); } - FinishTrace(DSCREEN_ENABLE_DISTRIBUTED_SCREEN_LABEL); return ret; } int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const std::string &dhId, const std::string &reqId) { - StartTrace(DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL, DSCREEN_ENABLE_DISTRIBUTED_SCREEN_START); DHLOGI("DisableDistributedScreen, devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); @@ -282,7 +266,6 @@ int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const ret = ERR_DH_SCREEN_SA_DISABLE_FAILED; break; } - FinishTrace(DSCREEN_DISABLE_DISTRIBUTED_SCREEN_LABEL); return ret; } @@ -345,7 +328,6 @@ int32_t DScreenManager::NotifyRemoteScreenService(const std::string &devId, int3 sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) { DHLOGI("GetDScreenSinkSA, devId: %s", GetAnonyString(devId).c_str()); - StartTrace(DSCREEN_GETDISCREEN_SINK_LABEL, DSCREEN_GETDISCREEN_SINK_START); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { @@ -363,7 +345,6 @@ sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) DHLOGE("Failed to get remote dscreen sink sa"); return nullptr; } - FinishTrace(DSCREEN_GETDISCREEN_SINK_LABEL); return remoteSinkSA; } @@ -397,7 +378,6 @@ void DScreenManager::NotifyRemoteSinkSetUp(const std::shared_ptr &dScre void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, const std::string &eventContent) { DHLOGI("HandleNotifySetUpResult, remoteDevId:%s", GetAnonyString(remoteDevId).c_str()); - StartTrace(DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL, DSCREEN_HANDLE_NOTIFY_SETUPRESULT_START); json eventContentJson = json::parse(eventContent, nullptr, false); if (eventContentJson.is_discarded()) { DHLOGE("HandleNotifySetUpResult, eventContent is invalid"); @@ -429,7 +409,6 @@ void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, con } dScreens_[dScreenIdx]->AddTask(std::make_shared(TaskType::TASK_CONNECT, "")); - FinishTrace(DSCREEN_HANDLE_NOTIFY_SETUPRESULT_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp index 50d39ad5..4f0850bf 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp @@ -38,7 +38,6 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s { DHLOGI("CreateVirtualScreen, width: %u, height: %u", videoParam->GetScreenWidth(), videoParam->GetScreenHeight()); - StartTrace(DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL, DSCREEN_CREATE_VIRTUAL_SCREEN_START); std::string screenName = DSCREEN_PREFIX + SEPERATOR + devId + SEPERATOR + dhId; Rosen::VirtualScreenOption option = { screenName, @@ -51,7 +50,6 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s }; uint64_t screenId = Rosen::ScreenManager::GetInstance().CreateVirtualScreen(option); - FinishTrace(DSCREEN_CREATE_VIRTUAL_SCREEN_LABEL); return screenId; } diff --git a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index c3dec782..f6bac28b 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -75,14 +75,12 @@ bool DScreenSourceService::Init() int32_t DScreenSourceService::InitSource(const std::string ¶ms, const sptr &callback) { DHLOGI("InitSource"); - StartTrace(DSCREEN_INIT_SOURCE_LABEL, DSCREEN_INIT_SOURCE_START); int32_t ret = DScreenManager::GetInstance().Init(); if (ret != DH_SUCCESS) { DHLOGE("Init DScreenManager failed. err: %d", ret); return ret; } - DScreenManager::GetInstance().RegisterDScreenCallback(callback); FinishTrace(DSCREEN_INIT_SOURCE_LABEL); return DH_SUCCESS; } @@ -90,13 +88,11 @@ int32_t DScreenSourceService::InitSource(const std::string ¶ms, const sptr &listener) { - StartTrace(DSCREEN_CREAT_SESSION_LABEL, DSCREEN_CREAT_SESSION_START); DHLOGI("%s: CreateSession, peerDevId(%s)", LOG_TAG, GetAnonyString(peerDevId_).c_str()); if (!listener) { DHLOGE("%s: Channel listener is null", LOG_TAG); @@ -50,13 +49,11 @@ int32_t ScreenDataChannelImpl::CreateSession(const std::shared_ptr &screenData) { - StartTrace(DSCREEN_SEND_DATA_LABEL, DSCREEN_SEND_DATA_START); DHLOGD("%s: SendData, sessionId(%d)", LOG_TAG, sessionId_); if (!screenData) { DHLOGE("%s: Screen data is null", LOG_TAG); @@ -132,13 +123,11 @@ int32_t ScreenDataChannelImpl::SendData(const std::shared_ptr &scree return ret; } - FinishTrace(DSCREEN_SEND_DATA_LABEL); return DH_SUCCESS; } void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) { - StartTrace(DSCREEN_ON_SESSION_OPEN_LABEL, DSCREEN_ON_SESSION_OPEN_START); DHLOGI("%s: OnScreenSessionOpened, sessionId: %d, result: %d", LOG_TAG, sessionId, result); if (result != 0) { DHLOGE("Session open failed.", LOG_TAG); @@ -152,12 +141,10 @@ void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) } listener->OnSessionOpened(); sessionId_ = sessionId; - FinishTrace(DSCREEN_ON_SESSION_OPEN_LABEL); } void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) { - StartTrace(DSCREEN_ON_SESSION_CLOSE_LABEL, DSCREEN_ON_SESSION_CLOSE_START); DHLOGI("%s: OnScreenSessionClosed, sessionId(%d).", LOG_TAG, sessionId); std::shared_ptr listener = channelListener_.lock(); if (!listener) { @@ -165,7 +152,6 @@ void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) return; } listener->OnSessionClosed(); - FinishTrace(DSCREEN_ON_SESSION_CLOSE_LABEL); } void ScreenDataChannelImpl::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) @@ -180,7 +166,6 @@ void ScreenDataChannelImpl::OnBytesReceived(int32_t sessionId, const void *data, void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param) { - StartTrace(DSCREEN_ON_STREAM_RECEIVED_LABEL, DSCREEN_ON_STREAM_RECEIVED_START); (void)ext; (void)param; @@ -208,7 +193,6 @@ void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData return; } listener->OnDataReceived(dataBuffer); - FinishTrace(DSCREEN_ON_STREAM_RECEIVED_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp index 05a8dfb2..b19fb870 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace DistributedHardware { void ImageDecoderCallback::OnError(Media::AVCodecErrorType errorType, int32_t errorCode) { - StartTrace(DSCREEN_IMAGE_DECODER_CALLBACK_LABEL, DSCREEN_IMAGE_DECODER_CALLBACK_START); DHLOGD("%s: OnError.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -30,13 +29,11 @@ void ImageDecoderCallback::OnError(Media::AVCodecErrorType errorType, int32_t er return; } decoder->OnError(errorType, errorCode); - FinishTrace(DSCREEN_IMAGE_DECODER_CALLBACK_LABEL); } void ImageDecoderCallback::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBufferInfo info, Media::AVCodecBufferFlag flag) { - StartTrace(DSCREEN_ON_OUTPUT_BUFFER_LABEL, DSCREEN_ON_OUTPUT_BUFFER_START); DHLOGD("%s: OnOutputBufferAvailable.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -44,12 +41,10 @@ void ImageDecoderCallback::OnOutputBufferAvailable(uint32_t index, Media::AVCode return; } decoder->OnOutputBufferAvailable(index, info, flag); - FinishTrace(DSCREEN_ON_OUTPUT_BUFFER_LABEL); } void ImageDecoderCallback::OnInputBufferAvailable(uint32_t index) { - StartTrace(DSCREEN_ONINPUT_BUFFER_LABEL, DSCREEN_ONINPUT_BUFFER_START); DHLOGD("%s: OnInputBufferAvailable.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -57,12 +52,10 @@ void ImageDecoderCallback::OnInputBufferAvailable(uint32_t index) return; } decoder->OnInputBufferAvailable(index); - FinishTrace(DSCREEN_ONINPUT_BUFFER_LABEL); } void ImageDecoderCallback::OnOutputFormatChanged(const Media::Format &format) { - StartTrace(DSCREEN_ON_OUTPUT_FORMAT_LABEL, DSCREEN_ON_OUTPUT_FORMAT_START); DHLOGD("%s: OnOutputFormatChanged.", LOG_TAG); std::shared_ptr decoder = videoDecoder_.lock(); if (decoder == nullptr) { @@ -70,7 +63,6 @@ void ImageDecoderCallback::OnOutputFormatChanged(const Media::Format &format) return; } decoder->OnOutputFormatChanged(format); - FinishTrace(DSCREEN_ON_OUTPUT_FORMAT_LABEL); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee From 1d4abc18ebb7bc10106988de0f4e19bb5e512a03 Mon Sep 17 00:00:00 2001 From: wangying <“wangying320@h-partners.com”> Date: Thu, 21 Apr 2022 11:23:16 +0800 Subject: [PATCH 5/5] Null pointer is called. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangying <“wangying320@h-partners.com”> --- .../native_cpp/screen_sink/src/dscreen_sink_handler.cpp | 2 +- .../native_cpp/screen_source/src/dscreen_source_handler.cpp | 2 +- .../sinkservice/screenregionmgr/src/screenregion.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 8f4472cc..8efd4b3f 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -121,7 +121,7 @@ void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) return; } std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_) { dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = nullptr; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index ed5e3c0f..825f04a7 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -151,7 +151,7 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo return; } std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; } diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp index 9fdf73b1..25bb4114 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp @@ -37,7 +37,7 @@ ScreenRegion::ScreenRegion(const std::string &remoteDevId, uint64_t screenId, ui ScreenRegion::~ScreenRegion() { DHLOGD("ScreenRegion deConstruct"); - if (!sinkTrans_) { + if (sinkTrans_) { sinkTrans_->Release(); } } -- Gitee