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

Commit 7ae3111d authored by Venkatarama Avadhani's avatar Venkatarama Avadhani Committed by Marco Nelissen
Browse files

Notify Errors Appropriately from SoftMPEG2

This is to ensure that the framework realises that an error has
occured and does not call onQueueFilled if the error is fatal.

Bug: 36715268
Merged-In: If02499d306aa9b6df64a7f25d43d1bdf318a10cd
Change-Id: I6911d2e8899cc3a472b5ba5ecdcfbd92233ecfa6
parent 7c86ed20
Loading
Loading
Loading
Loading
+46 −7
Original line number Diff line number Diff line
@@ -81,11 +81,21 @@ SoftMPEG2::SoftMPEG2(
    GENERATE_FILE_NAMES();
    CREATE_DUMP_FILE(mInFile);

    CHECK_EQ(initDecoder(), (status_t)OK);
    if (OK != initDecoder()) {
        ALOGE("Failed to initialize decoder");
        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
        mSignalledError = true;
        return;
    }
}

SoftMPEG2::~SoftMPEG2() {
    CHECK_EQ(deInitDecoder(), (status_t)OK);
    if (OK != deInitDecoder()) {
        ALOGE("Failed to deinit decoder");
        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
        mSignalledError = true;
        return;
    }
}


@@ -202,6 +212,9 @@ status_t SoftMPEG2::resetDecoder() {
    /* Set number of cores/threads to be used by the codec */
    setNumCores();

    mStride = 0;
    mSignalledError = false;

    return OK;
}

@@ -383,7 +396,8 @@ status_t SoftMPEG2::initDecoder() {
    resetPlugin();

    /* Set the run time (dynamic) parameters */
    setParams(displayStride);
    mStride = outputBufferWidth();
    setParams(mStride);

    /* Set number of cores/threads to be used by the codec */
    setNumCores();
@@ -428,6 +442,7 @@ status_t SoftMPEG2::deInitDecoder() {

    mInitNeeded = true;
    mChangingResolution = false;
    mCodecCtx = NULL;

    return OK;
}
@@ -439,10 +454,13 @@ status_t SoftMPEG2::reInitDecoder() {

    ret = initDecoder();
    if (OK != ret) {
        ALOGE("Create failure");
        ALOGE("Failed to initialize decoder");
        deInitDecoder();
        return NO_MEMORY;
        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
        mSignalledError = true;
        return ret;
    }
    mSignalledError = false;
    return OK;
}

@@ -540,6 +558,9 @@ void SoftMPEG2::onPortFlushCompleted(OMX_U32 portIndex) {
void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
    UNUSED(portIndex);

    if (mSignalledError) {
        return;
    }
    if (mOutputPortSettingsChange != NONE) {
        return;
    }
@@ -547,6 +568,12 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
    List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
    List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);

    if (outputBufferWidth() != mStride) {
        /* Set the run-time (dynamic) parameters */
        mStride = outputBufferWidth();
        setParams(mStride);
    }

    /* If input EOS is seen and decoder is not in flush mode,
     * set the decoder in flush mode.
     * There can be a case where EOS is sent along with last picture data
@@ -600,7 +627,12 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
            bool portWillReset = false;
            handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight);

            CHECK_EQ(reInitDecoder(), (status_t)OK);
            if (OK != reInitDecoder()) {
                ALOGE("Failed to reinitialize decoder");
                notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
                mSignalledError = true;
                return;
            }
            return;
        }

@@ -671,7 +703,12 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
                bool portWillReset = false;
                handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht);

                CHECK_EQ(reInitDecoder(), (status_t)OK);
                if (OK != reInitDecoder()) {
                    ALOGE("Failed to reinitialize decoder");
                    notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
                    mSignalledError = true;
                    return;
                }

                if (setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx)) {
                    ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op);
@@ -685,6 +722,8 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
                mChangingResolution = false;
                resetDecoder();
                resetPlugin();
                mStride = outputBufferWidth();
                setParams(mStride);
                continue;
            }

+2 −0
Original line number Diff line number Diff line
@@ -105,7 +105,9 @@ private:
    // codec. So the codec is switching to decode the new resolution.
    bool mChangingResolution;
    bool mFlushNeeded;
    bool mSignalledError;
    bool mWaitForI;
    size_t mStride;

    status_t initDecoder();
    status_t deInitDecoder();