diff options
| author | 2020-03-05 01:17:22 +0000 | |
|---|---|---|
| committer | 2020-03-05 01:17:22 +0000 | |
| commit | 987f74abd8a755ccb8f554b90fea620a5655376c (patch) | |
| tree | 1a382369822f27b805fcb70648ce443648ac3b6c /libs | |
| parent | 498d2f69aedcafd4f1eceb16e8e5780c3d72649e (diff) | |
| parent | a821321b901c5fdd9d00914ad3dbfbfa07f78695 (diff) | |
Merge "[AChoreographer] Resolves a deadlock" into rvc-dev am: a821321b90
Change-Id: I36bd39c1e98a5c485b96e542435985854d9617c8
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/nativedisplay/AChoreographer.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libs/nativedisplay/AChoreographer.cpp b/libs/nativedisplay/AChoreographer.cpp index 0f7e2fb936..0ff33ac747 100644 --- a/libs/nativedisplay/AChoreographer.cpp +++ b/libs/nativedisplay/AChoreographer.cpp @@ -185,9 +185,18 @@ void Choreographer::unregisterRefreshRateCallback(AChoreographer_refreshRateCall } void Choreographer::scheduleCallbacks() { - AutoMutex _{mLock}; - nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); - if (mFrameCallbacks.top().dueTime <= now) { + const nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); + nsecs_t dueTime; + { + AutoMutex _{mLock}; + // If there are no pending callbacks then don't schedule a vsync + if (mFrameCallbacks.empty()) { + return; + } + dueTime = mFrameCallbacks.top().dueTime; + } + + if (dueTime <= now) { ALOGV("choreographer %p ~ scheduling vsync", this); scheduleVsync(); return; |