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

Commit bf65553e authored by Ruben Brunk's avatar Ruben Brunk Committed by Android (Google) Code Review
Browse files

Merge "Handle recording failure more gracefully."

parents 3f80319d 26cee964
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ protected:
                 const sp<IGraphicBufferProducer>& surface,
                 bool storeMetaDataInVideoBuffers);

    virtual void startCameraRecording();
    virtual status_t startCameraRecording();
    virtual void releaseRecordingFrame(const sp<IMemory>& frame);

    // Returns true if need to skip the current frame.
+19 −8
Original line number Diff line number Diff line
@@ -586,14 +586,15 @@ CameraSource::~CameraSource() {
    }
}

void CameraSource::startCameraRecording() {
status_t CameraSource::startCameraRecording() {
    ALOGV("startCameraRecording");
    // Reset the identity to the current thread because media server owns the
    // camera and recording is started by the applications. The applications
    // will connect to the camera in ICameraRecordingProxy::startRecording.
    int64_t token = IPCThreadState::self()->clearCallingIdentity();
    status_t err;
    if (mNumInputBuffers > 0) {
        status_t err = mCamera->sendCommand(
        err = mCamera->sendCommand(
            CAMERA_CMD_SET_VIDEO_BUFFER_COUNT, mNumInputBuffers, 0);

        // This could happen for CameraHAL1 clients; thus the failure is
@@ -604,17 +605,25 @@ void CameraSource::startCameraRecording() {
        }
    }

    err = OK;
    if (mCameraFlags & FLAGS_HOT_CAMERA) {
        mCamera->unlock();
        mCamera.clear();
        CHECK_EQ((status_t)OK,
            mCameraRecordingProxy->startRecording(new ProxyListener(this)));
        if ((err = mCameraRecordingProxy->startRecording(
                new ProxyListener(this))) != OK) {
            ALOGE("Failed to start recording, received error: %s (%d)",
                    strerror(-err), err);
        }
    } else {
        mCamera->setListener(new CameraSourceListener(this));
        mCamera->startRecording();
        CHECK(mCamera->recordingEnabled());
        if (!mCamera->recordingEnabled()) {
            err = -EINVAL;
            ALOGE("Failed to start recording");
        }
    }
    IPCThreadState::self()->restoreCallingIdentity(token);
    return err;
}

status_t CameraSource::start(MetaData *meta) {
@@ -646,10 +655,12 @@ status_t CameraSource::start(MetaData *meta) {
        }
    }

    startCameraRecording();

    status_t err;
    if ((err = startCameraRecording()) == OK) {
        mStarted = true;
    return OK;
    }

    return err;
}

void CameraSource::stopCameraRecording() {