diff options
| author | 2021-09-03 02:01:55 +0000 | |
|---|---|---|
| committer | 2021-09-03 02:01:55 +0000 | |
| commit | 92e4782b3bd5e743ff1bacd1aa8ba72de3f0f261 (patch) | |
| tree | 35cbd0f709779033fe05a8055c1ef1d2efe8dc10 /libs/gui/BLASTBufferQueue.cpp | |
| parent | 3b134ccfc71c183c38169fe69cc1df5de222001d (diff) | |
| parent | 95b6d51f68e1a7c0fc3c989a7c8cfcd2db6a6ea4 (diff) | |
Merge "Surface: Release references to BlastBufferQueue and SurfaceControl on Surface#destroy" into sc-v2-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 e5a2151f13..d1f57b03bc 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 |