Loading libs/gui/BLASTBufferQueue.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -1232,6 +1232,11 @@ public: return OK; } // Provide a callback for Choreographer to start buffer stuffing recovery when blocked // on buffer release. std::function<void()> callbackCopy = bbq->getWaitForBufferReleaseCallback(); if (callbackCopy) callbackCopy(); // BufferQueue has already checked if we have a free buffer. If there's an unread interrupt, // we want to ignore it. This must be done before unlocking the BufferQueue lock to ensure // we don't miss an interrupt. Loading Loading @@ -1344,6 +1349,16 @@ void BLASTBufferQueue::setApplyToken(sp<IBinder> applyToken) { mApplyToken = std::move(applyToken); } void BLASTBufferQueue::setWaitForBufferReleaseCallback(std::function<void()> callback) { std::lock_guard _lock{mWaitForBufferReleaseMutex}; mWaitForBufferReleaseCallback = std::move(callback); } std::function<void()> BLASTBufferQueue::getWaitForBufferReleaseCallback() const { std::lock_guard _lock{mWaitForBufferReleaseMutex}; return mWaitForBufferReleaseCallback; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL) void BLASTBufferQueue::updateBufferReleaseProducer() { Loading libs/gui/include/gui/BLASTBufferQueue.h +8 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,12 @@ public: */ void setTransactionHangCallback(std::function<void(const std::string&)> callback); void setApplyToken(sp<IBinder>); void setWaitForBufferReleaseCallback(std::function<void()> callback) EXCLUDES(mWaitForBufferReleaseMutex); std::function<void()> getWaitForBufferReleaseCallback() const EXCLUDES(mWaitForBufferReleaseMutex); virtual ~BLASTBufferQueue(); void onFirstRef() override; Loading Loading @@ -186,6 +192,7 @@ private: sp<SurfaceControl> mSurfaceControl GUARDED_BY(mMutex); mutable std::mutex mMutex; mutable std::mutex mWaitForBufferReleaseMutex; std::condition_variable mCallbackCV; // BufferQueue internally allows 1 more than Loading Loading @@ -324,6 +331,7 @@ private: std::unordered_set<uint64_t> mSyncedFrameNumbers GUARDED_BY(mMutex); std::function<void()> mWaitForBufferReleaseCallback GUARDED_BY(mWaitForBufferReleaseMutex); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL) // BufferReleaseChannel is used to communicate buffer releases from SurfaceFlinger to the // client. Loading Loading
libs/gui/BLASTBufferQueue.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -1232,6 +1232,11 @@ public: return OK; } // Provide a callback for Choreographer to start buffer stuffing recovery when blocked // on buffer release. std::function<void()> callbackCopy = bbq->getWaitForBufferReleaseCallback(); if (callbackCopy) callbackCopy(); // BufferQueue has already checked if we have a free buffer. If there's an unread interrupt, // we want to ignore it. This must be done before unlocking the BufferQueue lock to ensure // we don't miss an interrupt. Loading Loading @@ -1344,6 +1349,16 @@ void BLASTBufferQueue::setApplyToken(sp<IBinder> applyToken) { mApplyToken = std::move(applyToken); } void BLASTBufferQueue::setWaitForBufferReleaseCallback(std::function<void()> callback) { std::lock_guard _lock{mWaitForBufferReleaseMutex}; mWaitForBufferReleaseCallback = std::move(callback); } std::function<void()> BLASTBufferQueue::getWaitForBufferReleaseCallback() const { std::lock_guard _lock{mWaitForBufferReleaseMutex}; return mWaitForBufferReleaseCallback; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL) void BLASTBufferQueue::updateBufferReleaseProducer() { Loading
libs/gui/include/gui/BLASTBufferQueue.h +8 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,12 @@ public: */ void setTransactionHangCallback(std::function<void(const std::string&)> callback); void setApplyToken(sp<IBinder>); void setWaitForBufferReleaseCallback(std::function<void()> callback) EXCLUDES(mWaitForBufferReleaseMutex); std::function<void()> getWaitForBufferReleaseCallback() const EXCLUDES(mWaitForBufferReleaseMutex); virtual ~BLASTBufferQueue(); void onFirstRef() override; Loading Loading @@ -186,6 +192,7 @@ private: sp<SurfaceControl> mSurfaceControl GUARDED_BY(mMutex); mutable std::mutex mMutex; mutable std::mutex mWaitForBufferReleaseMutex; std::condition_variable mCallbackCV; // BufferQueue internally allows 1 more than Loading Loading @@ -324,6 +331,7 @@ private: std::unordered_set<uint64_t> mSyncedFrameNumbers GUARDED_BY(mMutex); std::function<void()> mWaitForBufferReleaseCallback GUARDED_BY(mWaitForBufferReleaseMutex); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL) // BufferReleaseChannel is used to communicate buffer releases from SurfaceFlinger to the // client. Loading