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

Commit 6766df4e authored by Lajos Molnar's avatar Lajos Molnar
Browse files

Codec2: C2ParamDescriptor fixes

type() is now index()
added dependencies
use attributes instead of individual boolean flags

Bug: 64121714
Change-Id: If0b5326e19cf007cece517231cb55147607e3379
parent d18270d1
Loading
Loading
Loading
Loading
+25 −17
Original line number Diff line number Diff line
@@ -1020,7 +1020,7 @@ public:
     * For vendor-defined components, it can be true even for vendor-defined params,
     * but it is not recommended, in case the component becomes platform-defined.
     */
    inline bool isRequired() const { return _mIsRequired; }
    inline bool isRequired() const { return _mAttrib & IS_REQUIRED; }

    /**
     * Returns whether this parameter is persistent. This is always true for C2Tuning and C2Setting,
@@ -1029,35 +1029,43 @@ public:
     * current frame and is not assumed to have the same value (or even be present) on subsequent
     * frames, unless it is specified for those frames.
     */
    inline bool isPersistent() const { return _mIsPersistent; }
    inline bool isPersistent() const { return _mAttrib & IS_PERSISTENT; }

    /// Returns the name of this param.
    /// This defaults to the underlying C2Struct's name, but could be altered for a component.
    inline C2String name() const { return _mName; }

    /// Returns the parameter type
    /// \todo fix this
    inline C2Param::Type type() const { return _mType; }
    /// Returns the parameter index
    inline C2Param::Index index() const { return _mIndex; }

    /// Returns the indices of parameters that this parameter has a dependency on
    inline const std::vector<C2Param::Index> &dependencies() const { return mDependencies; }

    // TODO: add more constructors that allow setting dependencies and attributes

    template<typename T>
    inline C2ParamDescriptor(bool isRequired, C2StringLiteral name, const T*)
        : _mIsRequired(isRequired),
          _mIsPersistent(true),
          _mName(name),
          _mType(T::PARAM_TYPE) { }
        : _mIndex(T::PARAM_TYPE),
          _mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
          _mName(name) { }

    inline C2ParamDescriptor(
            bool isRequired, C2StringLiteral name, C2Param::Type type)
        : _mIsRequired(isRequired),
          _mIsPersistent(true),
          _mName(name),
          _mType(type) { }
            bool isRequired, C2StringLiteral name, C2Param::Index index)
        : _mIndex(index),
          _mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
          _mName(name) { }

private:
    const bool _mIsRequired;
    const bool _mIsPersistent;
    enum attrib_t : uint32_t {
        IS_REQUIRED   = 1u << 0,
        IS_PERSISTENT = 1u << 1,
    };
    const C2Param::Index _mIndex;
    const uint32_t _mAttrib;
    const C2String _mName;
    const C2Param::Type _mType;
    std::vector<C2Param::Index> mDependencies;

    friend struct _C2ParamInspector;
};

/// \ingroup internal
+1 −1
Original line number Diff line number Diff line
@@ -529,7 +529,7 @@ bool isSupportedParam(
        const C2Param &param,
        const std::vector<std::shared_ptr<C2ParamDescriptor>> &sParams) {
    for (const auto &pd : sParams) {
        if (param.type() == pd->type().type()) {
        if (param.type() == pd->index().type()) {
            return true;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -2736,7 +2736,7 @@ void dumpDesc(const C2ParamDescriptor &pd) {
        cout << "persistent ";
    }
    cout << "struct ";
    dumpType(pd.type());
    dumpType(C2Param::Type(pd.index().type()));
    cout << " " << pd.name() << ";" << endl;
}

+1 −1

File changed.

Contains only whitespace changes.