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

Commit fd866b3a authored by Wei Jia's avatar Wei Jia
Browse files

SimpleSoftOMXComponent: change CHECK to error notification.

SoftAVCDec, SoftMPEG4: fix handling of zero-byte input buffer.

ACodec: do not send empty input buffer without EOS to the omx component.

Bug: 22199127
Change-Id: I0bbcf5778f969ba6e30d0db31770c4289e2b64a4
parent 065f6572
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4864,6 +4864,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
        case RESUBMIT_BUFFERS:
        {
            if (buffer != NULL && !mCodec->mPortEOS[kPortIndexInput]) {
                // Do not send empty input buffer w/o EOS to the component.
                if (buffer->size() == 0 && !eos) {
                    postFillThisBuffer(info);
                    break;
                }

                int64_t timeUs;
                CHECK(buffer->meta()->findInt64("timeUs", &timeUs));

+14 −2
Original line number Diff line number Diff line
@@ -627,6 +627,11 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
            if (!inQueue.empty()) {
                inInfo = *inQueue.begin();
                inHeader = inInfo->mHeader;
                if (inHeader == NULL) {
                    inQueue.erase(inQueue.begin());
                    inInfo->mOwnedByUs = false;
                    continue;
                }
            } else {
                break;
            }
@@ -638,14 +643,21 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
        outHeader->nTimeStamp = 0;
        outHeader->nOffset = 0;

        if (inHeader != NULL && (inHeader->nFlags & OMX_BUFFERFLAG_EOS)) {
            mReceivedEOS = true;
        if (inHeader != NULL) {
            if (inHeader->nFilledLen == 0) {
                inQueue.erase(inQueue.begin());
                inInfo->mOwnedByUs = false;
                notifyEmptyBufferDone(inHeader);

                if (!(inHeader->nFlags & OMX_BUFFERFLAG_EOS)) {
                    continue;
                }

                mReceivedEOS = true;
                inHeader = NULL;
                setFlushMode();
            } else if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
                mReceivedEOS = true;
            }
        }

+20 −13
Original line number Diff line number Diff line
@@ -103,19 +103,25 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
    while (!inQueue.empty() && outQueue.size() == kNumOutputBuffers) {
        BufferInfo *inInfo = *inQueue.begin();
        OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
        if (inHeader == NULL) {
            inQueue.erase(inQueue.begin());
            inInfo->mOwnedByUs = false;
            continue;
        }

        PortInfo *port = editPortInfo(1);

        OMX_BUFFERHEADERTYPE *outHeader =
            port->mBuffers.editItemAt(mNumSamplesOutput & 1).mHeader;

        if ((inHeader->nFlags & OMX_BUFFERFLAG_EOS) && inHeader->nFilledLen == 0) {
        if (inHeader->nFilledLen == 0) {
            inQueue.erase(inQueue.begin());
            inInfo->mOwnedByUs = false;
            notifyEmptyBufferDone(inHeader);

            ++mInputBufferCount;

            if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
                outHeader->nFilledLen = 0;
                outHeader->nFlags = OMX_BUFFERFLAG_EOS;

@@ -131,6 +137,7 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {

                notifyFillBufferDone(outHeader);
                outHeader = NULL;
            }
            return;
        }

+9 −1
Original line number Diff line number Diff line
@@ -505,7 +505,15 @@ void SimpleSoftOMXComponent::onPortFlush(
    CHECK_LT(portIndex, mPorts.size());

    PortInfo *port = &mPorts.editItemAt(portIndex);
    CHECK_EQ((int)port->mTransition, (int)PortInfo::NONE);
    // Ideally, the port should not in transitioning state when flushing.
    // However, in error handling case, e.g., the client can't allocate buffers
    // when it tries to re-enable the port, the port will be stuck in ENABLING.
    // The client will then transition the component from Executing to Idle,
    // which leads to flushing ports. At this time, it should be ok to notify
    // the client of the error and still clear all buffers on the port.
    if (port->mTransition != PortInfo::NONE) {
        notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
    }

    for (size_t i = 0; i < port->mBuffers.size(); ++i) {
        BufferInfo *buffer = &port->mBuffers.editItemAt(i);