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

Commit f370264d authored by Andy Hung's avatar Andy Hung
Browse files

VolumeShaper: Fixes for updated Cts test

1) Limit number of VolumeShapers that can be created.
   a) 16 system VolumeShapers
   b) 16 application/client VolumeShapers
2) Return proper volume before VolumeShaper is started.
3) Consistent xOffset definition used internally:
   a) this is now always the position on the volumeshaper curve
      which can go backwards if in REVERSE.
   b) normalized time is always forward going and is scaled
      to 0.f and 1.f depending on progress relative to
      the curve's duration.
4) Fix replace method.
5) Add comments.

Test: Use updated CTS VolumeShaperTest
Bug: 37536598
Change-Id: I837ab2a481adc0abbd3f1338bfe2cb79831b11fa
parent 549bd02a
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -294,12 +294,21 @@ public:

    std::string toString() const {
        std::stringstream ss;
        ss << "mInterpolatorType: " << static_cast<int32_t>(mInterpolatorType) << std::endl;
        ss << "mFirstSlope: " << mFirstSlope << std::endl;
        ss << "mLastSlope: " << mLastSlope << std::endl;
        ss << "Interpolator{mInterpolatorType=" << static_cast<int32_t>(mInterpolatorType);
        ss << ", mFirstSlope=" << mFirstSlope;
        ss << ", mLastSlope=" << mLastSlope;
        ss << ", {";
        bool first = true;
        for (const auto &pt : *this) {
            ss << pt.first << " " << pt.second << std::endl;
            if (first) {
                first = false;
                ss << "{";
            } else {
                ss << ", {";
            }
            ss << pt.first << ", " << pt.second << "}";
        }
        ss << "}}";
        return ss.str();
    }

@@ -324,7 +333,7 @@ private:

    // spline cubic polynomial coefficient cache
    std::unordered_map<S, std::tuple<S /* c1 */, S /* c2 */, S /* c3 */>> mMemo;
};
}; // Interpolator

} // namespace android

+354 −192

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -2268,7 +2268,7 @@ status_t AudioTrack::restoreTrack_l(const char *from)
            // For now, we simply advance to the end of the VolumeShaper effect
            // if it has been started.
            if (shaper.isStarted()) {
                operationToEnd->setXOffset(1.f);
                operationToEnd->setNormalizedTime(1.f);
            }
            return mAudioTrack->applyVolumeShaper(shaper.mConfiguration, operationToEnd);
        });
+4 −0
Original line number Diff line number Diff line
@@ -874,6 +874,10 @@ public:
     */
            bool hasStarted(); // not const

            bool isPlaying() {
                AutoMutex lock(mLock);
                return mState == STATE_ACTIVE || mState == STATE_STOPPING;
            }
protected:
    /* copying audio tracks is not allowed */
                        AudioTrack(const AudioTrack& other);
+4 −3
Original line number Diff line number Diff line
@@ -2042,7 +2042,7 @@ status_t MediaPlayerService::AudioOutput::open(
        // For now, we simply advance to the end of the VolumeShaper effect
        // if it has been started.
        if (shaper.isStarted()) {
            operationToEnd->setXOffset(1.f);
            operationToEnd->setNormalizedTime(1.f);
        }
        return t->applyVolumeShaper(shaper.mConfiguration, operationToEnd);
    });
@@ -2301,9 +2301,10 @@ VolumeShaper::Status MediaPlayerService::AudioOutput::applyVolumeShaper(
        status = mTrack->applyVolumeShaper(configuration, operation);
        if (status >= 0) {
            (void)mVolumeHandler->applyVolumeShaper(configuration, operation);
            // TODO: start on exact AudioTrack state (STATE_ACTIVE || STATE_STOPPING)
            if (mTrack->isPlaying()) { // match local AudioTrack to properly restore.
                mVolumeHandler->setStarted();
            }
        }
    } else {
        status = mVolumeHandler->applyVolumeShaper(configuration, operation);
    }