Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3934aac authored by Yixiao Luo's avatar Yixiao Luo Committed by Android (Google) Code Review
Browse files

Merge "Release component on destructor if needed" into main

parents 1fd1f657 064072fd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ Component::Component(
        mListener{listener},
        mStore{store},
        mBufferPoolSender{clientPoolManager},
        mReleased(false),
        mDeathContext(nullptr) {
    // Retrieve supported parameters from store
    // TODO: We could cache this per component/interface type
@@ -457,6 +458,7 @@ ScopedAStatus Component::reset() {
}

ScopedAStatus Component::release() {
    mReleased = true;
    c2_status_t status = mComponent->release();
    {
        std::lock_guard<std::mutex> lock(mBlockPoolsMutex);
@@ -554,6 +556,10 @@ void Component::OnBinderUnlinked(void *cookie) {
}

Component::~Component() {
    if (!mReleased) {
        this->reset();
        this->release();
    }
    InputBufferManager::unregisterFrameData(mListener);
    mStore->reportComponentDeath(this);
    if (mDeathRecipient.get()) {
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ protected:
    // destroyBlockPool(), reset() or release(), or by destroying the component.
    std::map<uint64_t, std::shared_ptr<C2BlockPool>> mBlockPools;
    bool mBlockFenceSupport;
    bool mReleased;

    void initListener(const std::shared_ptr<Component>& self);