diff options
| author | 2018-07-18 14:59:18 -0700 | |
|---|---|---|
| committer | 2018-07-18 14:59:18 -0700 | |
| commit | 98010cd20f631215fc2bc6acb8eea25ec3557aa6 (patch) | |
| tree | eb38fe23601f7b9385d3a3bff0645481c0689ccd /libs/gui/BufferQueueProducer.cpp | |
| parent | 9bd6b8147b705a4cf740740858a319fec165b0d1 (diff) | |
| parent | 0a3e7847012108f047a6582ebfb88026d640277f (diff) | |
Do not block on allocating buffers
am: 0a3e784701
Change-Id: I1a965d4a5ffe50724b27d23505b9dd686e135614
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); |