surfaceflinger: Add check for number of queued buffers

Pop buffer item from shadow queue only when
number of queued buffer items is greater than zero.

Change-Id: I039bc133842293c29e3e130efd65f521ef0049c6
CRs-Fixed: 1009466
This commit is contained in:
Anjaneya Prasad Musunuri 2016-07-05 10:35:59 +05:30 committed by Steve Kondik
parent 2ab013db02
commit 52b8462635

View File

@ -1448,11 +1448,16 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions)
// Remove any stale buffers that have been dropped during
// updateTexImage
while (mQueueItems[0].mFrameNumber != currentFrameNumber) {
while ((mQueuedFrames > 0) && (mQueueItems[0].mFrameNumber != currentFrameNumber)) {
mQueueItems.removeAt(0);
android_atomic_dec(&mQueuedFrames);
}
if (mQueuedFrames == 0) {
ALOGE("[%s] mQueuedFrames is zero !!", mName.string());
return outDirtyRegion;
}
mQueueItems.removeAt(0);
}