diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2021-05-04 17:52:04 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-05-04 17:52:04 +0000 |
| commit | 6eb00420f2c2be31e637d84706db806e6e7dadc5 (patch) | |
| tree | fc75dfc08beebf46d3446c20de39e18f91b015de | |
| parent | d87cce4b24e416dca6a43e49d2a48e5360ac9a47 (diff) | |
| parent | 660ec921a8314d734d8c6f33997d4d72686c902f (diff) | |
| download | platform_hardware_google_camera-android11-platform-release.tar.gz platform_hardware_google_camera-android11-platform-release.tar.bz2 platform_hardware_google_camera-android11-platform-release.zip | |
Snap for 7316203 from 660ec921a8314d734d8c6f33997d4d72686c902f to rvc-platform-releaseandroid-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android11-platform-release
Change-Id: I27c21a3cb3efdc704ece3f7ad355af2c639a0e82
| -rw-r--r-- | common/hal/hidl_service/hidl_profiler.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/common/hal/hidl_service/hidl_profiler.cc b/common/hal/hidl_service/hidl_profiler.cc index 3c7e40d..e7e9ab9 100644 --- a/common/hal/hidl_service/hidl_profiler.cc +++ b/common/hal/hidl_service/hidl_profiler.cc @@ -17,6 +17,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "GCH_HidlProfiler" #include <log/log.h> +#include <mutex> #include <utility> #include "hidl_profiler.h" @@ -57,6 +58,8 @@ struct HidlProfiler { }; std::unique_ptr<HidlProfiler> gHidlProfiler = nullptr; +// Mutex to make all API functions mutually exclusive. +std::mutex api_mutex; void StartNewConnector() { if (gHidlProfiler != nullptr && gHidlProfiler->profiler != nullptr) { @@ -80,6 +83,7 @@ void EndProfiler() { } // anonymous namespace std::unique_ptr<HidlProfilerItem> OnCameraOpen() { + std::lock_guard lock(api_mutex); gHidlProfiler = std::make_unique<HidlProfiler>(); if (gHidlProfiler == nullptr || gHidlProfiler->profiler == nullptr) { ALOGE("%s: gHidlProfiler or profiler is nullptr.", __FUNCTION__); @@ -94,6 +98,7 @@ std::unique_ptr<HidlProfilerItem> OnCameraOpen() { } std::unique_ptr<HidlProfilerItem> OnCameraFlush() { + std::lock_guard lock(api_mutex); EndConnector(); if (gHidlProfiler == nullptr) { gHidlProfiler = std::make_unique<HidlProfiler>(); @@ -110,6 +115,7 @@ std::unique_ptr<HidlProfilerItem> OnCameraFlush() { } std::unique_ptr<HidlProfilerItem> OnCameraClose() { + std::lock_guard lock(api_mutex); EndConnector(); if (gHidlProfiler == nullptr) { gHidlProfiler = std::make_unique<HidlProfiler>(); @@ -126,6 +132,7 @@ std::unique_ptr<HidlProfilerItem> OnCameraClose() { } std::unique_ptr<HidlProfilerItem> OnCameraStreamConfigure() { + std::lock_guard lock(api_mutex); EndConnector(); if (gHidlProfiler == nullptr) { gHidlProfiler = std::make_unique<HidlProfiler>(); @@ -146,6 +153,7 @@ std::unique_ptr<HidlProfilerItem> OnCameraStreamConfigure() { } void OnFirstFrameRequest() { + std::lock_guard lock(api_mutex); EndConnector(); if (gHidlProfiler != nullptr && gHidlProfiler->profiler != nullptr) { gHidlProfiler->profiler->Start( @@ -156,6 +164,7 @@ void OnFirstFrameRequest() { } void OnFirstFrameResult() { + std::lock_guard lock(api_mutex); if (gHidlProfiler != nullptr && gHidlProfiler->profiler != nullptr) { gHidlProfiler->profiler->End( "First frame", google::camera_common::Profiler::kInvalidRequestId); |
