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

Commit 45145a39 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

Codec2: finalize C2 status constants

Bug: 64121714
Test: unittest
Change-Id: Id229f49e1db85751f9e4f28b5a4c0a7d15358e28
parent 8f35d0b4
Loading
Loading
Loading
Loading
+33 −21
Original line number Diff line number Diff line
@@ -66,8 +66,8 @@ 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 status_t, with C2_NOT_IMPLEMENTED not
 *   requiring any update to input/output arguments.
 * - all optional/placeholder virtual methods returning a C2Status, with C2_OMITTED not requiring
 *   any update to input/output arguments.
 * - limiting symbol export of inline methods
 * - use of pimpl (or shared-pimpl)
 *
@@ -98,25 +98,36 @@ enum {
 * C2String: basic string implementation
 */
typedef std::string C2String;

/**
 * C2StringLiteral: basic string literal implementation.
 * \note these are never owned by any object, and can only refer to C string literals.
 */
typedef const char *C2StringLiteral;

/**
 * C2Status: status codes used.
 */
//typedef int32_t C2Status;
enum C2Status : int32_t {

/*
 * Use android status constants if available. Otherwise, define the android status constants as
 * additional enum values using POSIX errno constants.
 */
#ifndef __ANDROID__
    OK                  = 0,
    ALREADY_EXISTS      = -EEXIST,
    BAD_VALUE           = -EINVAL,
    BAD_INDEX           = -EOVERFLOW,
    UNKNOWN_TRANSACTION = -EBADMSG,
    ALREADY_EXISTS      = -EEXIST,
    NAME_NOT_FOUND      = -ENOENT,
    FAILED_TRANSACTION  = -ENOTSUP,
    INVALID_OPERATION   = -ENOSYS,
    NAME_NOT_FOUND      = -ENOENT,
    NO_MEMORY           = -ENOMEM,
    NO_INIT             = -ENODEV,
    OK                  = 0,
    PERMISSION_DENIED   = -EPERM,
    TIMED_OUT           = -ETIMEDOUT,
    UNKNOWN_ERROR       = -EINVAL,
    UNKNOWN_ERROR       = -EFAULT,
    UNKNOWN_TRANSACTION = -EBADMSG,
#endif

    C2_OK        = OK,                   ///< operation completed successfully
@@ -124,7 +135,7 @@ enum C2Status : int32_t {
    // bad input
    C2_BAD_VALUE = BAD_VALUE,            ///< argument has invalid value (user error)
    C2_BAD_INDEX = BAD_INDEX,            ///< argument uses invalid index (user error)
    C2_UNSUPPORTED      = UNKNOWN_TRANSACTION,  ///< argument/index is value but not supported \todo is this really BAD_INDEX/VALUE?
    C2_CANNOT_DO = FAILED_TRANSACTION,   ///< argument/index is valid but not possible

    // bad sequencing of events
    C2_DUPLICATE = ALREADY_EXISTS,       ///< object already exists
@@ -133,11 +144,12 @@ enum C2Status : int32_t {

    // bad environment
    C2_NO_MEMORY = NO_MEMORY,            ///< not enough memory to complete operation
    C2_NO_PERMISSION    = PERMISSION_DENIED,    ///< missing permission to complete operation
    C2_REFUSED   = PERMISSION_DENIED,    ///< missing permission to complete operation

    C2_TIMED_OUT = TIMED_OUT,            ///< operation did not complete within timeout

    // bad versioning
    C2_NOT_IMPLEMENTED  = UNKNOWN_TRANSACTION,  ///< operation is not implemented (optional only) \todo for now reuse error code
    C2_OMITTED   = UNKNOWN_TRANSACTION,  ///< operation is not implemented/supported (optional only)

    // unknown fatal
    C2_CORRUPTED = UNKNOWN_ERROR,        ///< some unexpected error prevented the operation
+29 −29
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public:
     * \retval C2_TIMED_OUT     the fence has not been signaled within the timeout
     * \retval C2_BAD_STATE     the fence has been abandoned without being signaled (it will never
     *                          be signaled)
     * \retval C2_NO_PERMISSION no permission to wait for the fence (unexpected - system)
     * \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);
@@ -155,7 +155,7 @@ public:
     * \retval C2_OK            the fence(s) were successfully signaled
     * \retval C2_BAD_STATE     the fence(s) have already been abandoned or merged (caller error)
     * \retval C2_DUPLICATE     the fence(s) have already been signaled (caller error)
     * \retval C2_NO_PERMISSION no permission to signal the fence (unexpected - system)
     * \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();
@@ -169,7 +169,7 @@ public:
     * \retval C2_NO_MEMORY     not enough memory to perform the merging
     * \retval C2_DUPLICATE     the fence have already been merged (caller error)
     * \retval C2_BAD_STATE     the fence have already been signaled or abandoned (caller error)
     * \retval C2_NO_PERMISSION no permission to merge the fence (unexpected - system)
     * \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);
@@ -183,7 +183,7 @@ public:
     * \retval C2_OK            the fence(s) were successfully signaled
     * \retval C2_BAD_STATE     the fence(s) have already been signaled or merged (caller error)
     * \retval C2_DUPLICATE     the fence(s) have already been abandoned (caller error)
     * \retval C2_NO_PERMISSION no permission to abandon the fence (unexpected - system)
     * \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();
@@ -1377,7 +1377,7 @@ public:
     * \todo Do we need to support sync operation as we could just wait for the fence?
     *
     * \retval C2_OK        the operation was successful
     * \retval C2_NO_PERMISSION no permission to map the portion
     * \retval C2_REFUSED   no permission to map the portion
     * \retval C2_TIMED_OUT the operation timed out
     * \retval C2_DUPLICATE if the allocation is already mapped.
     * \retval C2_NO_MEMORY not enough memory to complete the operation
@@ -1407,7 +1407,7 @@ public:
     * \retval C2_BAD_VALUE the parameters (addr/size) do not correspond to previously mapped
     *                      regions (caller error)
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
     * \retval C2_NO_PERMISSION no permission to unmap the portion (unexpected - system)
     * \retval C2_REFUSED   no permission to unmap the portion (unexpected - system)
     */
    virtual C2Status unmap(void *addr, size_t size, int *fenceFd /* nullable */) = 0;

@@ -1463,7 +1463,7 @@ public:
     * \todo Do we need to support sync operation as we could just wait for the fence?
     *
     * \retval C2_OK        the operation was successful
     * \retval C2_NO_PERMISSION no permission to map the section
     * \retval C2_REFUSED   no permission to map the section
     * \retval C2_DUPLICATE there is already a mapped region (caller error)
     * \retval C2_TIMED_OUT the operation timed out
     * \retval C2_NO_MEMORY not enough memory to complete the operation
@@ -1490,7 +1490,7 @@ public:
     * \retval C2_TIMED_OUT the operation timed out
     * \retval C2_NOT_FOUND there is no mapped region (caller error)
     * \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
     * \retval C2_NO_PERMISSION no permission to unmap the section (unexpected - system)
     * \retval C2_REFUSED   no permission to unmap the section (unexpected - system)
     */
    virtual C2Status unmap(C2Fence *fenceFd /* nullable */) = 0;

@@ -1545,16 +1545,16 @@ public:
     * \retval C2_OK        the allocation was successful
     * \retval C2_NO_MEMORY not enough memory to complete the allocation
     * \retval C2_TIMED_OUT the allocation timed out
     * \retval C2_NO_PERMISSION     no permission to complete the allocation
     * \retval C2_REFUSED   no permission to complete the allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_UNSUPPORTED       this allocator does not support 1D allocations
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status allocateLinearBuffer(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2LinearAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    /**
@@ -1568,16 +1568,16 @@ public:
     * \retval C2_OK        the allocation was recreated successfully
     * \retval C2_NO_MEMORY not enough memory to recreate the allocation
     * \retval C2_TIMED_OUT the recreation timed out (unexpected)
     * \retval C2_NO_PERMISSION     no permission to recreate the allocation
     * \retval C2_REFUSED   no permission to recreate the allocation
     * \retval C2_BAD_VALUE invalid handle (caller error)
     * \retval C2_UNSUPPORTED       this allocator does not support 1D allocations
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status recreateLinearBuffer(
            const C2Handle *handle __unused,
            std::shared_ptr<C2LinearAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    /**
@@ -1601,9 +1601,9 @@ public:
     * \retval C2_OK        the allocation was successful
     * \retval C2_NO_MEMORY not enough memory to complete the allocation
     * \retval C2_TIMED_OUT the allocation timed out
     * \retval C2_NO_PERMISSION     no permission to complete the allocation
     * \retval C2_REFUSED   no permission to complete the allocation
     * \retval C2_BAD_VALUE width, height, format or usage are not supported (invalid) (caller error)
     * \retval C2_UNSUPPORTED       this allocator does not support 2D allocations
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status allocateGraphicBuffer(
@@ -1611,7 +1611,7 @@ public:
            C2MemoryUsage usage __unused,
            std::shared_ptr<C2GraphicAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    /**
@@ -1625,16 +1625,16 @@ public:
     * \retval C2_OK        the allocation was recreated successfully
     * \retval C2_NO_MEMORY not enough memory to recreate the allocation
     * \retval C2_TIMED_OUT the recreation timed out (unexpected)
     * \retval C2_NO_PERMISSION     no permission to recreate the allocation
     * \retval C2_REFUSED   no permission to recreate the allocation
     * \retval C2_BAD_VALUE invalid handle (caller error)
     * \retval C2_UNSUPPORTED       this allocator does not support 2D allocations
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during recreation (unexpected)
     */
    virtual C2Status recreateGraphicBuffer(
            const C2Handle *handle __unused,
            std::shared_ptr<C2GraphicAllocation> *allocation /* nonnull */) {
        *allocation = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

protected:
@@ -1669,16 +1669,16 @@ public:
     * \retval C2_OK        the allocation was successful
     * \retval C2_NO_MEMORY not enough memory to complete the allocation
     * \retval C2_TIMED_OUT the allocation timed out
     * \retval C2_NO_PERMISSION     no permission to complete the allocation
     * \retval C2_REFUSED   no permission to complete the allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_UNSUPPORTED       this allocator does not support linear allocations
     * \retval C2_OMITTED   this allocator does not support linear allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status allocateLinearBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2LinearBlock> *block /* nonnull */) {
        *block = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    /**
@@ -1698,16 +1698,16 @@ public:
     * \retval C2_OK            the allocation was successful
     * \retval C2_NO_MEMORY     not enough memory to complete the allocation
     * \retval C2_TIMED_OUT     the allocation timed out
     * \retval C2_NO_PERMISSION     no permission to complete the allocation
     * \retval C2_REFUSED       no permission to complete the allocation
     * \retval C2_BAD_VALUE     capacity or usage are not supported (invalid) (caller error)
     * \retval C2_UNSUPPORTED   this allocator does not support circular allocations
     * \retval C2_OMITTED       this allocator does not support circular allocations
     * \retval C2_CORRUPTED     some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status allocateCircularBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2CircularBlock> *block /* nonnull */) {
        *block = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    /**
@@ -1731,9 +1731,9 @@ public:
     * \retval C2_OK            the allocation was successful
     * \retval C2_NO_MEMORY     not enough memory to complete the allocation
     * \retval C2_TIMED_OUT     the allocation timed out
     * \retval C2_NO_PERMISSION     no permission to complete the allocation
     * \retval C2_REFUSED       no permission to complete the allocation
     * \retval C2_BAD_VALUE     width, height, format or usage are not supported (invalid) (caller error)
     * \retval C2_UNSUPPORTED   this allocator does not support 2D allocations
     * \retval C2_OMITTED       this allocator does not support 2D allocations
     * \retval C2_CORRUPTED     some unknown, unrecoverable error occured during allocation (unexpected)
     */
    virtual C2Status allocateGraphicBlock(
@@ -1741,7 +1741,7 @@ public:
            C2MemoryUsage usage __unused,
            std::shared_ptr<C2GraphicBlock> *block /* nonnull */) {
        *block = nullptr;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

protected:
+5 −3
Original line number Diff line number Diff line
@@ -250,7 +250,8 @@ public:
     * \retval C2_OK        the tunnel was successfully created
     * \retval C2_BAD_INDEX the target component does not exist
     * \retval C2_DUPLICATE the tunnel already exists
     * \retval C2_UNSUPPORTED  the tunnel is not supported
     * \retval C2_OMITTED   tunneling is not supported by this component
     * \retval C2_CANNOT_DO the specific tunnel is not supported
     *
     * \retval C2_TIMED_OUT could not create the tunnel within the time limit (unexpected)
     * \retval C2_CORRUPTED some unknown error prevented the creation of the tunnel (unexpected)
@@ -271,6 +272,7 @@ public:
     * \retval C2_OK        the tunnel was marked for release successfully
     * \retval C2_BAD_INDEX the target component does not exist
     * \retval C2_NOT_FOUND the tunnel does not exist
     * \retval C2_OMITTED   tunneling is not supported by this component
     *
     * \retval C2_TIMED_OUT could not mark the tunnel for release within the time limit (unexpected)
     * \retval C2_CORRUPTED some unknown error prevented the release of the tunnel (unexpected)
@@ -329,7 +331,7 @@ public:
     *
     * \retval C2_OK        the work was successfully queued
     * \retval C2_BAD_INDEX some component(s) in the work do(es) not exist
     * \retval C2_UNSUPPORTED  the components are not tunneled
     * \retval C2_CANNOT_DO the components are not tunneled
     *
     * \retval C2_NO_MEMORY not enough memory to queue the work
     * \retval C2_CORRUPTED some unknown error prevented queuing the work (unexpected)
@@ -346,7 +348,7 @@ public:
     *
     * \retval C2_OK        the work announcement has been successfully recorded
     * \retval C2_BAD_INDEX some component(s) in the work outline do(es) not exist
     * \retval C2_UNSUPPORTED  the componentes are not tunneled
     * \retval C2_CANNOT_DO the componentes are not tunneled
     *
     * \retval C2_NO_MEMORY not enough memory to record the work announcement
     * \retval C2_CORRUPTED some unknown error prevented recording the announcement (unexpected)
+4 −4
Original line number Diff line number Diff line
@@ -2408,7 +2408,7 @@ public:
            std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
        (void)params;
        (void)failures;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    virtual C2Status config_nb(
@@ -2416,12 +2416,12 @@ public:
            std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
        (void)params;
        (void)failures;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    virtual C2Status createTunnel_sm(node_id targetComponent) {
        (void)targetComponent;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    virtual C2Status query_nb(
@@ -2468,7 +2468,7 @@ public:

    virtual C2Status releaseTunnel_sm(node_id targetComponent) {
        (void)targetComponent;
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }

    class MyParamReflector : public C2ParamReflector {
+3 −3
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static C2Status maperr2error(Error maperr) {
        case Error::BAD_BUFFER:     return C2_BAD_VALUE;
        case Error::BAD_VALUE:      return C2_BAD_VALUE;
        case Error::NO_RESOURCES:   return C2_NO_MEMORY;
        case Error::UNSUPPORTED:    return C2_UNSUPPORTED;
        case Error::UNSUPPORTED:    return C2_CANNOT_DO;
    }
    return C2_CORRUPTED;
}
@@ -195,7 +195,7 @@ C2Status C2AllocationGralloc::map(
            return err;
        }
        // TODO
        return C2_UNSUPPORTED;
        return C2_OMITTED;
    }
    mLocked = true;

@@ -314,7 +314,7 @@ C2Status C2AllocatorGralloc::Impl::recreateGraphicBuffer(

    // TODO: need to figure out BufferDescriptorInfo from the handle.
    allocation->reset();
    return C2_UNSUPPORTED;
    return C2_OMITTED;
}

C2AllocatorGralloc::C2AllocatorGralloc() : mImpl(new Impl) {}
Loading