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

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

Merge "Codec2: Finalize C2Component APIs and add C2ComponentFactory"

parents d9e9d982 c638dfa1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ enum {
 * mitigate binary breaks by adhering to the following conventions:
 *
 * - at most one vtable with placeholder virtual methods
 * - all optional/placeholder virtual methods returning a C2Status, with C2_OMITTED not requiring
 * - all optional/placeholder virtual methods returning a c2_status_t, with C2_OMITTED not requiring
 *   any update to input/output arguments.
 * - limiting symbol export of inline methods
 * - use of pimpl (or shared-pimpl)
@@ -106,9 +106,9 @@ typedef std::string C2String;
typedef const char *C2StringLiteral;

/**
 * C2Status: status codes used.
 * c2_status_t: status codes used.
 */
enum C2Status : int32_t {
enum c2_status_t : int32_t {

/*
 * Use android status constants if available. Otherwise, define the android status constants as
+41 −37
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public:
     * \retval C2_REFUSED       no permission to wait for the fence (unexpected - system)
     * \retval C2_CORRUPTED     some unknown error prevented waiting for the fence (unexpected)
     */
    C2Status wait(nsecs_t timeoutNs);
    c2_status_t wait(nsecs_t timeoutNs);

    /**
     * Used to check if this fence is valid (if there is a chance for it to be signaled.)
@@ -158,7 +158,7 @@ public:
     * \retval C2_REFUSED       no permission to signal the fence (unexpected - system)
     * \retval C2_CORRUPTED     some unknown error prevented signaling the fence(s) (unexpected)
     */
    C2Status fire();
    c2_status_t fire();

    /**
     * Trigger this event from the merging of the supplied fences. This means that it will be
@@ -172,7 +172,7 @@ public:
     * \retval C2_REFUSED       no permission to merge the fence (unexpected - system)
     * \retval C2_CORRUPTED     some unknown error prevented merging the fence(s) (unexpected)
     */
    C2Status merge(std::vector<C2Fence> fences);
    c2_status_t merge(std::vector<C2Fence> fences);

    /**
     * Abandons the event and any associated fence(s).
@@ -186,7 +186,7 @@ public:
     * \retval C2_REFUSED       no permission to abandon the fence (unexpected - system)
     * \retval C2_CORRUPTED     some unknown error prevented signaling the fence(s) (unexpected)
     */
    C2Status abandon();
    c2_status_t abandon();

private:
    class Impl;
@@ -200,12 +200,12 @@ private:
 * Interface for objects that encapsulate an updatable status value.
 */
struct _C2InnateStatus {
    inline C2Status status() const { return mStatus; }
    inline c2_status_t status() const { return mStatus; }

protected:
    _C2InnateStatus(C2Status status) : mStatus(status) { }
    _C2InnateStatus(c2_status_t status) : mStatus(status) { }

    C2Status mStatus; // this status is updatable by the object
    c2_status_t mStatus; // this status is updatable by the object
};

/// @}
@@ -230,10 +230,10 @@ public:
    }

protected:
    C2Acquirable(C2Status error, C2Fence fence, T t) : C2Fence(fence), mInitialError(error), mT(t) { }
    C2Acquirable(c2_status_t error, C2Fence fence, T t) : C2Fence(fence), mInitialError(error), mT(t) { }

private:
    C2Status mInitialError;
    c2_status_t mInitialError;
    T mT; // TODO: move instead of copy
};

@@ -449,11 +449,11 @@ public:
    /**
     * \return error during the creation/mapping of this view.
     */
    C2Status error() const;
    c2_status_t error() const;

protected:
    C2ReadView(const _C2LinearCapacityAspect *parent, const uint8_t *data);
    explicit C2ReadView(C2Status error);
    explicit C2ReadView(c2_status_t error);

private:
    class Impl;
@@ -482,11 +482,11 @@ public:
    /**
     * \return error during the creation/mapping of this view.
     */
    C2Status error() const;
    c2_status_t error() const;

protected:
    C2WriteView(const _C2LinearRangeAspect *parent, uint8_t *base);
    explicit C2WriteView(C2Status error);
    explicit C2WriteView(c2_status_t error);

private:
    class Impl;
@@ -631,7 +631,7 @@ public:
     * \retval C2_TIMED_OUT     the reservation timed out \todo when?
     * \retval C2_CORRUPTED     some unknown error prevented reserving space. (unexpected)
     */
    C2Status reserve(size_t size, C2Fence *fence /* nullable */);
    c2_status_t reserve(size_t size, C2Fence *fence /* nullable */);

    /**
     * Abandons a portion of this segment. This will move to the beginning of this segment.
@@ -644,7 +644,7 @@ public:
     * \retval C2_TIMED_OUT     the operation timed out (unexpected)
     * \retval C2_CORRUPTED     some unknown error prevented abandoning the data (unexpected)
     */
    C2Status abandon(size_t size);
    c2_status_t abandon(size_t size);

    /**
     * Share a portion as block(s) with consumers (these are moved to the used section).
@@ -661,7 +661,7 @@ public:
     * \retval C2_TIMED_OUT     the operation timed out (unexpected)
     * \retval C2_CORRUPTED     some unknown error prevented sharing the data (unexpected)
     */
    C2Status share(size_t size, C2Fence fence, std::list<C2ConstLinearBlock> &blocks);
    c2_status_t share(size_t size, C2Fence fence, std::list<C2ConstLinearBlock> &blocks);

    /**
     * Returns the beginning offset of this segment from the start of this circular block.
@@ -695,7 +695,7 @@ public:
    /**
     * \return error during the creation/mapping of this view.
     */
    C2Status error() const;
    c2_status_t error() const;
};

/**
@@ -716,7 +716,7 @@ public:
     * \param size    number of bytes to commit to the next segment
     * \param fence   fence used for the commit (the fence must signal before the data is committed)
     */
    C2Status commit(size_t size, C2Fence fence);
    c2_status_t commit(size_t size, C2Fence fence);

    /**
     * Maps this block into memory and returns a write view for it.
@@ -1016,14 +1016,14 @@ public:
    /**
     * \return error during the creation/mapping of this view.
     */
    C2Status error() const;
    c2_status_t error() const;

protected:
    C2GraphicView(
            const _C2PlanarCapacityAspect *parent,
            uint8_t *const *data,
            const C2PlaneLayout& layout);
    explicit C2GraphicView(C2Status error);
    explicit C2GraphicView(c2_status_t error);

private:
    class Impl;
@@ -1224,7 +1224,7 @@ public:
     * \retval C2_NO_MEMORY not enough memory to register for this callback
     * \retval C2_CORRUPTED an unknown error prevented the registration (unexpected)
     */
    C2Status registerOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr);
    c2_status_t registerOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr);

    /**
     * Unregisters a previously registered pre-destroy notification.
@@ -1236,7 +1236,7 @@ public:
     * \retval C2_NOT_FOUND the notification was not found
     * \retval C2_CORRUPTED an unknown error prevented the registration (unexpected)
     */
    C2Status unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr);
    c2_status_t unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr);

    ///@}

@@ -1262,7 +1262,7 @@ public:
     * \retval C2_NO_MEMORY not enough memory to attach the metadata (this return value is not
     *                      used if the same kind of metadata is already attached to the buffer).
     */
    C2Status setInfo(const std::shared_ptr<C2Info> &info);
    c2_status_t setInfo(const std::shared_ptr<C2Info> &info);

    /**
     * Checks if there is a certain type of metadata attached to this buffer.
@@ -1385,7 +1385,7 @@ public:
     *                      the usage flags are invalid (caller error)
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
     */
    virtual C2Status map(
    virtual c2_status_t map(
            size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd /* nullable */,
            void **addr /* nonnull */) = 0;

@@ -1409,7 +1409,7 @@ public:
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
     * \retval C2_REFUSED   no permission to unmap the portion (unexpected - system)
     */
    virtual C2Status unmap(void *addr, size_t size, int *fenceFd /* nullable */) = 0;
    virtual c2_status_t unmap(void *addr, size_t size, int *fenceFd /* nullable */) = 0;

    /**
     * Returns true if this is a valid allocation.
@@ -1472,7 +1472,7 @@ public:
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)

     */
    virtual C2Status map(
    virtual c2_status_t map(
            C2Rect rect, C2MemoryUsage usage, int *fenceFd,
            // TODO: return <addr, size> buffers with plane sizes
            C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) = 0;
@@ -1492,7 +1492,7 @@ public:
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
     * \retval C2_REFUSED   no permission to unmap the section (unexpected - system)
     */
    virtual C2Status unmap(C2Fence *fenceFd /* nullable */) = 0;
    virtual c2_status_t unmap(C2Fence *fenceFd /* nullable */) = 0;

    /**
     * Returns true if this is a valid allocation.
@@ -1544,8 +1544,10 @@ public:

    /**
     * Information about an allocator.
     *
     * Allocators don't have a query API so all queriable information is stored here.
     */
    struct Info {
    struct Traits {
        C2String name;              ///< allocator name
        id_t id;                    ///< allocator ID
        type_t supportedTypes;      ///< supported allocation types
@@ -1574,13 +1576,15 @@ public:
    virtual id_t getId() const = 0;

    /**
     * Returns the allocator information.
     * Returns the allocator traits.
     *
     * This method MUST be "non-blocking" and return within 1ms.
     *
     * Allocators don't have a full-fledged query API, only this method.
     *
     * \return allocator information
     */
    virtual std::shared_ptr<const Info> getInfo() const = 0;
    virtual std::shared_ptr<const Traits> getTraits() const = 0;

    /**
     * Allocates a 1D allocation of given |capacity| and |usage|. If successful, the allocation is
@@ -1604,7 +1608,7 @@ public:
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status newLinearAllocation(
    virtual c2_status_t newLinearAllocation(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2LinearAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
@@ -1627,7 +1631,7 @@ public:
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status priorLinearAllocation(
    virtual c2_status_t priorLinearAllocation(
            const C2Handle *handle __unused,
            std::shared_ptr<C2LinearAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
@@ -1660,7 +1664,7 @@ public:
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status newGraphicAllocation(
    virtual c2_status_t newGraphicAllocation(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
            C2MemoryUsage usage __unused,
            std::shared_ptr<C2GraphicAllocation> *allocation /* nonnull */) {
@@ -1684,7 +1688,7 @@ public:
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during recreation (unexpected)
     */
    virtual C2Status priorGraphicAllocation(
    virtual c2_status_t priorGraphicAllocation(
            const C2Handle *handle __unused,
            std::shared_ptr<C2GraphicAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
@@ -1764,7 +1768,7 @@ public:
     * \retval C2_OMITTED   this pool does not support linear blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     */
    virtual C2Status fetchLinearBlock(
    virtual c2_status_t fetchLinearBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2LinearBlock> *block /* nonnull */) {
        *block = nullptr;
@@ -1792,7 +1796,7 @@ public:
     * \retval C2_OMITTED   this pool does not support circular blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     */
    virtual C2Status fetchCircularBlock(
    virtual c2_status_t fetchCircularBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2CircularBlock> *block /* nonnull */) {
        *block = nullptr;
@@ -1823,7 +1827,7 @@ public:
     * \retval C2_OMITTED   this pool does not support 2D blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     */
    virtual C2Status fetchGraphicBlock(
    virtual c2_status_t fetchGraphicBlock(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
            C2MemoryUsage usage __unused,
            std::shared_ptr<C2GraphicBlock> *block /* nonnull */) {
Loading