From 3e3df5f0e882e85cad21f3d793c6d32bbec41b4a Mon Sep 17 00:00:00 2001 From: w30042960 Date: Tue, 20 Aug 2024 10:46:12 +0800 Subject: [PATCH] modify ffrt Signed-off-by: w30042960 --- bundle.json | 1 + common/BUILD.gn | 1 + services/cameraservice/sinkservice/BUILD.gn | 1 + .../src/distributedcameramgr/dcamera_sink_controller.cpp | 5 +++-- services/cameraservice/sourceservice/BUILD.gn | 1 + .../distributedcamera/dcamera_service_state_listener.cpp | 9 +++++---- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bundle.json b/bundle.json index 995acf6c..b57b835f 100644 --- a/bundle.json +++ b/bundle.json @@ -44,6 +44,7 @@ "c_utils", "cJSON", "dsoftbus", + "ffrt", "ffmpeg", "hicollie", "media_foundation", diff --git a/common/BUILD.gn b/common/BUILD.gn index 7782a902..4eccff8b 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -64,6 +64,7 @@ ohos_shared_library("distributed_camera_utils") { "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", "dsoftbus:softbus_client", + "ffrt:libffrt", "hdf_core:libhdi", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 767bd71e..083295e9 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -119,6 +119,7 @@ ohos_shared_library("distributed_camera_sink") { "drivers_peripheral_display:hdi_gralloc_client", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_surface:surface", "hdf_core:libhdf_utils", "hilog:libhilog", diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp index 7b258cc9..5b2265d7 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -36,6 +36,7 @@ #include "distributed_hardware_log.h" #include "device_security_defines.h" #include "device_security_info.h" +#include "ffrt_inner.h" #include "idistributed_camera_source.h" #include "ipc_skeleton.h" #include "dcamera_low_latency.h" @@ -472,7 +473,7 @@ void DCameraSinkController::OnSessionState(int32_t state) break; case DCAMERA_CHANNEL_STATE_DISCONNECTED: DHLOGI("channel is disconnected"); - std::thread([this]() { + ffrt::submit([this]() { DHLOGI("DCameraSinkController::OnSessionState %{public}s new thread session state: %{public}d", GetAnonyString(dhId_).c_str(), sessionState_); prctl(PR_SET_NAME, CHANNEL_DISCONNECTED.c_str()); @@ -487,7 +488,7 @@ void DCameraSinkController::OnSessionState(int32_t state) DHLOGE("session state: %{public}d, %{public}s stop capture failed, ret: %{public}d", sessionState_, GetAnonyString(dhId_).c_str(), ret); } - }).detach(); + }); break; default: DHLOGE("unknown session state"); diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 53c27fe8..5beae828 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -130,6 +130,7 @@ ohos_shared_library("distributed_camera_source") { "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_surface:surface", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdi", diff --git a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp index 10d13511..58c1a809 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp @@ -22,6 +22,7 @@ #include "distributed_camera_errno.h" #include "distributed_camera_source_service.h" #include "distributed_hardware_log.h" +#include "ffrt_inner.h" #include namespace OHOS { @@ -52,7 +53,7 @@ int32_t DCameraServiceStateListener::OnRegisterNotify(const std::string& devId, std::lock_guard autoLock(proxyMutex_); if (status != DCAMERA_OK) { - std::thread([=]() mutable { + ffrt::submit([=]() mutable { DHLOGI("thread delete devId: %{public}s dhId: %{public}s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); prctl(PR_SET_NAME, REGISTER_SERVICE_NOTIFY.c_str()); @@ -66,7 +67,7 @@ int32_t DCameraServiceStateListener::OnRegisterNotify(const std::string& devId, if (ret != DCAMERA_OK) { DHLOGE("OnNotifyRegResult failed: %{public}d", ret); } - }).detach(); + }); } else { if (callbackProxy_ == nullptr) { DHLOGE("callbackProxy_ is nullptr"); @@ -92,7 +93,7 @@ int32_t DCameraServiceStateListener::OnUnregisterNotify(const std::string& devId } if (status == DCAMERA_OK) { - std::thread([=]() mutable { + ffrt::submit([=]() mutable { DHLOGI("thread delete devId: %{public}s dhId: %{public}s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); prctl(PR_SET_NAME, UNREGISTER_SERVICE_NOTIFY.c_str()); @@ -103,7 +104,7 @@ int32_t DCameraServiceStateListener::OnUnregisterNotify(const std::string& devId if (ret != DCAMERA_OK) { DHLOGE("OnNotifyUnregResult failed, ret: %{public}d", ret); } - }).detach(); + }); } else { int32_t ret = callbackProxy_->OnNotifyUnregResult(devId, dhId, reqId, status, data); if (ret != DCAMERA_OK) { -- Gitee