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

Commit 1b4ca5ce authored by Andreas Huber's avatar Andreas Huber Committed by Jamie Gennis
Browse files

Avoid a deadlock during EmptyBufferDone

The deadlock happens withen in the case where we use an OMX encoder with a
GraphicBufferSource.

Bug: 8329090
Change-Id: Icec58bb85ff3839ad1a2e3eca02fa9d6d133ca45
parent e2dfa5a4
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -779,6 +779,23 @@ void OMXNodeInstance::onMessage(const omx_message &msg) {
            static_cast<BufferMeta *>(buffer->pAppPrivate);

        buffer_meta->CopyFromOMX(buffer);
    } else if (msg.type == omx_message::EMPTY_BUFFER_DONE) {
        const sp<GraphicBufferSource>& bufferSource(getGraphicBufferSource());

        if (bufferSource != NULL) {
            // This is one of the buffers used exclusively by
            // GraphicBufferSource.
            // Don't dispatch a message back to ACodec, since it doesn't
            // know that anyone asked to have the buffer emptied and will
            // be very confused.

            OMX_BUFFERHEADERTYPE *buffer =
                static_cast<OMX_BUFFERHEADERTYPE *>(
                        msg.u.buffer_data.buffer);

            bufferSource->codecBufferEmptied(buffer);
            return;
        }
    }

    mObserver->onMessage(msg);
@@ -839,17 +856,6 @@ OMX_ERRORTYPE OMXNodeInstance::OnEmptyBufferDone(
    if (instance->mDying) {
        return OMX_ErrorNone;
    }
    const sp<GraphicBufferSource>& bufferSource(
            instance->getGraphicBufferSource());
    if (bufferSource != NULL) {
        bufferSource->codecBufferEmptied(pBuffer);

        // This is one of the buffers used exclusively by GraphicBufferSource.
        // Don't dispatch a message back to ACodec, since it doesn't
        // know that anyone asked to have the buffer emptied and will
        // be very confused.
        return OMX_ErrorNone;
    }
    return instance->owner()->OnEmptyBufferDone(instance->nodeID(), pBuffer);
}