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

Commit 2f077481 authored by Chien-Yu Chen's avatar Chien-Yu Chen Committed by android-build-team Robot
Browse files

camera: Drop pending preview for enableZsl shots

If the device support ZSL, drop pending preview buffers to reduce
the chance the rendering preview frames newer than the still frame
during takePicture().

Test: CTS
Bug: 67497723
Change-Id: I5f253a402a6302d31777ad4ca2878ef0d0d1ae44
Merged-In: I5f253a402a6302d31777ad4ca2878ef0d0d1ae44
(cherry picked from commit 63068520)
parent 9c8bf056
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -859,6 +859,12 @@ status_t Camera2Client::startPreviewL(Parameters &params, bool restart) {

    outputStreams.push(getPreviewStreamId());

    if (params.isDeviceZslSupported) {
        // If device ZSL is supported, resume preview buffers that may be paused
        // during last takePicture().
        mDevice->dropStreamBuffers(false, getPreviewStreamId());
    }

    if (!params.recordingHint) {
        if (!restart) {
            res = mStreamingProcessor->updatePreviewRequest(params);
+6 −0
Original line number Diff line number Diff line
@@ -553,6 +553,12 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture(
        return DONE;
    }

    if (l.mParameters.isDeviceZslSupported) {
        // If device ZSL is supported, drop all pending preview buffers to reduce the chance of
        // rendering preview frames newer than the still frame.
        client->getCameraDevice()->dropStreamBuffers(true, client->getPreviewStreamId());
    }

    /**
     * Clear the streaming request for still-capture pictures
     *   (as opposed to i.e. video snapshots)
+5 −0
Original line number Diff line number Diff line
@@ -349,6 +349,11 @@ class CameraDeviceBase : public virtual RefBase {
    virtual status_t setConsumerSurfaces(int streamId,
            const std::vector<sp<Surface>>& consumers) = 0;

    /**
     * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not
     * drop buffers for stream of streamId.
     */
    virtual status_t dropStreamBuffers(bool /*dropping*/, int /*streamId*/) = 0;
};

}; // namespace android
+14 −0
Original line number Diff line number Diff line
@@ -1977,6 +1977,20 @@ status_t Camera3Device::setConsumerSurfaces(int streamId,
    return OK;
}

status_t Camera3Device::dropStreamBuffers(bool dropping, int streamId) {
    Mutex::Autolock il(mInterfaceLock);
    Mutex::Autolock l(mLock);

    int idx = mOutputStreams.indexOfKey(streamId);
    if (idx == NAME_NOT_FOUND) {
        ALOGE("%s: Stream %d is not found.", __FUNCTION__, streamId);
        return BAD_VALUE;
    }

    sp<Camera3OutputStreamInterface> stream = mOutputStreams.editValueAt(idx);
    return stream->dropBuffers(dropping);
}

/**
 * Camera3Device private methods
 */
+6 −0
Original line number Diff line number Diff line
@@ -178,6 +178,12 @@ class Camera3Device :
     */
    status_t setConsumerSurfaces(int streamId, const std::vector<sp<Surface>>& consumers) override;

    /**
     * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not
     * drop buffers for stream of streamId.
     */
    status_t dropStreamBuffers(bool dropping, int streamId) override;

  private:

    // internal typedefs
Loading