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

Commit cf5c0971 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[ALPS09070588] Camera splitter bug fix" into main

parents fa64216c 63c6c23a
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -474,17 +474,18 @@ status_t Camera3StreamSplitter::attachBufferToOutputs(ANativeWindowBuffer* anb,
        mMutex.unlock();
        res = surface->attachBuffer(anb);
        mMutex.lock();
        //During buffer attach 'mMutex' is not held which makes the removal of
        //"surface" possible. Check whether this is the case and continue.
        if (surface.get() == nullptr) {
            res = OK;
            continue;
        }
        if (res != OK) {
            SP_LOGE("%s: Cannot attachBuffer from GraphicBufferProducer %p: %s (%d)", __FUNCTION__,
                    surface.get(), strerror(-res), res);
            // TODO: might need to detach/cleanup the already attached buffers before return?
            return res;
        }
        //During buffer attach 'mMutex' is not held which makes the removal of
        //"gbp" possible. Check whether this is the case and continue.
        if (mHeldBuffers[surface] == nullptr) {
            continue;
        }
        mHeldBuffers[surface]->insert(gb);
        SP_LOGV("%s: Attached buffer %p on output %p.", __FUNCTION__, gb.get(), surface.get());
    }
+6 −5
Original line number Diff line number Diff line
@@ -474,6 +474,12 @@ status_t DeprecatedCamera3StreamSplitter::attachBufferToOutputs(
        mMutex.unlock();
        res = gbp->attachBuffer(&slot, gb);
        mMutex.lock();
        // During buffer attach 'mMutex' is not held which makes the removal of
        //"gbp" possible. Check whether this is the case and continue.
        if (gbp.get() == nullptr) {
            res = OK;
            continue;
        }
        if (res != OK) {
            SP_LOGE("%s: Cannot attachBuffer from GraphicBufferProducer %p: %s (%d)", __FUNCTION__,
                    gbp.get(), strerror(-res), res);
@@ -485,11 +491,6 @@ status_t DeprecatedCamera3StreamSplitter::attachBufferToOutputs(
                    __FUNCTION__, slot, BufferQueue::NUM_BUFFER_SLOTS);
            return BAD_VALUE;
        }
        // During buffer attach 'mMutex' is not held which makes the removal of
        //"gbp" possible. Check whether this is the case and continue.
        if (mOutputSlots[gbp] == nullptr) {
            continue;
        }
        auto& outputSlots = *mOutputSlots[gbp];
        if (static_cast<size_t>(slot + 1) > outputSlots.size()) {
            outputSlots.resize(slot + 1);