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

Commit bb32f870 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enable pooled C2BlockPool" into pi-dev

parents 23409227 e321f352
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -760,19 +760,18 @@ void CCodecBufferChannel::setComponent(const std::shared_ptr<C2Component> &compo

        ALOGV("graphic = %s", graphic ? "true" : "false");
        std::shared_ptr<C2BlockPool> pool;
        err = GetCodec2BlockPool(
                graphic ? C2BlockPool::BASIC_GRAPHIC : C2BlockPool::BASIC_LINEAR,
                component,
                &pool);
        if (graphic) {
            err = GetCodec2BlockPool(C2BlockPool::BASIC_GRAPHIC, component, &pool);
        } else {
            err = CreateCodec2BlockPool(C2PlatformAllocatorStore::ION,
                                        component, &pool);
        }

        if (err == C2_OK) {
            (*buffers)->setPool(pool);
        } else {
            // TODO: error
        }
        // TODO: remove once we switch to proper buffer pool.
        if (!graphic) {
            *buffers = (*buffers)->toArrayMode();
        }
    }

    {
+9 −6
Original line number Diff line number Diff line
@@ -302,12 +302,15 @@ void SimpleC2Component::processQueue() {
            if (err != C2_OK) {
                return err;
            }
            if (outputFormat.value == C2FormatVideo) {
                err = GetCodec2BlockPool(
                    (outputFormat.value == C2FormatVideo)
                    ? C2BlockPool::BASIC_GRAPHIC
                    : C2BlockPool::BASIC_LINEAR,
                    shared_from_this(),
                    &mOutputBlockPool);
                        C2BlockPool::BASIC_GRAPHIC,
                        shared_from_this(), &mOutputBlockPool);
            } else {
                err = CreateCodec2BlockPool(
                        C2PlatformAllocatorStore::ION,
                        shared_from_this(), &mOutputBlockPool);
            }
            if (err != C2_OK) {
                return err;
            }
+4 −2
Original line number Diff line number Diff line
@@ -232,7 +232,8 @@ class C2BufferUtilsTest : public ::testing::Test {
class C2BufferTest : public ::testing::Test {
public:
    C2BufferTest()
        : mLinearAllocator(std::make_shared<C2AllocatorIon>('i')),
        : mBlockPoolId(C2BlockPool::PLATFORM_START),
          mLinearAllocator(std::make_shared<C2AllocatorIon>('i')),
          mSize(0u),
          mAddr(nullptr),
          mGraphicAllocator(std::make_shared<C2AllocatorGralloc>('g')) {
@@ -281,7 +282,7 @@ public:
    }

    std::shared_ptr<C2BlockPool> makeLinearBlockPool() {
        return std::make_shared<C2BasicLinearBlockPool>(mLinearAllocator);
        return std::make_shared<C2PooledBlockPool>(mLinearAllocator, mBlockPoolId++);
    }

    void allocateGraphic(uint32_t width, uint32_t height) {
@@ -328,6 +329,7 @@ public:
    }

private:
    C2BlockPool::local_id_t mBlockPoolId;
    std::shared_ptr<C2Allocator> mLinearAllocator;
    std::shared_ptr<C2LinearAllocation> mLinearAllocation;
    size_t mSize;
+3 −0
Original line number Diff line number Diff line
@@ -39,14 +39,17 @@ cc_library_shared {
    shared_libs: [
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.media.bufferpool@1.0",
        "libbinder",
        "libcutils",
        "libdl",
        "libhardware",
        "libhidlbase",
        "libion",
        "libfmq",
        "liblog",
        "libstagefright_foundation",
        "libstagefright_bufferpool@1.0",
        "libui",
        "libutils",
    ],
+9 −4
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ private:
     * so that we can capture the error.
     *
     * \param ionFd     ion client (ownership transferred to created object)
     * \param owned     whehter native_handle_t is owned by an allocation or not.
     * \param capacity  size of allocation
     * \param bufferFd  buffer handle (ownership transferred to created object). Must be
     *                  invalid if err is not 0.
@@ -157,8 +158,9 @@ private:
     *                  invalid if err is not 0.
     * \param err       errno during buffer allocation or import
     */
    Impl(int ionFd, size_t capacity, int bufferFd, ion_user_handle_t buffer, C2Allocator::id_t id, int err)
    Impl(int ionFd, bool owned, size_t capacity, int bufferFd, ion_user_handle_t buffer, C2Allocator::id_t id, int err)
        : mIonFd(ionFd),
          mHandleOwned(owned),
          mHandle(bufferFd, capacity),
          mBuffer(buffer),
          mId(id),
@@ -189,7 +191,7 @@ public:
    static Impl *Import(int ionFd, size_t capacity, int bufferFd, C2Allocator::id_t id) {
        ion_user_handle_t buffer = -1;
        int ret = ion_import(ionFd, bufferFd, &buffer);
        return new Impl(ionFd, capacity, bufferFd, buffer, id, ret);
        return new Impl(ionFd, false, capacity, bufferFd, buffer, id, ret);
    }

    /**
@@ -216,7 +218,7 @@ public:
                buffer = -1;
            }
        }
        return new Impl(ionFd, size, bufferFd, buffer, id, ret);
        return new Impl(ionFd, true, size, bufferFd, buffer, id, ret);
    }

    c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence, void **addr) {
@@ -313,8 +315,10 @@ public:
        if (mIonFd >= 0) {
            close(mIonFd);
        }
        if (mHandleOwned) {
            native_handle_close(&mHandle);
        }
    }

    c2_status_t status() const {
        return mInit;
@@ -334,6 +338,7 @@ public:

private:
    int mIonFd;
    bool mHandleOwned;
    C2HandleIon mHandle;
    ion_user_handle_t mBuffer;
    C2Allocator::id_t mId;
Loading