diff options
author | Antoine Labour <piman@google.com> | 2014-07-15 21:17:03 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-07-22 19:45:55 +0000 |
commit | 78014f32da6d0ebf52fb34ebb7663863000520a0 (patch) | |
tree | 8e34b5ea77b30458ce145678c2a9a08503498595 /include/gui/BufferQueueCore.h | |
parent | 7b3f48d2efc83094de70c24520bafacda3749a20 (diff) | |
download | frameworks_native-78014f32da6d0ebf52fb34ebb7663863000520a0.zip frameworks_native-78014f32da6d0ebf52fb34ebb7663863000520a0.tar.gz frameworks_native-78014f32da6d0ebf52fb34ebb7663863000520a0.tar.bz2 |
BufferQueue: release mutex while allocating. DO NOT MERGE
BufferQueueProducer::allocateBuffers used to keep the BufferQueueCore
mutex while doing the buffer allocation, which would cause the consumer
(which also needs the mutex) to block if the allocation takes a long
time.
Instead, release the mutex while doing the allocation, and grab it again
before filling the slots. Keep a bool state and a condvar to prevent
other producers from trying to allocate the slots while the mutex is
released.
Bug: 11792166
Change-Id: I4ab1319995ef892be2beba892f1fdbf50ce0416d
(cherry picked from commit ea96044470a29133321c681080870b9d31f81a19)
Diffstat (limited to 'include/gui/BufferQueueCore.h')
-rw-r--r-- | include/gui/BufferQueueCore.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h index cfcb7a5..1050e3b 100644 --- a/include/gui/BufferQueueCore.h +++ b/include/gui/BufferQueueCore.h @@ -120,6 +120,9 @@ private: // in one of the slots. bool stillTracking(const BufferItem* item) const; + // waitWhileAllocatingLocked blocks until mIsAllocating is false. + void waitWhileAllocatingLocked() const; + // mAllocator is the connection to SurfaceFlinger that is used to allocate // new GraphicBuffer objects. sp<IGraphicBufferAlloc> mAllocator; @@ -234,6 +237,15 @@ private: // mSidebandStream is a handle to the sideband buffer stream, if any sp<NativeHandle> mSidebandStream; + // mIsAllocating indicates whether a producer is currently trying to allocate buffers (which + // releases mMutex while doing the allocation proper). Producers should not modify any of the + // FREE slots while this is true. mIsAllocatingCondition is signaled when this value changes to + // false. + bool mIsAllocating; + + // mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating + // becomes false. + mutable Condition mIsAllocatingCondition; }; // class BufferQueueCore } // namespace android |