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

Commit cb78e0b0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Replace android.hidl.allocator usage" into main am: dccd0d07

parents 6d7e38df dccd0d07
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ cc_fuzz {
        "libstagefright_httplive_headers",
    ],
    shared_libs: [
        "libbase",
        "libcrypto",
        "libstagefright_foundation",
        "libhidlbase",
+20 −26
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@
#include "ESQueue.h"

#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <cutils/ashmem.h>
#include <cutils/native_handle.h>
#include <hidlmemory/mapping.h>
#include <media/cas/DescramblerAPI.h>
@@ -46,12 +46,12 @@
#include <inttypes.h>

namespace android {
using hardware::hidl_handle;
using hardware::hidl_string;
using hardware::hidl_vec;
using hardware::hidl_memory;
using namespace hardware::cas::V1_0;
using namespace hardware::cas::native::V1_0;
typedef hidl::allocator::V1_0::IAllocator TAllocator;
typedef hidl::memory::V1_0::IMemory TMemory;

// I want the expression "y" evaluated even if verbose logging is off.
@@ -210,7 +210,6 @@ private:
    bool mSampleEncrypted;
    sp<AMessage> mSampleAesKeyItem;
    sp<TMemory> mHidlMemory;
    sp<TAllocator> mHidlAllocator;
    hardware::cas::native::V1_0::SharedBuffer mDescramblerSrcBuffer;
    sp<ABuffer> mDescrambledBuffer;
    List<SubSampleInfo> mSubSamples;
@@ -1006,34 +1005,29 @@ bool ATSParser::Stream::ensureBufferCapacity(size_t neededSize) {
    sp<ABuffer> newBuffer, newScrambledBuffer;
    sp<TMemory> newMem;
    if (mScrambled) {
        if (mHidlAllocator == nullptr) {
            mHidlAllocator = TAllocator::getService("ashmem");
            if (mHidlAllocator == nullptr) {
                ALOGE("[stream %d] can't get hidl allocator", mElementaryPID);
        int fd = ashmem_create_region("mediaATS", neededSize);
        if (fd < 0) {
             ALOGE("[stream %d] create_ashmem_region failed for size %zu. FD returned: %d",
                    mElementaryPID, neededSize, fd);
            return false;
        }
        }

        hidl_memory hidlMemToken;
        bool success;
        auto transStatus = mHidlAllocator->allocate(
                neededSize,
                [&success, &hidlMemToken](
                        bool s,
                        hidl_memory const& m) {
                    success = s;
                    hidlMemToken = m;
                });

        if (!transStatus.isOk()) {
            ALOGE("[stream %d] hidl allocator failed at the transport: %s",
                    mElementaryPID, transStatus.description().c_str());
            return false;
        native_handle_t* handle = native_handle_create(1 /*numFds*/, 0/*numInts*/);
        if (handle == nullptr) {
            ALOGE("[stream %d] failed to create a native_handle_t", mElementaryPID);
            if (close(fd)) {
                ALOGE("[stream %d] failed to close ashmem fd. errno: %s", mElementaryPID,
                      strerror(errno));
            }
        if (!success) {
            ALOGE("[stream %d] hidl allocator failed", mElementaryPID);

            return false;
        }

        handle->data[0] = fd;
        hidl_handle memHandle;
        memHandle.setTo(handle, true /*shouldOwn*/);
        hidl_memory hidlMemToken("ashmem", memHandle, neededSize);

        newMem = mapMemory(hidlMemToken);
        if (newMem == nullptr || newMem->getPointer() == nullptr) {
            ALOGE("[stream %d] hidl failed to map memory", mElementaryPID);
+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ cc_defaults {
        "libhidlmemory",
        "android.hardware.cas.native@1.0",
        "android.hidl.memory@1.0",
        "android.hidl.allocator@1.0",
    ],

    header_libs: [
+1 −2
Original line number Diff line number Diff line
@@ -37,9 +37,8 @@ cc_test{
    shared_libs: [
        "android.hardware.cas@1.0",
        "android.hardware.cas.native@1.0",
        "android.hidl.token@1.0-utils",
        "android.hidl.allocator@1.0",
        "libcrypto",
        "libcutils",
        "libhidlbase",
        "libhidlmemory",
        "liblog",