blob: 66906e950c86b65e1f13303d8adf236013b21d3f [file] [log] [blame]
Dan Stozaec460082018-12-17 15:35:09 -08001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define ATRACE_TAG ATRACE_TAG_GRAPHICS
19#undef LOG_TAG
20#define LOG_TAG "RegionSamplingThread"
21
22#include "RegionSamplingThread.h"
23
Kevin DuBois413287f2019-02-25 08:46:47 -080024#include <cutils/properties.h>
Dan Stozaec460082018-12-17 15:35:09 -080025#include <gui/IRegionSamplingListener.h>
26#include <utils/Trace.h>
Kevin DuBois413287f2019-02-25 08:46:47 -080027#include <string>
Dan Stozaec460082018-12-17 15:35:09 -080028
Kevin DuBoisb325c932019-05-21 08:34:09 -070029#include <compositionengine/Display.h>
30#include <compositionengine/impl/OutputCompositionState.h>
Dan Stozaec460082018-12-17 15:35:09 -080031#include "DisplayDevice.h"
32#include "Layer.h"
33#include "SurfaceFlinger.h"
34
35namespace android {
Kevin DuBois413287f2019-02-25 08:46:47 -080036using namespace std::chrono_literals;
Dan Stozaec460082018-12-17 15:35:09 -080037
38template <typename T>
39struct SpHash {
40 size_t operator()(const sp<T>& p) const { return std::hash<T*>()(p.get()); }
41};
42
Kevin DuBois413287f2019-02-25 08:46:47 -080043constexpr auto lumaSamplingStepTag = "LumaSamplingStep";
44enum class samplingStep {
45 noWorkNeeded,
46 idleTimerWaiting,
47 waitForZeroPhase,
48 waitForSamplePhase,
49 sample
50};
51
52constexpr auto defaultRegionSamplingOffset = -3ms;
53constexpr auto defaultRegionSamplingPeriod = 100ms;
54constexpr auto defaultRegionSamplingTimerTimeout = 100ms;
55// TODO: (b/127403193) duration to string conversion could probably be constexpr
56template <typename Rep, typename Per>
57inline std::string toNsString(std::chrono::duration<Rep, Per> t) {
58 return std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(t).count());
Dan Stozaec460082018-12-17 15:35:09 -080059}
60
Kevin DuBois413287f2019-02-25 08:46:47 -080061RegionSamplingThread::EnvironmentTimingTunables::EnvironmentTimingTunables() {
62 char value[PROPERTY_VALUE_MAX] = {};
63
64 property_get("debug.sf.region_sampling_offset_ns", value,
65 toNsString(defaultRegionSamplingOffset).c_str());
66 int const samplingOffsetNsRaw = atoi(value);
67
68 property_get("debug.sf.region_sampling_period_ns", value,
69 toNsString(defaultRegionSamplingPeriod).c_str());
70 int const samplingPeriodNsRaw = atoi(value);
71
72 property_get("debug.sf.region_sampling_timer_timeout_ns", value,
73 toNsString(defaultRegionSamplingTimerTimeout).c_str());
74 int const samplingTimerTimeoutNsRaw = atoi(value);
75
76 if ((samplingPeriodNsRaw < 0) || (samplingTimerTimeoutNsRaw < 0)) {
77 ALOGW("User-specified sampling tuning options nonsensical. Using defaults");
78 mSamplingOffset = defaultRegionSamplingOffset;
79 mSamplingPeriod = defaultRegionSamplingPeriod;
80 mSamplingTimerTimeout = defaultRegionSamplingTimerTimeout;
81 } else {
82 mSamplingOffset = std::chrono::nanoseconds(samplingOffsetNsRaw);
83 mSamplingPeriod = std::chrono::nanoseconds(samplingPeriodNsRaw);
84 mSamplingTimerTimeout = std::chrono::nanoseconds(samplingTimerTimeoutNsRaw);
85 }
86}
87
88struct SamplingOffsetCallback : DispSync::Callback {
89 SamplingOffsetCallback(RegionSamplingThread& samplingThread, Scheduler& scheduler,
90 std::chrono::nanoseconds targetSamplingOffset)
91 : mRegionSamplingThread(samplingThread),
92 mScheduler(scheduler),
93 mTargetSamplingOffset(targetSamplingOffset) {}
94
95 ~SamplingOffsetCallback() { stopVsyncListener(); }
96
97 SamplingOffsetCallback(const SamplingOffsetCallback&) = delete;
98 SamplingOffsetCallback& operator=(const SamplingOffsetCallback&) = delete;
99
100 void startVsyncListener() {
101 std::lock_guard lock(mMutex);
102 if (mVsyncListening) return;
103
104 mPhaseIntervalSetting = Phase::ZERO;
105 mScheduler.withPrimaryDispSync([this](android::DispSync& sync) {
Alec Mouri7355eb22019-03-05 14:19:10 -0800106 sync.addEventListener("SamplingThreadDispSyncListener", 0, this, mLastCallbackTime);
Kevin DuBois413287f2019-02-25 08:46:47 -0800107 });
108 mVsyncListening = true;
109 }
110
111 void stopVsyncListener() {
112 std::lock_guard lock(mMutex);
113 stopVsyncListenerLocked();
114 }
115
116private:
117 void stopVsyncListenerLocked() /*REQUIRES(mMutex)*/ {
118 if (!mVsyncListening) return;
119
Alec Mouri7355eb22019-03-05 14:19:10 -0800120 mScheduler.withPrimaryDispSync([this](android::DispSync& sync) {
121 sync.removeEventListener(this, &mLastCallbackTime);
122 });
Kevin DuBois413287f2019-02-25 08:46:47 -0800123 mVsyncListening = false;
124 }
125
126 void onDispSyncEvent(nsecs_t /* when */) final {
127 std::unique_lock<decltype(mMutex)> lock(mMutex);
128
129 if (mPhaseIntervalSetting == Phase::ZERO) {
130 ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::waitForSamplePhase));
131 mPhaseIntervalSetting = Phase::SAMPLING;
132 mScheduler.withPrimaryDispSync([this](android::DispSync& sync) {
133 sync.changePhaseOffset(this, mTargetSamplingOffset.count());
134 });
135 return;
136 }
137
138 if (mPhaseIntervalSetting == Phase::SAMPLING) {
139 mPhaseIntervalSetting = Phase::ZERO;
140 mScheduler.withPrimaryDispSync(
141 [this](android::DispSync& sync) { sync.changePhaseOffset(this, 0); });
142 stopVsyncListenerLocked();
143 lock.unlock();
144 mRegionSamplingThread.notifySamplingOffset();
145 return;
146 }
147 }
148
149 RegionSamplingThread& mRegionSamplingThread;
150 Scheduler& mScheduler;
151 const std::chrono::nanoseconds mTargetSamplingOffset;
152 mutable std::mutex mMutex;
Alec Mouri7355eb22019-03-05 14:19:10 -0800153 nsecs_t mLastCallbackTime = 0;
Kevin DuBois413287f2019-02-25 08:46:47 -0800154 enum class Phase {
155 ZERO,
156 SAMPLING
157 } mPhaseIntervalSetting /*GUARDED_BY(mMutex) macro doesnt work with unique_lock?*/
158 = Phase::ZERO;
159 bool mVsyncListening /*GUARDED_BY(mMutex)*/ = false;
160};
161
162RegionSamplingThread::RegionSamplingThread(SurfaceFlinger& flinger, Scheduler& scheduler,
163 const TimingTunables& tunables)
164 : mFlinger(flinger),
165 mScheduler(scheduler),
166 mTunables(tunables),
167 mIdleTimer(std::chrono::duration_cast<std::chrono::milliseconds>(
168 mTunables.mSamplingTimerTimeout),
169 [] {}, [this] { checkForStaleLuma(); }),
170 mPhaseCallback(std::make_unique<SamplingOffsetCallback>(*this, mScheduler,
171 tunables.mSamplingOffset)),
172 lastSampleTime(0ns) {
Kevin DuBois26afc782019-05-06 16:46:45 -0700173 mThread = std::thread([this]() { threadMain(); });
174 pthread_setname_np(mThread.native_handle(), "RegionSamplingThread");
Kevin DuBois413287f2019-02-25 08:46:47 -0800175 mIdleTimer.start();
176}
177
178RegionSamplingThread::RegionSamplingThread(SurfaceFlinger& flinger, Scheduler& scheduler)
179 : RegionSamplingThread(flinger, scheduler,
180 TimingTunables{defaultRegionSamplingOffset,
181 defaultRegionSamplingPeriod,
182 defaultRegionSamplingTimerTimeout}) {}
183
Dan Stozaec460082018-12-17 15:35:09 -0800184RegionSamplingThread::~RegionSamplingThread() {
Kevin DuBois413287f2019-02-25 08:46:47 -0800185 mIdleTimer.stop();
186
Dan Stozaec460082018-12-17 15:35:09 -0800187 {
Kevin DuBois26afc782019-05-06 16:46:45 -0700188 std::lock_guard lock(mThreadControlMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800189 mRunning = false;
190 mCondition.notify_one();
191 }
192
Dan Stozaec460082018-12-17 15:35:09 -0800193 if (mThread.joinable()) {
194 mThread.join();
195 }
196}
197
198void RegionSamplingThread::addListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,
199 const sp<IRegionSamplingListener>& listener) {
200 wp<Layer> stopLayer = stopLayerHandle != nullptr
201 ? static_cast<Layer::Handle*>(stopLayerHandle.get())->owner
202 : nullptr;
203
204 sp<IBinder> asBinder = IInterface::asBinder(listener);
205 asBinder->linkToDeath(this);
Kevin DuBois26afc782019-05-06 16:46:45 -0700206 std::lock_guard lock(mSamplingMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800207 mDescriptors.emplace(wp<IBinder>(asBinder), Descriptor{samplingArea, stopLayer, listener});
208}
209
210void RegionSamplingThread::removeListener(const sp<IRegionSamplingListener>& listener) {
Kevin DuBois26afc782019-05-06 16:46:45 -0700211 std::lock_guard lock(mSamplingMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800212 mDescriptors.erase(wp<IBinder>(IInterface::asBinder(listener)));
213}
214
Kevin DuBois413287f2019-02-25 08:46:47 -0800215void RegionSamplingThread::checkForStaleLuma() {
Kevin DuBois26afc782019-05-06 16:46:45 -0700216 std::lock_guard lock(mThreadControlMutex);
Kevin DuBois413287f2019-02-25 08:46:47 -0800217
218 if (mDiscardedFrames) {
219 ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::waitForZeroPhase));
220 mDiscardedFrames = false;
221 mPhaseCallback->startVsyncListener();
222 }
223}
224
225void RegionSamplingThread::notifyNewContent() {
226 doSample();
227}
228
229void RegionSamplingThread::notifySamplingOffset() {
230 doSample();
231}
232
233void RegionSamplingThread::doSample() {
Kevin DuBois26afc782019-05-06 16:46:45 -0700234 std::lock_guard lock(mThreadControlMutex);
Kevin DuBois413287f2019-02-25 08:46:47 -0800235 auto now = std::chrono::nanoseconds(systemTime(SYSTEM_TIME_MONOTONIC));
236 if (lastSampleTime + mTunables.mSamplingPeriod > now) {
237 ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::idleTimerWaiting));
238 mDiscardedFrames = true;
239 return;
240 }
241
242 ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::sample));
243
244 mDiscardedFrames = false;
245 lastSampleTime = now;
246
247 mIdleTimer.reset();
248 mPhaseCallback->stopVsyncListener();
249
Dan Stozaec460082018-12-17 15:35:09 -0800250 mSampleRequested = true;
251 mCondition.notify_one();
252}
253
254void RegionSamplingThread::binderDied(const wp<IBinder>& who) {
Kevin DuBois26afc782019-05-06 16:46:45 -0700255 std::lock_guard lock(mSamplingMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800256 mDescriptors.erase(who);
257}
258
259namespace {
260// Using Rec. 709 primaries
261float getLuma(float r, float g, float b) {
262 constexpr auto rec709_red_primary = 0.2126f;
263 constexpr auto rec709_green_primary = 0.7152f;
264 constexpr auto rec709_blue_primary = 0.0722f;
265 return rec709_red_primary * r + rec709_green_primary * g + rec709_blue_primary * b;
266}
Kevin DuBoisbb27bcd2019-04-02 14:34:35 -0700267} // anonymous namespace
Dan Stozaec460082018-12-17 15:35:09 -0800268
Kevin DuBoisb325c932019-05-21 08:34:09 -0700269float sampleArea(const uint32_t* data, int32_t width, int32_t height, int32_t stride,
270 uint32_t orientation, const Rect& sample_area) {
271 if (!sample_area.isValid() || (sample_area.getWidth() > width) ||
272 (sample_area.getHeight() > height)) {
273 ALOGE("invalid sampling region requested");
274 return 0.0f;
275 }
276
277 // (b/133849373) ROT_90 screencap images produced upside down
278 auto area = sample_area;
279 if (orientation & ui::Transform::ROT_90) {
280 area.top = height - area.top;
281 area.bottom = height - area.bottom;
282 std::swap(area.top, area.bottom);
Kevin DuBois69162d02019-06-04 20:22:43 -0700283
284 area.left = width - area.left;
285 area.right = width - area.right;
286 std::swap(area.left, area.right);
Kevin DuBoisb325c932019-05-21 08:34:09 -0700287 }
288
Dan Stozaec460082018-12-17 15:35:09 -0800289 std::array<int32_t, 256> brightnessBuckets = {};
290 const int32_t majoritySampleNum = area.getWidth() * area.getHeight() / 2;
291
292 for (int32_t row = area.top; row < area.bottom; ++row) {
293 const uint32_t* rowBase = data + row * stride;
294 for (int32_t column = area.left; column < area.right; ++column) {
295 uint32_t pixel = rowBase[column];
296 const float r = (pixel & 0xFF) / 255.0f;
297 const float g = ((pixel >> 8) & 0xFF) / 255.0f;
298 const float b = ((pixel >> 16) & 0xFF) / 255.0f;
299 const uint8_t luma = std::round(getLuma(r, g, b) * 255.0f);
300 ++brightnessBuckets[luma];
301 if (brightnessBuckets[luma] > majoritySampleNum) return luma / 255.0f;
302 }
303 }
304
305 int32_t accumulated = 0;
306 size_t bucket = 0;
Kevin DuBoisbb27bcd2019-04-02 14:34:35 -0700307 for (; bucket < brightnessBuckets.size(); bucket++) {
Dan Stozaec460082018-12-17 15:35:09 -0800308 accumulated += brightnessBuckets[bucket];
309 if (accumulated > majoritySampleNum) break;
310 }
311
312 return bucket / 255.0f;
313}
Dan Stozaec460082018-12-17 15:35:09 -0800314
Kevin DuBois7cbcc372019-02-25 14:53:28 -0800315std::vector<float> RegionSamplingThread::sampleBuffer(
316 const sp<GraphicBuffer>& buffer, const Point& leftTop,
Kevin DuBoisb325c932019-05-21 08:34:09 -0700317 const std::vector<RegionSamplingThread::Descriptor>& descriptors, uint32_t orientation) {
Dan Stozaec460082018-12-17 15:35:09 -0800318 void* data_raw = nullptr;
319 buffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, &data_raw);
320 std::shared_ptr<uint32_t> data(reinterpret_cast<uint32_t*>(data_raw),
321 [&buffer](auto) { buffer->unlock(); });
322 if (!data) return {};
323
Kevin DuBoisb325c932019-05-21 08:34:09 -0700324 const int32_t width = buffer->getWidth();
325 const int32_t height = buffer->getHeight();
Dan Stozaec460082018-12-17 15:35:09 -0800326 const int32_t stride = buffer->getStride();
327 std::vector<float> lumas(descriptors.size());
328 std::transform(descriptors.begin(), descriptors.end(), lumas.begin(),
329 [&](auto const& descriptor) {
Kevin DuBoisb325c932019-05-21 08:34:09 -0700330 return sampleArea(data.get(), width, height, stride, orientation,
331 descriptor.area - leftTop);
Dan Stozaec460082018-12-17 15:35:09 -0800332 });
333 return lumas;
334}
335
336void RegionSamplingThread::captureSample() {
337 ATRACE_CALL();
Kevin DuBois26afc782019-05-06 16:46:45 -0700338 std::lock_guard lock(mSamplingMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800339
340 if (mDescriptors.empty()) {
341 return;
342 }
343
Kevin DuBoisb325c932019-05-21 08:34:09 -0700344 const auto device = mFlinger.getDefaultDisplayDevice();
345 const auto display = device->getCompositionDisplay();
346 const auto state = display->getState();
347 const auto orientation = static_cast<ui::Transform::orientation_flags>(state.orientation);
348
Dan Stozaec460082018-12-17 15:35:09 -0800349 std::vector<RegionSamplingThread::Descriptor> descriptors;
350 Region sampleRegion;
351 for (const auto& [listener, descriptor] : mDescriptors) {
352 sampleRegion.orSelf(descriptor.area);
353 descriptors.emplace_back(descriptor);
354 }
355
Kevin DuBois7cbcc372019-02-25 14:53:28 -0800356 const Rect sampledArea = sampleRegion.bounds();
Dan Stozaec460082018-12-17 15:35:09 -0800357
Kevin DuBoisb325c932019-05-21 08:34:09 -0700358 auto dx = 0;
359 auto dy = 0;
360 switch (orientation) {
361 case ui::Transform::ROT_90:
362 dx = device->getWidth();
363 break;
364 case ui::Transform::ROT_180:
365 dx = device->getWidth();
366 dy = device->getHeight();
367 break;
368 case ui::Transform::ROT_270:
369 dy = device->getHeight();
370 break;
371 default:
372 break;
373 }
374
375 ui::Transform t(orientation);
376 auto screencapRegion = t.transform(sampleRegion);
377 screencapRegion = screencapRegion.translate(dx, dy);
378 DisplayRenderArea renderArea(device, screencapRegion.bounds(), sampledArea.getWidth(),
379 sampledArea.getHeight(), ui::Dataspace::V0_SRGB, orientation);
Dan Stozaec460082018-12-17 15:35:09 -0800380
381 std::unordered_set<sp<IRegionSamplingListener>, SpHash<IRegionSamplingListener>> listeners;
382
383 auto traverseLayers = [&](const LayerVector::Visitor& visitor) {
384 bool stopLayerFound = false;
385 auto filterVisitor = [&](Layer* layer) {
386 // We don't want to capture any layers beyond the stop layer
387 if (stopLayerFound) return;
388
389 // Likewise if we just found a stop layer, set the flag and abort
390 for (const auto& [area, stopLayer, listener] : descriptors) {
391 if (layer == stopLayer.promote().get()) {
392 stopLayerFound = true;
393 return;
394 }
395 }
396
397 // Compute the layer's position on the screen
Kevin DuBois7cbcc372019-02-25 14:53:28 -0800398 const Rect bounds = Rect(layer->getBounds());
399 const ui::Transform transform = layer->getTransform();
Dan Stozaec460082018-12-17 15:35:09 -0800400 constexpr bool roundOutwards = true;
401 Rect transformed = transform.transform(bounds, roundOutwards);
402
403 // If this layer doesn't intersect with the larger sampledArea, skip capturing it
404 Rect ignore;
405 if (!transformed.intersect(sampledArea, &ignore)) return;
406
407 // If the layer doesn't intersect a sampling area, skip capturing it
408 bool intersectsAnyArea = false;
409 for (const auto& [area, stopLayer, listener] : descriptors) {
410 if (transformed.intersect(area, &ignore)) {
411 intersectsAnyArea = true;
412 listeners.insert(listener);
413 }
414 }
415 if (!intersectsAnyArea) return;
416
417 ALOGV("Traversing [%s] [%d, %d, %d, %d]", layer->getName().string(), bounds.left,
418 bounds.top, bounds.right, bounds.bottom);
419 visitor(layer);
420 };
421 mFlinger.traverseLayersInDisplay(device, filterVisitor);
422 };
423
Kevin DuBois4efd1f52019-04-29 10:09:43 -0700424 sp<GraphicBuffer> buffer = nullptr;
425 if (mCachedBuffer && mCachedBuffer->getWidth() == sampledArea.getWidth() &&
426 mCachedBuffer->getHeight() == sampledArea.getHeight()) {
427 buffer = mCachedBuffer;
428 } else {
429 const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER;
430 buffer = new GraphicBuffer(sampledArea.getWidth(), sampledArea.getHeight(),
431 PIXEL_FORMAT_RGBA_8888, 1, usage, "RegionSamplingThread");
432 }
Dan Stozaec460082018-12-17 15:35:09 -0800433
Robert Carr108b2c72019-04-02 16:32:58 -0700434 bool ignored;
435 mFlinger.captureScreenCommon(renderArea, traverseLayers, buffer, false, ignored);
Dan Stozaec460082018-12-17 15:35:09 -0800436
437 std::vector<Descriptor> activeDescriptors;
438 for (const auto& descriptor : descriptors) {
439 if (listeners.count(descriptor.listener) != 0) {
440 activeDescriptors.emplace_back(descriptor);
441 }
442 }
443
444 ALOGV("Sampling %zu descriptors", activeDescriptors.size());
Kevin DuBoisb325c932019-05-21 08:34:09 -0700445 std::vector<float> lumas =
446 sampleBuffer(buffer, sampledArea.leftTop(), activeDescriptors, orientation);
Dan Stozaec460082018-12-17 15:35:09 -0800447 if (lumas.size() != activeDescriptors.size()) {
Kevin DuBois7cbcc372019-02-25 14:53:28 -0800448 ALOGW("collected %zu median luma values for %zu descriptors", lumas.size(),
449 activeDescriptors.size());
Dan Stozaec460082018-12-17 15:35:09 -0800450 return;
451 }
452
453 for (size_t d = 0; d < activeDescriptors.size(); ++d) {
454 activeDescriptors[d].listener->onSampleCollected(lumas[d]);
455 }
Kevin DuBois4efd1f52019-04-29 10:09:43 -0700456
457 // Extend the lifetime of mCachedBuffer from the previous frame to here to ensure that:
458 // 1) The region sampling thread is the last owner of the buffer, and the freeing of the buffer
459 // happens in this thread, as opposed to the main thread.
460 // 2) The listener(s) receive their notifications prior to freeing the buffer.
461 mCachedBuffer = buffer;
Kevin DuBois413287f2019-02-25 08:46:47 -0800462 ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::noWorkNeeded));
Dan Stozaec460082018-12-17 15:35:09 -0800463}
464
Kevin DuBois26afc782019-05-06 16:46:45 -0700465// NO_THREAD_SAFETY_ANALYSIS is because std::unique_lock presently lacks thread safety annotations.
466void RegionSamplingThread::threadMain() NO_THREAD_SAFETY_ANALYSIS {
467 std::unique_lock<std::mutex> lock(mThreadControlMutex);
Dan Stozaec460082018-12-17 15:35:09 -0800468 while (mRunning) {
469 if (mSampleRequested) {
470 mSampleRequested = false;
Kevin DuBois26afc782019-05-06 16:46:45 -0700471 lock.unlock();
Dan Stozaec460082018-12-17 15:35:09 -0800472 captureSample();
Kevin DuBois26afc782019-05-06 16:46:45 -0700473 lock.lock();
Dan Stozaec460082018-12-17 15:35:09 -0800474 }
Kevin DuBois26afc782019-05-06 16:46:45 -0700475 mCondition.wait(lock, [this]() REQUIRES(mThreadControlMutex) {
476 return mSampleRequested || !mRunning;
477 });
Dan Stozaec460082018-12-17 15:35:09 -0800478 }
479}
480
481} // namespace android