diff options
| author | 2018-07-18 15:14:16 -0700 | |
|---|---|---|
| committer | 2018-07-18 15:14:16 -0700 | |
| commit | 186e41ea39a4de173565fb7d366f1f5b4dae5166 (patch) | |
| tree | b2601d888da6c0313b52954824b1bd87476d14e2 /libs/gui/BufferQueueProducer.cpp | |
| parent | 98c5445943edadd07512edba8d8c243c90792724 (diff) | |
| parent | 432911091c487d52f0ddc708b0d30db6d3dcae74 (diff) | |
Merge "Do not block on allocating buffers am: 0a3e784701" into pi-dev-plus-aosp
am: 432911091c
Change-Id: I9c95caa9a7bf0949679809aaa490327795fa981f
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 ce3a90a483..5e250a4185 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); |