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

Commit 5331371a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Delete streams after successful configuration"

parents 60536d8e 98014ff8
Loading
Loading
Loading
Loading
+61 −49
Original line number Diff line number Diff line
@@ -399,9 +399,11 @@ Return<void> CameraDeviceSession::configureStreams(
        return Void();
    }

    if (status != Status::OK) {
        _hidl_cb(status, outStreams);
        return Void();
    }


    if (status == Status::OK) {
    camera3_stream_configuration_t stream_list;
    hidl_vec<camera3_stream_t*> streams;

@@ -441,6 +443,9 @@ Return<void> CameraDeviceSession::configureStreams(
    status_t ret = mDevice->ops->configure_streams(mDevice, &stream_list);
    ATRACE_END();

    // In case Hal returns error most likely it was not able to release
    // the corresponding resources of the deleted streams.
    if (ret == OK) {
        // delete unused streams, note we do this after adding new streams to ensure new stream
        // will not have the same address as deleted stream, and HAL has a chance to reference
        // the to be deleted stream in configure_streams call
@@ -455,16 +460,15 @@ Return<void> CameraDeviceSession::configureStreams(
            }
            if (!found) {
                // Unmap all buffers of deleted stream
                for (auto& pair : mCirculatingBuffers.at(id)) {
                    sHandleImporter.freeBuffer(pair.second);
                }
                mCirculatingBuffers[id].clear();
                mCirculatingBuffers.erase(id);
                // in case the configuration call succeeds and HAL
                // is able to release the corresponding resources too.
                cleanupBuffersLocked(id);
                it = mStreamMap.erase(it);
            } else {
                ++it;
            }
        }
    }

    if (ret == -EINVAL) {
        status = Status::ILLEGAL_ARGUMENT;
@@ -474,11 +478,19 @@ Return<void> CameraDeviceSession::configureStreams(
        convertToHidl(stream_list, &outStreams);
    }

    }
    _hidl_cb(status, outStreams);
    return Void();
}

// Needs to get called after acquiring 'mInflightLock'
void CameraDeviceSession::cleanupBuffersLocked(int id) {
    for (auto& pair : mCirculatingBuffers.at(id)) {
        sHandleImporter.freeBuffer(pair.second);
    }
    mCirculatingBuffers[id].clear();
    mCirculatingBuffers.erase(id);
}

Return<Status> CameraDeviceSession::processCaptureRequest(const CaptureRequest& request)  {
    Status status = initStatus();
    if (status != Status::OK) {
+2 −0
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ private:
    static void cleanupInflightFences(
            hidl_vec<int>& allFences, size_t numFences);

    void cleanupBuffersLocked(int id);

    /**
     * Static callback forwarding methods from HAL to instance
     */