diff options
| author | 2021-09-08 01:10:00 +0000 | |
|---|---|---|
| committer | 2021-09-08 01:10:00 +0000 | |
| commit | 5bcc5bd9d27d24815f5b7a3d047af828863cf7e0 (patch) | |
| tree | 56d9821e4ea97e527e951f587397231be0c938af /libs/gui/BLASTBufferQueue.cpp | |
| parent | cb9fcb9d5248491a27fae9619835914a763191a0 (diff) | |
| parent | c0fa0078cf9691dc34c7d8243f472426dca83e14 (diff) | |
Merge "Surface: Release references to BlastBufferQueue and SurfaceControl on Surface#destroy" into sc-qpr1-dev
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index d860f30617..94e1ae1c74 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -630,7 +630,10 @@ bool BLASTBufferQueue::maxBuffersAcquired(bool includeExtraAcquire) const { class BBQSurface : public Surface { private: + std::mutex mMutex; sp<BLASTBufferQueue> mBbq; + bool mDestroyed = false; + public: BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp, const sp<IBinder>& scHandle, const sp<BLASTBufferQueue>& bbq) @@ -650,6 +653,10 @@ public: status_t setFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) override { + std::unique_lock _lock{mMutex}; + if (mDestroyed) { + return DEAD_OBJECT; + } if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy, "BBQSurface::setFrameRate")) { return BAD_VALUE; @@ -658,8 +665,20 @@ public: } status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override { + std::unique_lock _lock{mMutex}; + if (mDestroyed) { + return DEAD_OBJECT; + } return mBbq->setFrameTimelineInfo(frameTimelineInfo); } + + void destroy() override { + Surface::destroy(); + + std::unique_lock _lock{mMutex}; + mDestroyed = true; + mBbq = nullptr; + } }; // TODO: Can we coalesce this with frame updates? Need to confirm |