diff --git a/bundle.json b/bundle.json index 995acf6c661f020e38f165acc3bcbef2d1e486c5..b57b835f0925ed57dd1974d8900326475a66c228 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 7782a902e41afbb24699541bf9c41b9c61d72050..4eccff8b0ff8d71dc4aeebcc1267a063c6ea02c0 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 fdf1276a0e474250151522e96d795bfa6997637d..c2731760cd0986f8f464f4b603a8b7e011f30b79 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -113,6 +113,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 39dad30f7f87b88d6606e0d61ce15ddce9645cec..bf0f0d146d5ac1d66bccd7dc37f604cebd63afce 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -38,6 +38,7 @@ #include "device_security_defines.h" #include "device_security_info.h" #endif +#include "ffrt_inner.h" #include "idistributed_camera_source.h" #include "ipc_skeleton.h" #include "dcamera_low_latency.h" @@ -488,7 +489,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()); @@ -503,7 +504,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 53c27fe8f435551b25cf0d8376156b14f01a5cd0..5beae8280f1a0b5d5f55466485f59eb36cb44675 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 10d1351149b8ff750b481631eab75121d6e3fa31..58c1a80963778a6f1526cb75c60ddfc1eea17151 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) {