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

Commit 5e57c2cf authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru Committed by Android Code Review
Browse files

Merge "Stagefright: Return error if codec takes too long to return a buffer."

parents 01caec8c e086ad8d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -3015,6 +3015,8 @@ sp<MetaData> OMXCodec::getFormat() {

status_t OMXCodec::read(
        MediaBuffer **buffer, const ReadOptions *options) {

    status_t wait_status = 0;
    *buffer = NULL;

    Mutex::Autolock autoLock(mLock);
@@ -3084,12 +3086,20 @@ status_t OMXCodec::read(
        }

        while (mSeekTimeUs >= 0) {
            mBufferFilled.wait(mLock);
            wait_status = mBufferFilled.waitRelative(mLock, 3000000000);
            if (wait_status) {
                LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
                return UNKNOWN_ERROR;
            }
        }
    }

    while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
        mBufferFilled.wait(mLock);
        wait_status = mBufferFilled.waitRelative(mLock, 3000000000);
        if (wait_status) {
            LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
            return UNKNOWN_ERROR;
        }
    }

    if (mState == ERROR) {