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

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

Merge "Camera: Avoid stream re-configuration when format gets overridden" into oc-mr1-dev

parents 2999d359 710c142d
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -121,18 +121,17 @@ status_t CallbackProcessor::updateStream(const Parameters &params) {

    if (mCallbackStreamId != NO_STREAM) {
        // Check if stream parameters have to change
        uint32_t currentWidth, currentHeight, currentFormat;
        res = device->getStreamInfo(mCallbackStreamId,
                &currentWidth, &currentHeight, &currentFormat, 0);
        CameraDeviceBase::StreamInfo streamInfo;
        res = device->getStreamInfo(mCallbackStreamId, &streamInfo);
        if (res != OK) {
            ALOGE("%s: Camera %d: Error querying callback output stream info: "
                    "%s (%d)", __FUNCTION__, mId,
                    strerror(-res), res);
            return res;
        }
        if (currentWidth != (uint32_t)params.previewWidth ||
                currentHeight != (uint32_t)params.previewHeight ||
                currentFormat != (uint32_t)callbackFormat) {
        if (streamInfo.width != (uint32_t)params.previewWidth ||
                streamInfo.height != (uint32_t)params.previewHeight ||
                !streamInfo.matchFormat((uint32_t)callbackFormat)) {
            // Since size should only change while preview is not running,
            // assuming that all existing use of old callback stream is
            // completed.
+4 −5
Original line number Diff line number Diff line
@@ -136,17 +136,16 @@ status_t JpegProcessor::updateStream(const Parameters &params) {

    if (mCaptureStreamId != NO_STREAM) {
        // Check if stream parameters have to change
        uint32_t currentWidth, currentHeight;
        res = device->getStreamInfo(mCaptureStreamId,
                &currentWidth, &currentHeight, 0, 0);
        CameraDeviceBase::StreamInfo streamInfo;
        res = device->getStreamInfo(mCaptureStreamId, &streamInfo);
        if (res != OK) {
            ALOGE("%s: Camera %d: Error querying capture output stream info: "
                    "%s (%d)", __FUNCTION__,
                    mId, strerror(-res), res);
            return res;
        }
        if (currentWidth != (uint32_t)params.pictureWidth ||
                currentHeight != (uint32_t)params.pictureHeight) {
        if (streamInfo.width != (uint32_t)params.pictureWidth ||
                streamInfo.height != (uint32_t)params.pictureHeight) {
            ALOGV("%s: Camera %d: Deleting stream %d since the buffer dimensions changed",
                __FUNCTION__, mId, mCaptureStreamId);
            res = device->deleteStream(mCaptureStreamId);
+17 −24
Original line number Diff line number Diff line
@@ -161,18 +161,17 @@ status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {

    if (mPreviewStreamId != NO_STREAM) {
        // Check if stream parameters have to change
        uint32_t currentWidth, currentHeight;
        res = device->getStreamInfo(mPreviewStreamId,
                &currentWidth, &currentHeight, 0, 0);
        CameraDeviceBase::StreamInfo streamInfo;
        res = device->getStreamInfo(mPreviewStreamId, &streamInfo);
        if (res != OK) {
            ALOGE("%s: Camera %d: Error querying preview stream info: "
                    "%s (%d)", __FUNCTION__, mId, strerror(-res), res);
            return res;
        }
        if (currentWidth != (uint32_t)params.previewWidth ||
                currentHeight != (uint32_t)params.previewHeight) {
        if (streamInfo.width != (uint32_t)params.previewWidth ||
                streamInfo.height != (uint32_t)params.previewHeight) {
            ALOGV("%s: Camera %d: Preview size switch: %d x %d -> %d x %d",
                    __FUNCTION__, mId, currentWidth, currentHeight,
                    __FUNCTION__, mId, streamInfo.width, streamInfo.height,
                    params.previewWidth, params.previewHeight);
            res = device->waitUntilDrained();
            if (res != OK) {
@@ -312,10 +311,8 @@ status_t StreamingProcessor::recordingStreamNeedsUpdate(
        return INVALID_OPERATION;
    }

    uint32_t currentWidth, currentHeight, currentFormat;
    android_dataspace currentDataSpace;
    res = device->getStreamInfo(mRecordingStreamId,
            &currentWidth, &currentHeight, &currentFormat, &currentDataSpace);
    CameraDeviceBase::StreamInfo streamInfo;
    res = device->getStreamInfo(mRecordingStreamId, &streamInfo);
    if (res != OK) {
        ALOGE("%s: Camera %d: Error querying recording output stream info: "
                "%s (%d)", __FUNCTION__, mId,
@@ -324,10 +321,10 @@ status_t StreamingProcessor::recordingStreamNeedsUpdate(
    }

    if (mRecordingWindow == nullptr ||
            currentWidth != (uint32_t)params.videoWidth ||
            currentHeight != (uint32_t)params.videoHeight ||
            currentFormat != (uint32_t)params.videoFormat ||
            currentDataSpace != params.videoDataSpace) {
            streamInfo.width != (uint32_t)params.videoWidth ||
            streamInfo.height != (uint32_t)params.videoHeight ||
            !streamInfo.matchFormat((uint32_t)params.videoFormat) ||
            streamInfo.dataSpace != params.videoDataSpace) {
        *needsUpdate = true;
        return res;
    }
@@ -348,22 +345,18 @@ status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {

    if (mRecordingStreamId != NO_STREAM) {
        // Check if stream parameters have to change
        uint32_t currentWidth, currentHeight;
        uint32_t currentFormat;
        android_dataspace currentDataSpace;
        res = device->getStreamInfo(mRecordingStreamId,
                &currentWidth, &currentHeight,
                &currentFormat, &currentDataSpace);
        CameraDeviceBase::StreamInfo streamInfo;
        res = device->getStreamInfo(mRecordingStreamId, &streamInfo);
        if (res != OK) {
            ALOGE("%s: Camera %d: Error querying recording output stream info: "
                    "%s (%d)", __FUNCTION__, mId,
                    strerror(-res), res);
            return res;
        }
        if (currentWidth != (uint32_t)params.videoWidth ||
                currentHeight != (uint32_t)params.videoHeight ||
                currentFormat != (uint32_t)params.videoFormat ||
                currentDataSpace != params.videoDataSpace) {
        if (streamInfo.width != (uint32_t)params.videoWidth ||
                streamInfo.height != (uint32_t)params.videoHeight ||
                !streamInfo.matchFormat((uint32_t)params.videoFormat) ||
                streamInfo.dataSpace != params.videoDataSpace) {
            // TODO: Should wait to be sure previous recording has finished
            res = device->deleteStream(mRecordingStreamId);

+4 −5
Original line number Diff line number Diff line
@@ -233,17 +233,16 @@ status_t ZslProcessor::updateStream(const Parameters &params) {

    if ((mZslStreamId != NO_STREAM) || (mInputStreamId != NO_STREAM)) {
        // Check if stream parameters have to change
        uint32_t currentWidth, currentHeight;
        res = device->getStreamInfo(mZslStreamId,
                &currentWidth, &currentHeight, 0, 0);
        CameraDeviceBase::StreamInfo streamInfo;
        res = device->getStreamInfo(mZslStreamId, &streamInfo);
        if (res != OK) {
            ALOGE("%s: Camera %d: Error querying capture output stream info: "
                    "%s (%d)", __FUNCTION__,
                    client->getCameraId(), strerror(-res), res);
            return res;
        }
        if (currentWidth != (uint32_t)params.fastInfo.arrayWidth ||
                currentHeight != (uint32_t)params.fastInfo.arrayHeight) {
        if (streamInfo.width != (uint32_t)params.fastInfo.arrayWidth ||
                streamInfo.height != (uint32_t)params.fastInfo.arrayHeight) {
            if (mZslStreamId != NO_STREAM) {
                ALOGV("%s: Camera %d: Deleting stream %d since the buffer "
                      "dimensions changed",
+23 −3
Original line number Diff line number Diff line
@@ -142,12 +142,32 @@ class CameraDeviceBase : public virtual RefBase {
    virtual status_t createInputStream(uint32_t width, uint32_t height,
            int32_t format, /*out*/ int32_t *id) = 0;

    struct StreamInfo {
        uint32_t width;
        uint32_t height;
        uint32_t format;
        bool formatOverridden;
        uint32_t originalFormat;
        android_dataspace dataSpace;
        StreamInfo() : width(0), height(0), format(0), formatOverridden(false), originalFormat(0),
                dataSpace(HAL_DATASPACE_UNKNOWN) {}
        /**
         * Check whether the format matches the current or the original one in case
         * it got overridden.
         */
        bool matchFormat(uint32_t clientFormat) {
            if ((formatOverridden && (originalFormat == clientFormat)) ||
                    (format == clientFormat)) {
                return true;
            }
            return false;
        }
    };

    /**
     * Get information about a given stream.
     */
    virtual status_t getStreamInfo(int id,
            uint32_t *width, uint32_t *height,
            uint32_t *format, android_dataspace *dataSpace) = 0;
    virtual status_t getStreamInfo(int id, StreamInfo *streamInfo) = 0;

    /**
     * Set stream gralloc buffer transform
Loading