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

Commit 40524ece authored by Wonsik Kim's avatar Wonsik Kim
Browse files

ApexCodecs: ApexCodec_Configurable_config semantics change

|written| is renamed to |writtenOrRequested| and will contain the
requested size of the buffer in case the given |config| had
insufficient size. |config->size| does not change as a result.

In addition, add _Nullable/_Nonnull annotations.

Bug: 297922713 
Bug: 380300185
Test: presubmit
Flag: EXEMPT NDK (APEX native)
Change-Id: I08144239bebe63467148c0e53130cf9dc044b2cc
parent 46aff260
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ ApexCodec_Status ApexCodec_Configurable_query(
        uint32_t indices[],
        size_t numIndices,
        ApexCodec_LinearBuffer *config,
        size_t *written) {
        size_t *writtenOrRequired) {
    return APEXCODEC_STATUS_OMITTED;
}

+66 −63
Original line number Diff line number Diff line
@@ -131,11 +131,11 @@ typedef struct ApexCodec_ComponentTraits {
    /**
     * The name of the component.
     */
    const char *name;
    const char *_Nonnull name;
    /**
     * The supported media type of the component.
     */
    const char *mediaType;
    const char *_Nonnull mediaType;
    /**
     * The kind of the component.
     */
@@ -158,7 +158,7 @@ typedef struct ApexCodec_ComponentStore ApexCodec_ComponentStore;
 *
 * \return component store object.
 */
ApexCodec_ComponentStore *ApexCodec_GetComponentStore()
ApexCodec_ComponentStore *_Nullable ApexCodec_GetComponentStore()
        __INTRODUCED_IN(36);

/**
@@ -174,8 +174,8 @@ ApexCodec_ComponentStore *ApexCodec_GetComponentStore()
 * \param index index of the traits object to query
 * \return traits object at the index, or nullptr if the index is out of bounds.
 */
ApexCodec_ComponentTraits *ApexCodec_Traits_get(
        ApexCodec_ComponentStore *store, size_t index) __INTRODUCED_IN(36);
ApexCodec_ComponentTraits *_Nullable ApexCodec_Traits_get(
        ApexCodec_ComponentStore *_Nonnull store, size_t index) __INTRODUCED_IN(36);

/**
 * An opaque struct that represents a codec.
@@ -192,8 +192,9 @@ typedef struct ApexCodec_Component ApexCodec_Component;
 *          APEXCODEC_STATUS_NOT_FOUND  if the name is not found
 */
ApexCodec_Status ApexCodec_Component_create(
        ApexCodec_ComponentStore *store, const char *name, ApexCodec_Component **comp)
        __INTRODUCED_IN(36);
        ApexCodec_ComponentStore *_Nonnull store,
        const char *_Nonnull name,
        ApexCodec_Component *_Nullable *_Nonnull comp) __INTRODUCED_IN(36);

/**
 * Destroy the component by the handle. It is invalid to call component methods on the handle
@@ -201,7 +202,7 @@ ApexCodec_Status ApexCodec_Component_create(
 *
 * \param comp the handle for the component
 */
void ApexCodec_Component_destroy(ApexCodec_Component *comp) __INTRODUCED_IN(36);
void ApexCodec_Component_destroy(ApexCodec_Component *_Nullable comp) __INTRODUCED_IN(36);

/**
 * Start the component. The component is ready to process buffers after this call.
@@ -209,7 +210,7 @@ void ApexCodec_Component_destroy(ApexCodec_Component *comp) __INTRODUCED_IN(36);
 * \param comp the handle for the component
 */
ApexCodec_Status ApexCodec_Component_start(
        ApexCodec_Component *comp) __INTRODUCED_IN(36);
        ApexCodec_Component *_Nonnull comp) __INTRODUCED_IN(36);

/**
 * Flush the component's internal states. This operation preserves the existing configurations.
@@ -217,7 +218,7 @@ ApexCodec_Status ApexCodec_Component_start(
 * \param comp the handle for the component
 */
ApexCodec_Status ApexCodec_Component_flush(
        ApexCodec_Component *comp) __INTRODUCED_IN(36);
        ApexCodec_Component *_Nonnull comp) __INTRODUCED_IN(36);

/**
 * Resets the component to the initial state, right after creation. Note that the configuration
@@ -227,7 +228,7 @@ ApexCodec_Status ApexCodec_Component_flush(
 * \param comp the handle for the component
 */
ApexCodec_Status ApexCodec_Component_reset(
        ApexCodec_Component *comp) __INTRODUCED_IN(36);
        ApexCodec_Component *_Nonnull comp) __INTRODUCED_IN(36);

/**
 * An opaque struct that represents a configurable part of the component.
@@ -243,8 +244,8 @@ typedef struct ApexCodec_Configurable ApexCodec_Configurable;
 * \param comp the handle for the component
 * \return the configurable object handle
 */
ApexCodec_Configurable *ApexCodec_Component_getConfigurable(
        ApexCodec_Component *comp) __INTRODUCED_IN(36);
ApexCodec_Configurable *_Nonnull ApexCodec_Component_getConfigurable(
        ApexCodec_Component *_Nonnull comp) __INTRODUCED_IN(36);

/**
 * Enum that represents the flags for ApexCodec_Buffer.
@@ -285,7 +286,7 @@ typedef struct ApexCodec_LinearBuffer {
    /**
     * A pointer to the start of the buffer. This is not aligned.
     */
    uint8_t *data;
    uint8_t *_Nullable data;
    /**
     * Size of the buffer. The memory region between |data| (inclusive) and
     * |data + size| (exclusive) is assumed to be valid for read/write.
@@ -323,7 +324,7 @@ typedef struct ApexCodec_Buffer {
     */
    union {
        ApexCodec_LinearBuffer linear;
        AHardwareBuffer *graphic;
        AHardwareBuffer *_Nullable graphic;
    } memory;
    /**
     * Config updates associated with the buffer. For input buffers these are sent to the component
@@ -427,19 +428,19 @@ typedef struct ApexCodec_SupportedValues ApexCodec_SupportedValues;
 *                          if type == APEXCODEC_SUPPORTED_VALUES_VALUES/_FLAGS: varies
 */
ApexCodec_Status ApexCodec_SupportedValues_getTypeAndValues(
        ApexCodec_SupportedValues *supportedValues,
        ApexCodec_SupportedValuesType *type,
        ApexCodec_SupportedValuesNumberType *numberType,
        ApexCodec_Value **values,
        uint32_t *numValues) __INTRODUCED_IN(36);
        ApexCodec_SupportedValues *_Nonnull supportedValues,
        ApexCodec_SupportedValuesType *_Nonnull type,
        ApexCodec_SupportedValuesNumberType *_Nonnull numberType,
        ApexCodec_Value *_Nullable *_Nonnull values,
        uint32_t *_Nonnull numValues) __INTRODUCED_IN(36);

/**
 * Release the supported values object.
 * Release the supported values object. No-op if |values| is nullptr.
 *
 * \param values the supported values object
 */
void ApexCodec_SupportedValues_release(
        ApexCodec_SupportedValues *values) __INTRODUCED_IN(36);
        ApexCodec_SupportedValues *_Nullable values) __INTRODUCED_IN(36);

/**
 * Struct that represents the result of ApexCodec_Configurable_config.
@@ -504,7 +505,7 @@ typedef struct ApexCodec_ParamFieldValues {
    /** size of the param field */
    uint32_t size;
    /** currently supported values of the param field */
    ApexCodec_SupportedValues *values;
    ApexCodec_SupportedValues *_Nullable values;
} ApexCodec_ParamFieldValues;

/**
@@ -528,20 +529,20 @@ typedef struct ApexCodec_ParamFieldValues {
 * \return APEXCODEC_STATUS_NOT_FOUND  if index is out of range
 */
ApexCodec_Status ApexCodec_SettingResults_getResultAtIndex(
        ApexCodec_SettingResults *results,
        ApexCodec_SettingResults *_Nonnull results,
        size_t index,
        ApexCodec_SettingResultFailure *failure,
        ApexCodec_ParamFieldValues *field,
        ApexCodec_ParamFieldValues **conflicts,
        size_t *numConflicts) __INTRODUCED_IN(36);
        ApexCodec_SettingResultFailure *_Nonnull failure,
        ApexCodec_ParamFieldValues *_Nonnull field,
        ApexCodec_ParamFieldValues *_Nullable *_Nonnull conflicts,
        size_t *_Nonnull numConflicts) __INTRODUCED_IN(36);

/**
 * Release the setting result object.
 * Release the setting result object. No-op if |results| is nullptr.
 *
 * \param result the setting result object
 */
void ApexCodec_SettingResults_release(
        ApexCodec_SettingResults *results) __INTRODUCED_IN(36);
        ApexCodec_SettingResults *_Nullable results) __INTRODUCED_IN(36);

/**
 * Process one frame from |input|, and produce one frame to |output| if possible.
@@ -570,11 +571,11 @@ void ApexCodec_SettingResults_release(
 * \return APEXCODEC_STATUS_CORRUPTED  if unexpected error has occurred
 */
ApexCodec_Status ApexCodec_Component_process(
        ApexCodec_Component *comp,
        const ApexCodec_Buffer *input,
        ApexCodec_Buffer *output,
        size_t *consumed,
        size_t *produced) __INTRODUCED_IN(36);
        ApexCodec_Component *_Nonnull comp,
        const ApexCodec_Buffer *_Nullable input,
        ApexCodec_Buffer *_Nonnull output,
        size_t *_Nonnull consumed,
        size_t *_Nonnull produced) __INTRODUCED_IN(36);

/**
 * Configure the component with the given config.
@@ -604,9 +605,9 @@ ApexCodec_Status ApexCodec_Component_process(
 * \return APEXCODEC_STATUS_CORRUPTED  if unexpected error has occurred
 */
ApexCodec_Status ApexCodec_Configurable_config(
        ApexCodec_Configurable *comp,
        ApexCodec_LinearBuffer *config,
        ApexCodec_SettingResults **results) __INTRODUCED_IN(36);
        ApexCodec_Configurable *_Nonnull comp,
        ApexCodec_LinearBuffer *_Nonnull config,
        ApexCodec_SettingResults *_Nullable *_Nonnull results) __INTRODUCED_IN(36);

/**
 * Query the component for the given indices.
@@ -617,21 +618,23 @@ ApexCodec_Status ApexCodec_Configurable_config(
 * \param [in] indices      the array of indices to query
 * \param [in] numIndices   the size of the indices array
 * \param [inout] config    the output buffer for the config blob, allocated by the client.
 *                          if the |config->size| was insufficient, it is set to the required size
 *                          and |config->data| remains unchanged.
 * \param [out] written     the number of bytes written to |config|.
 *                          it can be null to query the required size.
 * \param [out] writtenOrRequired       the number of bytes written to |config|.
 *                                      if the |config->size| was insufficient, it is set to the
 *                                      required size.
 *
 * \return APEXCODEC_STATUS_OK          if successful
 * \return APEXCODEC_STATUS_NO_MEMORY   if |config.size| is too small; |config.size| is updated to the
 *                                      requested buffer size.
 * \return APEXCODEC_STATUS_BAD_VALUE   if the parameters are bad. e.g. |indices|, |config|,
 *                                      |config->data| or |written| is nullptr.
 * \return APEXCODEC_STATUS_NO_MEMORY   if |config.size| is too small; |config.size| is updated
 *                                      to the requested buffer size.
 * \return APEXCODEC_STATUS_BAD_VALUE   if the parameters are bad. e.g. |indices| or
 *                                      |written| is nullptr.
 */
ApexCodec_Status ApexCodec_Configurable_query(
        ApexCodec_Configurable *comp,
        uint32_t indices[],
        ApexCodec_Configurable *_Nonnull comp,
        uint32_t indices[_Nonnull],
        size_t numIndices,
        ApexCodec_LinearBuffer *config,
        size_t *written) __INTRODUCED_IN(36);
        ApexCodec_LinearBuffer *_Nullable config,
        size_t *_Nonnull writtenOrRequired) __INTRODUCED_IN(36);

/**
 * Struct that represents a parameter descriptor.
@@ -674,9 +677,9 @@ typedef enum ApexCodec_ParamAttribute : uint32_t {
 *                                  |numIndices| is nullptr.
 */
ApexCodec_Status ApexCodec_ParamDescriptors_getIndices(
        ApexCodec_ParamDescriptors *descriptors,
        uint32_t **indices,
        size_t *numIndices) __INTRODUCED_IN(36);
        ApexCodec_ParamDescriptors *_Nonnull descriptors,
        uint32_t *_Nullable *_Nonnull indices,
        size_t *_Nonnull numIndices) __INTRODUCED_IN(36);

/**
 * Get the descriptor of the param.
@@ -697,12 +700,12 @@ ApexCodec_Status ApexCodec_ParamDescriptors_getIndices(
 * \return APEXCODEC_STATUS_BAD_INDEX   if the index is not included in the param descriptors.
 */
ApexCodec_Status ApexCodec_ParamDescriptors_getDescriptor(
        ApexCodec_ParamDescriptors *descriptors,
        ApexCodec_ParamDescriptors *_Nonnull descriptors,
        uint32_t index,
        ApexCodec_ParamAttribute *attr,
        const char **name,
        uint32_t **dependencies,
        size_t *numDependencies) __INTRODUCED_IN(36);
        ApexCodec_ParamAttribute *_Nonnull attr,
        const char *_Nullable *_Nonnull name,
        uint32_t *_Nullable *_Nonnull dependencies,
        size_t *_Nonnull numDependencies) __INTRODUCED_IN(36);

/**
 * Release the param descriptors object.
@@ -710,7 +713,7 @@ ApexCodec_Status ApexCodec_ParamDescriptors_getDescriptor(
 * \param descriptors the param descriptors object
 */
ApexCodec_Status ApexCodec_ParamDescriptors_release(
        ApexCodec_ParamDescriptors *descriptors) __INTRODUCED_IN(36);
        ApexCodec_ParamDescriptors *_Nullable descriptors) __INTRODUCED_IN(36);

/**
 * Query the component for the supported parameters.
@@ -722,8 +725,8 @@ ApexCodec_Status ApexCodec_ParamDescriptors_release(
 * \return APEXCODEC_STATUS_BAD_VALUE   if parameters are bad. e.g. |descriptors| is nullptr.
 */
ApexCodec_Status ApexCodec_Configurable_querySupportedParams(
        ApexCodec_Configurable *comp,
        ApexCodec_ParamDescriptors **descriptors) __INTRODUCED_IN(36);
        ApexCodec_Configurable *_Nonnull comp,
        ApexCodec_ParamDescriptors *_Nullable *_Nonnull descriptors) __INTRODUCED_IN(36);

/**
 * Struct that represents the query for the supported values of a parameter.
@@ -748,7 +751,7 @@ typedef struct ApexCodec_SupportedValuesQuery {
    ApexCodec_Status status;

    /** supported values. must be released with ApexCodec_SupportedValues_release(). */
    ApexCodec_SupportedValues *values;
    ApexCodec_SupportedValues *_Nullable values;
} ApexCodec_SupportedValuesQuery;

/**
@@ -761,8 +764,8 @@ typedef struct ApexCodec_SupportedValuesQuery {
 *          APEXCODEC_STATUS_CORRUPTED  if unexpected error has occurred
 */
ApexCodec_Status ApexCodec_Configurable_querySupportedValues(
        ApexCodec_Configurable *comp,
        ApexCodec_SupportedValuesQuery *queries,
        ApexCodec_Configurable *_Nonnull comp,
        ApexCodec_SupportedValuesQuery *_Nonnull queries,
        size_t numQueries) __INTRODUCED_IN(36);

__END_DECLS
 No newline at end of file