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

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

Merge "Abort read() after CameraSource has stopped" into pi-dev

parents 155af760 44b042ca
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ CameraSource::CameraSource(
      mNumFramesReceived(0),
      mLastFrameTimestampUs(0),
      mStarted(false),
      mEos(false),
      mNumFramesEncoded(0),
      mTimeBetweenFrameCaptureUs(0),
      mFirstFrameTimeUs(0),
@@ -880,6 +881,7 @@ status_t CameraSource::reset() {
    {
        Mutex::Autolock autoLock(mLock);
        mStarted = false;
        mEos = false;
        mStopSystemTimeUs = -1;
        mFrameAvailableCondition.signal();

@@ -1075,7 +1077,7 @@ status_t CameraSource::read(

    {
        Mutex::Autolock autoLock(mLock);
        while (mStarted && mFramesReceived.empty()) {
        while (mStarted && !mEos && mFramesReceived.empty()) {
            if (NO_ERROR !=
                mFrameAvailableCondition.waitRelative(mLock,
                    mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
@@ -1091,6 +1093,9 @@ status_t CameraSource::read(
        if (!mStarted) {
            return OK;
        }
        if (mFramesReceived.empty()) {
            return ERROR_END_OF_STREAM;
        }
        frame = *mFramesReceived.begin();
        mFramesReceived.erase(mFramesReceived.begin());

@@ -1129,6 +1134,8 @@ bool CameraSource::shouldSkipFrameLocked(int64_t timestampUs) {
    if (mStopSystemTimeUs != -1 && timestampUs >= mStopSystemTimeUs) {
        ALOGV("Drop Camera frame at %lld  stop time: %lld us",
                (long long)timestampUs, (long long)mStopSystemTimeUs);
        mEos = true;
        mFrameAvailableCondition.signal();
        return true;
    }

+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ protected:
    int32_t mNumFramesReceived;
    int64_t mLastFrameTimestampUs;
    bool mStarted;
    bool mEos;
    int32_t mNumFramesEncoded;

    // Time between capture of two frames.