From 4b5dce8bb57179809c558b8b090d8001a89b8d05 Mon Sep 17 00:00:00 2001 From: Pawin Vongmasa Date: Fri, 22 Mar 2019 07:45:36 -0700 Subject: [PATCH] Use safe_union in FieldSupportedValues Test: make cts -j123 && cts-tradefed run cts-dev -m \ CtsMediaTestCases --compatibility:module-arg \ CtsMediaTestCases:include-annotation:\ android.platform.test.annotations.RequiresDevice Bug: 129084824 Change-Id: I9ae77a6a6697dcc508415090640a21841caba345 --- current.txt | 2 +- media/c2/1.0/Android.bp | 1 + media/c2/1.0/types.hal | 134 +++++++++++++++++----------------------- 3 files changed, 59 insertions(+), 78 deletions(-) diff --git a/current.txt b/current.txt index 99100f16cb..b818922d65 100644 --- a/current.txt +++ b/current.txt @@ -502,7 +502,7 @@ d36f747f9c9a8f2f21db2f8323c2d755dd08b34ce813932d7339979f7d490dab android.hardwar 21aa259585caaa27b6470ebcd8509aabde0ef5d039160aa6425d589cb787488b android.hardware.media.c2@1.0::IInputSink b9422a9aca84df1ff9623dc12c0562abce97716e28d63a965f2bfb88f9ad9607 android.hardware.media.c2@1.0::IInputSurface 0a786a19e6753f9774a7ca7781c2a2edfe5c0b5fa112355dfa0e50ebedeb08b9 android.hardware.media.c2@1.0::IInputSurfaceConnection -4cb139f729c29d8d6f4ecdab149c4feb571dad8a06e56cd57fcb52e70208bab4 android.hardware.media.c2@1.0::types +7d3c292ca75ec3e22a8fd4ae72d2edb0659d280257e763786e766f3429954dd1 android.hardware.media.c2@1.0::types 4880af120fc1640225abdc2c60bda6d79617d73484d5124913c7278af3b11e2d android.hardware.neuralnetworks@1.2::IBurstCallback 19877e466ad8c6ed42b38050b77bd010cf7800ff365fdc8574f45bbfda03a758 android.hardware.neuralnetworks@1.2::IBurstContext 96249c852dabeefa3a9496ecdfc44681a071c665bfbf88527bf775c88bf1ab1b android.hardware.neuralnetworks@1.2::IDevice diff --git a/media/c2/1.0/Android.bp b/media/c2/1.0/Android.bp index 7307a81e00..895e9dbbf8 100644 --- a/media/c2/1.0/Android.bp +++ b/media/c2/1.0/Android.bp @@ -27,6 +27,7 @@ hidl_interface { "android.hardware.media.omx@1.0", "android.hardware.media@1.0", "android.hidl.base@1.0", + "android.hidl.safe_union@1.0", ], gen_java: false, } diff --git a/media/c2/1.0/types.hal b/media/c2/1.0/types.hal index ec422b1f40..f4f6f2f402 100644 --- a/media/c2/1.0/types.hal +++ b/media/c2/1.0/types.hal @@ -17,6 +17,7 @@ package android.hardware.media.c2@1.0; import android.hardware.media.bufferpool@2.0::BufferStatusMessage; +import android.hidl.safe_union@1.0::Monostate; /** * Common return values for Codec2 operations. @@ -190,89 +191,68 @@ struct ParamDescriptor { */ typedef uint64_t PrimitiveValue; +/** + * Description of a set of values. + * + * If the `step` member is 0, and `num` and `denom` are both 1, the `Range` + * structure represents a closed interval bounded by `min` and `max`. + * + * Otherwise, the #ValueRange structure represents a finite sequence of numbers + * produced from the following recurrence relation: + * + * @code + * v[0] = min + * v[i] = v[i - 1] * num / denom + step ; i >= 1 + * @endcode + * + * Both the ratio `num / denom` and the value `step` must be positive. The + * last number in the sequence described by this #Range structure is the + * largest number in the sequence that is smaller than or equal to `max`. + * + * @note + * The division in the formula may truncate the result if the data type of + * these values is an integral type. + */ +struct ValueRange { + /** + * Lower end of the range (inclusive). + */ + PrimitiveValue min; + /** + * Upper end of the range (inclusive). + */ + PrimitiveValue max; + /** + * The non-homogeneous term in the recurrence relation. + */ + PrimitiveValue step; + /** + * The numerator of the scale coefficient in the recurrence relation. + */ + PrimitiveValue num; + /** + * The denominator of the scale coefficient in the recurrence relation. + */ + PrimitiveValue denom; +}; + /* * Description of supported values for a field. * * This can be a continuous range or a discrete set of values. + * + * The intended type of values must be made clear in the context where + * `FieldSupportedValues` is used. */ -struct FieldSupportedValues { - /** - * Used if #type is `RANGE`. - * - * If the `step` member is 0, and `num` and `denom` are both 1, the `Range` - * structure represents a closed interval bounded by `min` and `max`. - * - * Otherwise, the #Range structure represents a finite sequence of numbers - * produced from the following recurrence relation: - * - * @code - * v[0] = min - * v[i] = v[i - 1] * num / denom + step ; i >= 1 - * @endcode - * - * Both the ratio `num / denom` and the value `step` must be positive. The - * last number in the sequence described by this #Range structure is the - * largest number in the sequence that is smaller than or equal to `max`. - * - * @note - * The division in the formula may truncate the result if the data type of - * these values is an integral type. - */ - struct Range { - /** - * Lower end of the range (inclusive). - */ - PrimitiveValue min; - /** - * Upper end of the range (inclusive). - */ - PrimitiveValue max; - /** - * The non-homogeneous term in the recurrence relation. - */ - PrimitiveValue step; - /** - * The numerator of the scale coefficient in the recurrence relation. - */ - PrimitiveValue num; - /** - * The denominator of the scale coefficient in the recurrence relation. - */ - PrimitiveValue denom; - }; - - enum Type : int32_t { - /** No supported values */ - EMPTY = 0, - /** Numeric range, described in a #Range structure */ - RANGE, - /** List of values */ - VALUES, - /** List of flags that can be OR-ed */ - FLAGS, - }; - /** - * Type of the supported values. - */ - Type type; - - /** - * When #type is #Type.RANGE, #range shall specify the range of possible - * values. - * - * The intended type of members of #range shall be clear in the context - * where `FieldSupportedValues` is used. - */ - Range range; - - /** - * When #type is #Type.VALUES or #Type.FLAGS, #value shall list supported - * values/flags. - * - * The intended type of components of #value shall be clear in the context - * where `FieldSupportedValues` is used. - */ +safe_union FieldSupportedValues { + /** No supported values */ + Monostate empty; + /** Numeric range, described in a #ValueRange structure */ + ValueRange range; + /** List of values */ vec values; + /** List of flags that can be OR-ed */ + vec flags; }; /**