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

Commit 8be3dcd8 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Merge "VolumeShaper: Clean up constructors" into oc-dev am: 94cfe137

am: cc37107c

Change-Id: If1bef0500c65aeea71433c46a15404e616685f70
parents 93d7b51f cc37107c
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public:
            , mId(-1) {
        }

        Configuration(const Configuration &configuration)
        explicit Configuration(const Configuration &configuration)
            : Interpolator<S, T>(*static_cast<const Interpolator<S, T> *>(&configuration))
            , mType(configuration.mType)
            , mOptionFlags(configuration.mOptionFlags)
@@ -236,6 +236,7 @@ public:
            clampVolume();
        }

        // The parcel layout must match VolumeShaper.java
        status_t writeToParcel(Parcel *parcel) const {
            if (parcel == nullptr) return BAD_VALUE;
            return parcel->writeInt32((int32_t)mType)
@@ -300,15 +301,19 @@ public:
            : Operation(FLAG_NONE, -1 /* replaceId */) {
        }

        explicit Operation(Flag flags, int replaceId)
        Operation(Flag flags, int replaceId)
            : Operation(flags, replaceId, std::numeric_limits<S>::quiet_NaN() /* xOffset */) {
        }

        Operation(const Operation &operation)
        explicit Operation(const Operation &operation)
            : Operation(operation.mFlags, operation.mReplaceId, operation.mXOffset) {
        }

        explicit Operation(Flag flags, int replaceId, S xOffset)
        explicit Operation(const sp<Operation> &operation)
            : Operation(*operation.get()) {
        }

        Operation(Flag flags, int replaceId, S xOffset)
            : mFlags(flags)
            , mReplaceId(replaceId)
            , mXOffset(xOffset) {
@@ -375,7 +380,7 @@ public:
    // must match with VolumeShaper.java in frameworks/base
    class State : public RefBase {
    public:
        explicit State(T volume, S xOffset)
        State(T volume, S xOffset)
            : mVolume(volume)
            , mXOffset(xOffset) {
        }
@@ -480,7 +485,7 @@ public:
    // TODO: Since we pass configuration and operation as shared pointers
    // there is a potential risk that the caller may modify these after
    // delivery.  Currently, we don't require copies made here.
    explicit VolumeShaper(
    VolumeShaper(
            const sp<VolumeShaper::Configuration> &configuration,
            const sp<VolumeShaper::Operation> &operation)
        : mConfiguration(configuration) // we do not make a copy
@@ -793,7 +798,7 @@ public:
    void reset() {
        AutoMutex _l(mLock);
        mVolumeShapers.clear();
        mLastFrame = -1;
        mLastFrame = 0;
        // keep mVolumeShaperIdCounter as is.
    }

@@ -835,7 +840,7 @@ private:

    mutable Mutex mLock;
    double mSampleRate; // in samples (frames) per second
    int64_t mLastFrame; // logging purpose only
    int64_t mLastFrame; // logging purpose only, 0 on start
    int32_t mVolumeShaperIdCounter; // a counter to return a unique volume shaper id.
    std::pair<T /* volume */, bool /* active */> mLastVolume;
    std::list<VolumeShaper> mVolumeShapers; // list provides stable iterators on erase