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

Commit a936ac26 authored by Chien-Yu Chen's avatar Chien-Yu Chen Committed by Trevor Bunker
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
(cherry picked from commit c75eb9b126b2c6b7fc8f47d8ae4e4ac15f6a176e)
parent 7e94f954
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)
+6 −0
Original line number Diff line number Diff line
@@ -359,6 +359,12 @@ class CameraDeviceBase : public virtual RefBase {
            const std::vector<android::camera3::OutputStreamInfo> &outputInfo,
            const std::vector<size_t> &removedSurfaceIds,
            KeyedVector<sp<Surface>, size_t> *outputMap/*out*/) = 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
@@ -2039,6 +2039,20 @@ status_t Camera3Device::updateStream(int streamId, const std::vector<sp<Surface>
    return res;
}

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
@@ -192,6 +192,12 @@ class Camera3Device :
            const std::vector<size_t> &removedSurfaceIds,
            KeyedVector<sp<Surface>, size_t> *outputMap/*out*/);

    /**
     * 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