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

Commit 27a7b609 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Ricardo Cerqueira
Browse files

libstagefright: Fix to free buffers properly in ERROR state

- In the ERROR state, OMXCodec::on_message tries to free the output
  buffers in the FBD sequence. This can fail if the OMX component hasn't
  been moved to idle state.
- OMXNodeInstance does not check for the return value of OMX_FreeBuffer
  call and returns the buffer entry from the list of active buffers
- This buffer ends up being unfreed which can adversely affect
  the next video playback

(cherry picked from commit 6ef3096b6db1cee7fec57da3ae4c519cdaa28bbb)

Change-Id: I9d80fd0f3c3e75da41697370f787df72316b32e4
CRs-Fixed: 329874
parent 79ed227b
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3370,6 +3370,13 @@ status_t OMXCodec::freeBuffer(OMX_U32 portIndex, size_t bufIndex) {
    if (err == OK) {
        buffers->removeAt(bufIndex);
    }
#ifdef QCOM_HARDWARE
    else {
        LOGW("Warning, free Buffer failed, to be freed later"
             " returning OK to prevent crash..");
        return OK;
    }
#endif

    return err;
}
@@ -4550,6 +4557,12 @@ status_t OMXCodec::stop() {
            if (state != OMX_StateExecuting) {
                break;
            }
#ifdef QCOM_HARDWARE
            else {
                CODEC_LOGV("Component is still in executing state, fall through and move component"
                           " to idle");
            }
#endif
            // else fall through to the idling code
            isError = true;
        }
+15 −0
Original line number Diff line number Diff line
@@ -599,15 +599,30 @@ status_t OMXNodeInstance::freeBuffer(
        OMX_U32 portIndex, OMX::buffer_id buffer) {
    Mutex::Autolock autoLock(mLock);

#ifndef QCOM_HARDWARE
    removeActiveBuffer(portIndex, buffer);
#endif

    OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer;
    BufferMeta *buffer_meta = static_cast<BufferMeta *>(header->pAppPrivate);

    OMX_ERRORTYPE err = OMX_FreeBuffer(mHandle, portIndex, header);

#ifdef QCOM_HARDWARE
    if (err == OMX_ErrorNone) {
        removeActiveBuffer(portIndex, buffer);

        if (buffer_meta) {
            delete buffer_meta;
            buffer_meta = NULL;
        }
    } else {
        LOGE("OMX_FreeBuffer failed with err 0x%08x", err);
    }
#else
    delete buffer_meta;
    buffer_meta = NULL;
#endif

    return StatusFromOMXError(err);
}