From e74890f56aea9de71111cde67731b7e79665e0b9 Mon Sep 17 00:00:00 2001 From: Cosmin Tanislav Date: Sat, 19 Feb 2022 23:34:29 +0200 Subject: [PATCH] sm7125-common: sensors: Fix locking around setOperationMode and activate Change-Id: I9a09f45f012662c8f92fa40da3a4b9dd691a1b2c --- sensors/Sensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors/Sensor.cpp b/sensors/Sensor.cpp index 73a9567..991e723 100644 --- a/sensors/Sensor.cpp +++ b/sensors/Sensor.cpp @@ -83,8 +83,8 @@ void Sensor::batch(int32_t samplingPeriodNs) { } void Sensor::activate(bool enable) { + std::lock_guard lock(mRunMutex); if (mIsEnabled != enable) { - std::unique_lock lock(mRunMutex); mIsEnabled = enable; mWaitCV.notify_all(); } @@ -158,8 +158,8 @@ std::vector Sensor::readEvents() { } void Sensor::setOperationMode(OperationMode mode) { + std::lock_guard lock(mRunMutex); if (mMode != mode) { - std::unique_lock lock(mRunMutex); mMode = mode; mWaitCV.notify_all(); }