sm7125-common: sensors: Fix locking around setOperationMode and activate

Change-Id: I9a09f45f012662c8f92fa40da3a4b9dd691a1b2c
fourteen-wip
Cosmin Tanislav 3 years ago committed by Simon1511
parent 19a1c19c93
commit e74890f56a
  1. 4
      sensors/Sensor.cpp

@ -83,8 +83,8 @@ void Sensor::batch(int32_t samplingPeriodNs) {
}
void Sensor::activate(bool enable) {
std::lock_guard<std::mutex> lock(mRunMutex);
if (mIsEnabled != enable) {
std::unique_lock<std::mutex> lock(mRunMutex);
mIsEnabled = enable;
mWaitCV.notify_all();
}
@ -158,8 +158,8 @@ std::vector<Event> Sensor::readEvents() {
}
void Sensor::setOperationMode(OperationMode mode) {
std::lock_guard<std::mutex> lock(mRunMutex);
if (mMode != mode) {
std::unique_lock<std::mutex> lock(mRunMutex);
mMode = mode;
mWaitCV.notify_all();
}

Loading…
Cancel
Save