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

Commit c18e2734 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Handle idle->loaded state transition when loaded->idle is still in progress

Bug: 31156921
Bug: 23270724
Change-Id: I926cab482fadecb8bb885d85e0d083a4501596fd
parent 5472aee4
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -431,7 +431,19 @@ void SimpleSoftOMXComponent::onSendCommand(
}

void SimpleSoftOMXComponent::onChangeState(OMX_STATETYPE state) {
    ALOGV("%p requesting change from %d to %d", this, mState, state);
    // We shouldn't be in a state transition already.

    if (mState == OMX_StateLoaded
            && mTargetState == OMX_StateIdle
            && state == OMX_StateLoaded) {
        // OMX specifically allows "canceling" a state transition from loaded
        // to idle. Pretend we made it to idle, and go back to loaded
        ALOGV("load->idle canceled");
        mState = mTargetState = OMX_StateIdle;
        state = OMX_StateLoaded;
    }

    CHECK_EQ((int)mState, (int)mTargetState);

    switch (mState) {
@@ -611,6 +623,7 @@ void SimpleSoftOMXComponent::checkTransitions() {
        }

        if (transitionComplete) {
            ALOGV("state transition from %d to %d complete", mState, mTargetState);
            mState = mTargetState;

            if (mState == OMX_StateLoaded) {
@@ -618,6 +631,8 @@ void SimpleSoftOMXComponent::checkTransitions() {
            }

            notify(OMX_EventCmdComplete, OMX_CommandStateSet, mState, NULL);
        } else {
            ALOGV("state transition from %d to %d not yet complete", mState, mTargetState);
        }
    }