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

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

Merge "ACodec: handle state machine being stuck"

parents d662d4c0 3034eec3
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -5556,6 +5556,11 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatCheckIfStuck: {
            ALOGV("No-op by default");
            break;
        }

        default:
            return false;
    }
@@ -7873,6 +7878,18 @@ bool ACodec::OutputPortSettingsChangedState::onMessageReceived(
            break;
        }

        case kWhatCheckIfStuck:
        {
            int32_t generation = 0;
            CHECK(msg->findInt32("generation", &generation));
            if (generation == mCodec->mStateGeneration) {
                mCodec->signalError(OMX_ErrorUndefined, TIMED_OUT);
            }

            handled = true;
            break;
        }

        default:
            handled = BaseState::onMessageReceived(msg);
            break;
@@ -7884,6 +7901,11 @@ bool ACodec::OutputPortSettingsChangedState::onMessageReceived(
void ACodec::OutputPortSettingsChangedState::stateEntered() {
    ALOGV("[%s] Now handling output port settings change",
         mCodec->mComponentName.c_str());

    // If we haven't transitioned after 3 seconds, we're probably stuck.
    sp<AMessage> msg = new AMessage(ACodec::kWhatCheckIfStuck, mCodec);
    msg->setInt32("generation", mCodec->mStateGeneration);
    msg->post(3000000);
}

bool ACodec::OutputPortSettingsChangedState::onOMXFrameRendered(
@@ -8146,6 +8168,11 @@ void ACodec::FlushingState::stateEntered() {
    ALOGV("[%s] Now Flushing", mCodec->mComponentName.c_str());

    mFlushComplete[kPortIndexInput] = mFlushComplete[kPortIndexOutput] = false;

    // If we haven't transitioned after 3 seconds, we're probably stuck.
    sp<AMessage> msg = new AMessage(ACodec::kWhatCheckIfStuck, mCodec);
    msg->setInt32("generation", mCodec->mStateGeneration);
    msg->post(3000000);
}

bool ACodec::FlushingState::onMessageReceived(const sp<AMessage> &msg) {
@@ -8160,6 +8187,7 @@ bool ACodec::FlushingState::onMessageReceived(const sp<AMessage> &msg) {
                msg->setInt32("generation", mCodec->mStateGeneration);
                msg->post(3000000);
            }
            handled = true;
            break;
        }

@@ -8180,6 +8208,18 @@ bool ACodec::FlushingState::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatCheckIfStuck:
        {
            int32_t generation = 0;
            CHECK(msg->findInt32("generation", &generation));
            if (generation == mCodec->mStateGeneration) {
                mCodec->signalError(OMX_ErrorUndefined, TIMED_OUT);
            }

            handled = true;
            break;
        }

        default:
            handled = BaseState::onMessageReceived(msg);
            break;
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ private:
        kWhatOMXDied                 = 'OMXd',
        kWhatReleaseCodecInstance    = 'relC',
        kWhatForceStateTransition    = 'fstt',
        kWhatCheckIfStuck            = 'Cstk',
    };

    enum {