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

Commit c87f9570 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Eino-Ville Talvala (Eddy)
Browse files

Camera server: Move shutter notify callback outside in-flight mutex

This further reduces contention on the in-flight queue mutex with
calls like getExpectedInFlightDuration().
On a test trace recording 1080p60 video on Pixel, the average duration
of getExpectedInFlightDuration reduced from 12 to 5 us, with a much
narrower histogram as well.

Test: Manual trace inspection from 1080p60 recording, atest CtsCameraTestCases
Bug: 315526878
Change-Id: I50f2c835247b22a6c9acb637740814b0d721ceea
parent 8be94d0f
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1015,6 +1015,7 @@ void notifyShutter(CaptureOutputStates& states, const camera_shutter_msg_t &msg)
    ssize_t idx;

    std::vector<BufferToReturn> returnableBuffers{};
    CaptureResultExtras pendingNotificationResultExtras{};

    // Set timestamp for the request in the in-flight tracking
    // and get the request ID to send upstream
@@ -1082,9 +1083,13 @@ void notifyShutter(CaptureOutputStates& states, const camera_shutter_msg_t &msg)
                            states.lastCompletedReprocessFrameNumber;
                    r.resultExtras.lastCompletedZslFrameNumber =
                            states.lastCompletedZslFrameNumber;
                    if (flags::return_buffers_outside_locks()) {
                        pendingNotificationResultExtras = r.resultExtras;
                    } else {
                        states.listener->notifyShutter(r.resultExtras, msg.timestamp);
                    }
                // send pending result and buffers
                }
                // send pending result and buffers; this queues them up for delivery later
                const auto& cameraIdsWithZoom = getCameraIdsWithZoomLocked(
                        inflightMap, r.pendingMetadata, r.cameraIdsWithZoom);
                sendCaptureResult(states,
@@ -1110,6 +1115,11 @@ void notifyShutter(CaptureOutputStates& states, const camera_shutter_msg_t &msg)
        SET_ERR("Shutter notification for non-existent frame number %d",
                msg.frame_number);
    }
    // Call notifyShutter outside of in-flight mutex
    if (flags::return_buffers_outside_locks() && pendingNotificationResultExtras.isValid()) {
        states.listener->notifyShutter(pendingNotificationResultExtras, msg.timestamp);
    }

    // With no locks held, finish returning buffers to streams, which may take a while since
    // binder calls are involved
    if (flags::return_buffers_outside_locks()) {