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

Commit 450bf4b0 authored by Andreas Huber's avatar Andreas Huber
Browse files

Fixes a race condition between entering ERROR state and initial buffer submit.

parent a8a371c8
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1272,7 +1272,7 @@ void OMXCodec::fillOutputBuffers() {
}

void OMXCodec::drainInputBuffers() {
    CHECK_EQ(mState, EXECUTING);
    CHECK(mState == EXECUTING || mState == RECONFIGURING);

    Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput];
    for (size_t i = 0; i < buffers->size(); ++i) {
@@ -1716,15 +1716,20 @@ status_t OMXCodec::read(

    Mutex::Autolock autoLock(mLock);

    if (mState != EXECUTING && mState != RECONFIGURING) {
        return UNKNOWN_ERROR;
    }

    if (mInitialBufferSubmit) {
        mInitialBufferSubmit = false;

        drainInputBuffers();

        if (mState == EXECUTING) {
            // Otherwise mState == RECONFIGURING and this code will trigger
            // after the output port is reenabled.
            fillOutputBuffers();
        }

    if (mState != EXECUTING && mState != RECONFIGURING) {
        return UNKNOWN_ERROR;
    }

    int64_t seekTimeUs;