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

Commit 42aae0c4 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android Git Automerger
Browse files

am f04e8b5e: am 25842048: Merge "stagefright: try to free codec instance if...

am f04e8b5e: am 25842048: Merge "stagefright: try to free codec instance if MediaCodec.release hangs" into lmp-dev

* commit 'f04e8b5e':
  stagefright: try to free codec instance if MediaCodec.release hangs
parents 8274b049 f04e8b5e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -120,6 +120,7 @@ private:
        kWhatSetParameters           = 'setP',
        kWhatSetParameters           = 'setP',
        kWhatSubmitOutputMetaDataBufferIfEOS = 'subm',
        kWhatSubmitOutputMetaDataBufferIfEOS = 'subm',
        kWhatOMXDied                 = 'OMXd',
        kWhatOMXDied                 = 'OMXd',
        kWhatReleaseCodecInstance    = 'relC',
    };
    };


    enum {
    enum {
+24 −0
Original line number Original line Diff line number Diff line
@@ -498,6 +498,10 @@ void ACodec::initiateShutdown(bool keepComponentAllocated) {
    sp<AMessage> msg = new AMessage(kWhatShutdown, id());
    sp<AMessage> msg = new AMessage(kWhatShutdown, id());
    msg->setInt32("keepComponentAllocated", keepComponentAllocated);
    msg->setInt32("keepComponentAllocated", keepComponentAllocated);
    msg->post();
    msg->post();
    if (!keepComponentAllocated) {
        // ensure shutdown completes in 3 seconds
        (new AMessage(kWhatReleaseCodecInstance, id()))->post(3000000);
    }
}
}


void ACodec::signalRequestIDRFrame() {
void ACodec::signalRequestIDRFrame() {
@@ -3797,6 +3801,19 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
            break;
            break;
        }
        }


        case ACodec::kWhatReleaseCodecInstance:
        {
            ALOGI("[%s] forcing the release of codec",
                    mCodec->mComponentName.c_str());
            status_t err = mCodec->mOMX->freeNode(mCodec->mNode);
            ALOGE_IF("[%s] failed to release codec instance: err=%d",
                       mCodec->mComponentName.c_str(), err);
            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", CodecBase::kWhatShutdownCompleted);
            notify->post();
            break;
        }

        default:
        default:
            return false;
            return false;
    }
    }
@@ -4456,6 +4473,13 @@ bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) {
            break;
            break;
        }
        }


        case ACodec::kWhatReleaseCodecInstance:
        {
            // nothing to do, as we have already signaled shutdown
            handled = true;
            break;
        }

        default:
        default:
            return BaseState::onMessageReceived(msg);
            return BaseState::onMessageReceived(msg);
    }
    }
+5 −0
Original line number Original line Diff line number Diff line
@@ -149,6 +149,11 @@ static status_t StatusFromOMXError(OMX_ERRORTYPE err) {
status_t OMXNodeInstance::freeNode(OMXMaster *master) {
status_t OMXNodeInstance::freeNode(OMXMaster *master) {
    static int32_t kMaxNumIterations = 10;
    static int32_t kMaxNumIterations = 10;


    // exit if we have already freed the node
    if (mHandle == NULL) {
        return OK;
    }

    // Transition the node from its current state all the way down
    // Transition the node from its current state all the way down
    // to "Loaded".
    // to "Loaded".
    // This ensures that all active buffers are properly freed even
    // This ensures that all active buffers are properly freed even