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

Commit 1b40f280 authored by Lajos Molnar's avatar Lajos Molnar Committed by Jeff Tinker
Browse files

stagefright: IOMX: pass native handle in sp<NativeHandle>

This clarifies ownership of the native handle

Bug: 28644266
Bug: 27856976
Change-Id: I7a617513d7ac93dd58d74af9469663418735aaf3
parent 6393ea69
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ namespace android {
class IMemory;
class IMemory;
class IOMXObserver;
class IOMXObserver;
class IOMXRenderer;
class IOMXRenderer;
class NativeHandle;
class Surface;
class Surface;


class IOMX : public IInterface {
class IOMX : public IInterface {
@@ -145,7 +146,7 @@ public:
    // pointer is just that, a pointer into local address space.
    // pointer is just that, a pointer into local address space.
    virtual status_t allocateSecureBuffer(
    virtual status_t allocateSecureBuffer(
            node_id node, OMX_U32 port_index, size_t size,
            node_id node, OMX_U32 port_index, size_t size,
            buffer_id *buffer, void **buffer_data, native_handle_t **native_handle) = 0;
            buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle) = 0;


    // Allocate an OMX buffer of size |allotedSize|. Use |params| as the backup buffer, which
    // Allocate an OMX buffer of size |allotedSize|. Use |params| as the backup buffer, which
    // may be larger.
    // may be larger.
+6 −4
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@
#include <media/IOMX.h>
#include <media/IOMX.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/openmax/OMX_IndexExt.h>
#include <media/openmax/OMX_IndexExt.h>
#include <utils/NativeHandle.h>


namespace android {
namespace android {


@@ -465,7 +466,7 @@ public:


    virtual status_t allocateSecureBuffer(
    virtual status_t allocateSecureBuffer(
            node_id node, OMX_U32 port_index, size_t size,
            node_id node, OMX_U32 port_index, size_t size,
            buffer_id *buffer, void **buffer_data, native_handle_t **native_handle) {
            buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle) {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
        data.writeInt32((int32_t)node);
        data.writeInt32((int32_t)node);
@@ -484,7 +485,8 @@ public:
        *buffer = (buffer_id)reply.readInt32();
        *buffer = (buffer_id)reply.readInt32();
        *buffer_data = (void *)reply.readInt64();
        *buffer_data = (void *)reply.readInt64();
        if (*buffer_data == NULL) {
        if (*buffer_data == NULL) {
            *native_handle = reply.readNativeHandle();
            *native_handle = NativeHandle::create(
                    reply.readNativeHandle(), true /* ownsHandle */);
        } else {
        } else {
            *native_handle = NULL;
            *native_handle = NULL;
        }
        }
@@ -1063,7 +1065,7 @@ status_t BnOMX::onTransact(


            buffer_id buffer;
            buffer_id buffer;
            void *buffer_data = NULL;
            void *buffer_data = NULL;
            native_handle_t *native_handle = NULL;
            sp<NativeHandle> native_handle;
            status_t err = allocateSecureBuffer(
            status_t err = allocateSecureBuffer(
                    node, port_index, size, &buffer, &buffer_data, &native_handle);
                    node, port_index, size, &buffer, &buffer_data, &native_handle);
            reply->writeInt32(err);
            reply->writeInt32(err);
@@ -1072,7 +1074,7 @@ status_t BnOMX::onTransact(
                reply->writeInt32((int32_t)buffer);
                reply->writeInt32((int32_t)buffer);
                reply->writeInt64((uintptr_t)buffer_data);
                reply->writeInt64((uintptr_t)buffer_data);
                if (buffer_data == NULL) {
                if (buffer_data == NULL) {
                    reply->writeNativeHandle(native_handle);
                    reply->writeNativeHandle(native_handle == NULL ? NULL : native_handle->handle());
                }
                }
            }
            }


+6 −3
Original line number Original line Diff line number Diff line
@@ -867,7 +867,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
                    mem.clear();
                    mem.clear();


                    void *ptr = NULL;
                    void *ptr = NULL;
                    native_handle_t *native_handle = NULL;
                    sp<NativeHandle> native_handle;
                    err = mOMX->allocateSecureBuffer(
                    err = mOMX->allocateSecureBuffer(
                            mNode, portIndex, bufSize, &info.mBufferID,
                            mNode, portIndex, bufSize, &info.mBufferID,
                            &ptr, &native_handle);
                            &ptr, &native_handle);
@@ -880,8 +880,11 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {


                    // TRICKY2: use native handle as the base of the ABuffer if received one,
                    // TRICKY2: use native handle as the base of the ABuffer if received one,
                    // because Widevine source only receives these base addresses.
                    // because Widevine source only receives these base addresses.
                    info.mData = new ABuffer(ptr != NULL ? ptr : (void *)native_handle, bufSize);
                    const native_handle_t *native_handle_ptr =
                    info.mNativeHandle = NativeHandle::create(native_handle, true /* ownsHandle */);
                        native_handle == NULL ? NULL : native_handle->handle();
                    info.mData = new ABuffer(
                            ptr != NULL ? ptr : (void *)native_handle_ptr, bufSize);
                    info.mNativeHandle = native_handle;
                    info.mCodecData = info.mData;
                    info.mCodecData = info.mData;
                } else if (mQuirks & requiresAllocateBufferBit) {
                } else if (mQuirks & requiresAllocateBufferBit) {
                    err = mOMX->allocateBufferWithBackup(
                    err = mOMX->allocateBufferWithBackup(
+2 −2
Original line number Original line Diff line number Diff line
@@ -127,7 +127,7 @@ struct MuxOMX : public IOMX {


    virtual status_t allocateSecureBuffer(
    virtual status_t allocateSecureBuffer(
            node_id node, OMX_U32 port_index, size_t size,
            node_id node, OMX_U32 port_index, size_t size,
            buffer_id *buffer, void **buffer_data, native_handle_t **native_handle);
            buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle);


    virtual status_t allocateBufferWithBackup(
    virtual status_t allocateBufferWithBackup(
            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
@@ -415,7 +415,7 @@ status_t MuxOMX::signalEndOfInputStream(node_id node) {


status_t MuxOMX::allocateSecureBuffer(
status_t MuxOMX::allocateSecureBuffer(
        node_id node, OMX_U32 port_index, size_t size,
        node_id node, OMX_U32 port_index, size_t size,
        buffer_id *buffer, void **buffer_data, native_handle_t **native_handle) {
        buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle) {
    return getOMX(node)->allocateSecureBuffer(
    return getOMX(node)->allocateSecureBuffer(
            node, port_index, size, buffer, buffer_data, native_handle);
            node, port_index, size, buffer, buffer_data, native_handle);
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -111,7 +111,7 @@ public:


    virtual status_t allocateSecureBuffer(
    virtual status_t allocateSecureBuffer(
            node_id node, OMX_U32 port_index, size_t size,
            node_id node, OMX_U32 port_index, size_t size,
            buffer_id *buffer, void **buffer_data, native_handle_t **native_handle);
            buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle);


    virtual status_t allocateBufferWithBackup(
    virtual status_t allocateBufferWithBackup(
            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
Loading