diff options
| author | 2018-07-18 22:07:22 +0000 | |
|---|---|---|
| committer | 2018-07-18 22:07:22 +0000 | |
| commit | 432911091c487d52f0ddc708b0d30db6d3dcae74 (patch) | |
| tree | 0d03a1c3902357e43794e4994b51372bcf1f7a9b /libs/gui/BufferQueueProducer.cpp | |
| parent | 4d29392c7fb268e0210db4146f151d40502eff33 (diff) | |
| parent | 98010cd20f631215fc2bc6acb8eea25ec3557aa6 (diff) | |
Merge "Do not block on allocating buffers am: 0a3e784701" into pi-dev-plus-aosp
Diffstat (limited to 'libs/gui/BufferQueueProducer.cpp')
| -rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index c8021e4d54..c96a2dd6a3 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -381,7 +381,6 @@ status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* ou { // Autolock scope Mutex::Autolock lock(mCore->mMutex); - mCore->waitWhileAllocatingLocked(); if (format == 0) { format = mCore->mDefaultBufferFormat; @@ -1345,7 +1344,9 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, return; } - newBufferCount = mCore->mFreeSlots.size(); + // Only allocate one buffer at a time to reduce risks of overlapping an allocation from + // both allocateBuffers and dequeueBuffer. + newBufferCount = mCore->mFreeSlots.empty() ? 0 : 1; if (newBufferCount == 0) { return; } @@ -1360,7 +1361,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, } // Autolock scope Vector<sp<GraphicBuffer>> buffers; - for (size_t i = 0; i < newBufferCount; ++i) { + for (size_t i = 0; i < newBufferCount; ++i) { sp<GraphicBuffer> graphicBuffer = new GraphicBuffer( allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT, allocUsage, allocName); |