Codec2: finalize C2 status constants
Bug: 64121714
Test: unittest
Change-Id: Id229f49e1db85751f9e4f28b5a4c0a7d15358e28
diff --git a/media/libstagefright/codec2/include/C2.h b/media/libstagefright/codec2/include/C2.h
index 213d5a0..bd563ff 100644
--- a/media/libstagefright/codec2/include/C2.h
+++ b/media/libstagefright/codec2/include/C2.h
@@ -66,8 +66,8 @@
* 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,50 +98,62 @@
* 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
+ C2_OK = OK, ///< operation completed successfully
// 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_BAD_VALUE = BAD_VALUE, ///< argument has invalid value (user error)
+ C2_BAD_INDEX = BAD_INDEX, ///< argument uses invalid index (user error)
+ C2_CANNOT_DO = FAILED_TRANSACTION, ///< argument/index is valid but not possible
// bad sequencing of events
- C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists
- C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found
- C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state
+ C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists
+ C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found
+ C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state
// bad environment
- C2_NO_MEMORY = NO_MEMORY, ///< not enough memory to complete operation
- C2_NO_PERMISSION = PERMISSION_DENIED, ///< missing permission to complete operation
- C2_TIMED_OUT = TIMED_OUT, ///< operation did not complete within timeout
+ C2_NO_MEMORY = NO_MEMORY, ///< not enough memory 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
- C2_NO_INIT = NO_INIT, ///< status has not been initialized
+ C2_CORRUPTED = UNKNOWN_ERROR, ///< some unexpected error prevented the operation
+ C2_NO_INIT = NO_INIT, ///< status has not been initialized
};
/// @}
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index 2a3e599..cb8c2d2 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -88,7 +88,7 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
C2MemoryUsage usage __unused,
std::shared_ptr<C2GraphicAllocation> *allocation /* nonnull */) {
*allocation = nullptr;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
/**
@@ -1625,16 +1625,16 @@
* \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 @@
* \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 @@
* \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 @@
* \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 @@
C2MemoryUsage usage __unused,
std::shared_ptr<C2GraphicBlock> *block /* nonnull */) {
*block = nullptr;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
protected:
diff --git a/media/libstagefright/codec2/include/C2Component.h b/media/libstagefright/codec2/include/C2Component.h
index 4eea800..2ac9c72 100644
--- a/media/libstagefright/codec2/include/C2Component.h
+++ b/media/libstagefright/codec2/include/C2Component.h
@@ -250,7 +250,8 @@
* \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 @@
* \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 @@
*
* \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 @@
*
* \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)
diff --git a/media/libstagefright/codec2/tests/C2Param_test.cpp b/media/libstagefright/codec2/tests/C2Param_test.cpp
index 0140f5c..97c5f91 100644
--- a/media/libstagefright/codec2/tests/C2Param_test.cpp
+++ b/media/libstagefright/codec2/tests/C2Param_test.cpp
@@ -2408,7 +2408,7 @@
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 @@
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 @@
virtual C2Status releaseTunnel_sm(node_id targetComponent) {
(void)targetComponent;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
class MyParamReflector : public C2ParamReflector {
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
index 537a411..6530cc1 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
@@ -45,7 +45,7 @@
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 @@
return err;
}
// TODO
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
mLocked = true;
@@ -314,7 +314,7 @@
// TODO: need to figure out BufferDescriptorInfo from the handle.
allocation->reset();
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
C2AllocatorGralloc::C2AllocatorGralloc() : mImpl(new Impl) {}
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
index 4d23270..06b4874 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
@@ -282,7 +282,7 @@
C2AllocatorIon::C2AllocatorIon() : mInit(C2_OK), mIonFd(ion_open()) {
if (mIonFd < 0) {
switch (errno) {
- case ENOENT: mInit = C2_UNSUPPORTED; break;
+ case ENOENT: mInit = C2_OMITTED; break;
default: mInit = c2_map_errno<EACCES>(errno); break;
}
}
@@ -302,7 +302,7 @@
allocation->reset();
if (mInit != C2_OK) {
- return C2_UNSUPPORTED;
+ return mInit;
}
// get align, heapMask and flags
@@ -332,7 +332,7 @@
const C2Handle *handle, std::shared_ptr<C2LinearAllocation> *allocation) {
*allocation = nullptr;
if (mInit != C2_OK) {
- return C2_UNSUPPORTED;
+ return mInit;
}
if (!C2HandleIon::isValid(handle)) {
diff --git a/media/libstagefright/codec2/vndk/include/C2ErrnoUtils.h b/media/libstagefright/codec2/vndk/include/C2ErrnoUtils.h
index adeb42e..aea3a6f 100644
--- a/media/libstagefright/codec2/vndk/include/C2ErrnoUtils.h
+++ b/media/libstagefright/codec2/vndk/include/C2ErrnoUtils.h
@@ -26,8 +26,8 @@
template<int N> constexpr C2Status _c2_errno2status_impl();
template<> constexpr C2Status _c2_errno2status_impl<0>() { return C2_OK; }
template<> constexpr C2Status _c2_errno2status_impl<EINVAL>() { return C2_BAD_VALUE; }
-template<> constexpr C2Status _c2_errno2status_impl<EACCES>() { return C2_NO_PERMISSION; }
-template<> constexpr C2Status _c2_errno2status_impl<EPERM>() { return C2_NO_PERMISSION; }
+template<> constexpr C2Status _c2_errno2status_impl<EACCES>() { return C2_REFUSED; }
+template<> constexpr C2Status _c2_errno2status_impl<EPERM>() { return C2_REFUSED; }
template<> constexpr C2Status _c2_errno2status_impl<ENOMEM>() { return C2_NO_MEMORY; }
// map standard errno-s to the equivalent C2Status
diff --git a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
index f94768a..77db255 100644
--- a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
+++ b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
@@ -499,13 +499,13 @@
C2Status C2SoftAvcDecIntf::createTunnel_sm(node_id targetComponent) {
// Tunneling is not supported
(void) targetComponent;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
C2Status C2SoftAvcDecIntf::releaseTunnel_sm(node_id targetComponent) {
// Tunneling is not supported
(void) targetComponent;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
std::shared_ptr<C2ParamReflector> C2SoftAvcDecIntf::getParamReflector() const {
@@ -669,7 +669,7 @@
C2Status C2SoftAvcDec::announce_nb(const std::vector<C2WorkOutline> &items) {
// Tunneling is not supported
(void) items;
- return C2_UNSUPPORTED;
+ return C2_OMITTED;
}
C2Status C2SoftAvcDec::flush_sm(