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

Commit 0cf9a22b authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "fix [3223749] media server crashes when switching mode from video...

Merge "fix [3223749] media server crashes when switching mode from video capture to still image capture"
parents a6219160 575eaf54
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -246,9 +246,10 @@ void Layer::setGeometry(hwc_layer_t* hwcl)
void Layer::setPerFrameData(hwc_layer_t* hwcl) {
void Layer::setPerFrameData(hwc_layer_t* hwcl) {
    sp<GraphicBuffer> buffer(mBufferManager.getActiveBuffer());
    sp<GraphicBuffer> buffer(mBufferManager.getActiveBuffer());
    if (buffer == NULL) {
    if (buffer == NULL) {
        // this situation can happen if we ran out of memory for instance.
        // this can happen if the client never drew into this layer yet,
        // not much we can do. continue to use whatever texture was bound
        // or if we ran out of memory. In that case, don't let
        // to this context.
        // HWC handle it.
        hwcl->flags |= HWC_SKIP_LAYER;
        hwcl->handle = NULL;
        hwcl->handle = NULL;
        return;
        return;
    }
    }
@@ -581,12 +582,20 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
    }
    }


    // we retired a buffer, which becomes the new front buffer
    // we retired a buffer, which becomes the new front buffer

    const bool noActiveBuffer = !mBufferManager.hasActiveBuffer();
    if (mBufferManager.setActiveBufferIndex(buf) < NO_ERROR) {
    if (mBufferManager.setActiveBufferIndex(buf) < NO_ERROR) {
        LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
        LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
        mPostedDirtyRegion.clear();
        mPostedDirtyRegion.clear();
        return;
        return;
    }
    }


    if (noActiveBuffer) {
        // we didn't have an active buffer, we need to recompute
        // our visible region
        recomputeVisibleRegions = true;
    }

    sp<GraphicBuffer> newFrontBuffer(getBuffer(buf));
    sp<GraphicBuffer> newFrontBuffer(getBuffer(buf));
    if (newFrontBuffer != NULL) {
    if (newFrontBuffer != NULL) {
        // get the dirty region
        // get the dirty region
@@ -888,6 +897,10 @@ sp<GraphicBuffer> Layer::BufferManager::getActiveBuffer() const {
    return result;
    return result;
}
}


bool Layer::BufferManager::hasActiveBuffer() const {
    return mActiveBuffer >= 0;
}

sp<GraphicBuffer> Layer::BufferManager::detachBuffer(size_t index)
sp<GraphicBuffer> Layer::BufferManager::detachBuffer(size_t index)
{
{
    BufferData* const buffers = mBufferData;
    BufferData* const buffers = mBufferData;
+2 −0
Original line number Original line Diff line number Diff line
@@ -188,6 +188,8 @@ private:
        size_t getActiveBufferIndex() const;
        size_t getActiveBufferIndex() const;
        // return the active buffer
        // return the active buffer
        sp<GraphicBuffer> getActiveBuffer() const;
        sp<GraphicBuffer> getActiveBuffer() const;
        // return wether we have an active buffer
        bool hasActiveBuffer() const;
        // return the active texture (or fail-over)
        // return the active texture (or fail-over)
        Texture getActiveTexture() const;
        Texture getActiveTexture() const;
        // frees resources associated with all buffers
        // frees resources associated with all buffers