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

Commit 898a9a9b authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2: Fix recording bugs

 - Release recording stream on shutdown
 - Return recording gralloc buffers to queue when they are received by
   camera service after recording has been stopped (which is normal
   behavior thanks to pipeline latencies in camera pipelines)

Bug: 6243944
Change-Id: Ia13a501c726613fd1e404733456dbd10d7b00132
parent 4865aa8a
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -338,6 +338,11 @@ void Camera2Client::disconnect() {
        mCaptureStreamId = NO_STREAM;
        mCaptureStreamId = NO_STREAM;
    }
    }


    if (mRecordingStreamId != NO_STREAM) {
        mDevice->deleteStream(mRecordingStreamId);
        mRecordingStreamId = NO_STREAM;
    }

    CameraService::Client::disconnect();
    CameraService::Client::disconnect();
}
}


@@ -1492,10 +1497,12 @@ void Camera2Client::onRecordingFrameAvailable() {
    {
    {
        Mutex::Autolock icl(mICameraLock);
        Mutex::Autolock icl(mICameraLock);
        // TODO: Signal errors here upstream
        // TODO: Signal errors here upstream
        bool discardData = false;
        if (mState != RECORD && mState != VIDEO_SNAPSHOT) {
        if (mState != RECORD && mState != VIDEO_SNAPSHOT) {
            ALOGE("%s: Camera %d: Recording image buffer produced unexpectedly!",
            ALOGV("%s: Camera %d: Discarding recording image buffers received after "
                    "recording done",
                    __FUNCTION__, mCameraId);
                    __FUNCTION__, mCameraId);
            return;
            discardData = true;
        }
        }


        CpuConsumer::LockedBuffer imgBuffer;
        CpuConsumer::LockedBuffer imgBuffer;
@@ -1509,9 +1516,14 @@ void Camera2Client::onRecordingFrameAvailable() {
        if (imgBuffer.format != (int)kRecordingFormat) {
        if (imgBuffer.format != (int)kRecordingFormat) {
            ALOGE("%s: Camera %d: Unexpected recording format: %x",
            ALOGE("%s: Camera %d: Unexpected recording format: %x",
                    __FUNCTION__, mCameraId, imgBuffer.format);
                    __FUNCTION__, mCameraId, imgBuffer.format);
            discardData = true;
        }

        if (discardData) {
            mRecordingConsumer->unlockBuffer(imgBuffer);
            mRecordingConsumer->unlockBuffer(imgBuffer);
            return;
            return;
        }
        }

        size_t bufferSize = imgBuffer.width * imgBuffer.height * 3 / 2;
        size_t bufferSize = imgBuffer.width * imgBuffer.height * 3 / 2;


        if (mRecordingHeap == 0 ||
        if (mRecordingHeap == 0 ||