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 Original line Diff line number Diff line
@@ -217,6 +217,7 @@ CameraSource::CameraSource(
      mNumFramesReceived(0),
      mNumFramesReceived(0),
      mLastFrameTimestampUs(0),
      mLastFrameTimestampUs(0),
      mStarted(false),
      mStarted(false),
      mEos(false),
      mNumFramesEncoded(0),
      mNumFramesEncoded(0),
      mTimeBetweenFrameCaptureUs(0),
      mTimeBetweenFrameCaptureUs(0),
      mFirstFrameTimeUs(0),
      mFirstFrameTimeUs(0),
@@ -880,6 +881,7 @@ status_t CameraSource::reset() {
    {
    {
        Mutex::Autolock autoLock(mLock);
        Mutex::Autolock autoLock(mLock);
        mStarted = false;
        mStarted = false;
        mEos = false;
        mStopSystemTimeUs = -1;
        mStopSystemTimeUs = -1;
        mFrameAvailableCondition.signal();
        mFrameAvailableCondition.signal();


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


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


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


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


    // Time between capture of two frames.
    // Time between capture of two frames.