From e1e361ed439d41af24b01c10cda5f2ecae10abdd Mon Sep 17 00:00:00 2001 From: sangweilin Date: Sun, 19 Mar 2023 14:28:53 +0800 Subject: [PATCH] catch mutex when notify sampling rate changed, otherwise signal may be lost Change-Id: Ib52f26e731808ecbe5fd2a53fcd8a47ab3882902 Signed-off-by: sangweilin --- sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp b/sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp index a0bb67a3f9..d8e292a0da 100644 --- a/sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp +++ b/sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp @@ -76,6 +76,7 @@ void Sensor::batch(int64_t samplingPeriodNs) { static_cast(mSensorInfo.minDelay) * 1000, static_cast(mSensorInfo.maxDelay) * 1000); + std::unique_lock lock(mRunMutex); if (mSamplingPeriodNs != samplingPeriodNs) { mSamplingPeriodNs = samplingPeriodNs; // Wake up the 'run' thread to check if a new event should be generated now