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

Commit 4995000d authored by Shunkai Yao's avatar Shunkai Yao
Browse files

AudioFlinger: remove global effect enablement timeout

`kMinGlobalEffectEnabletimeNs` prevents offload track creation
whenever there was non-offloadable global effect enabled in last
20 mins.

After timer removed:
 - offload tracks can be created as long as there is no
   non-offloadable global effect enabled
 - offload tracks will be invalidated when a non-offloadable
   global effect enables

Flag: EXEMPT bug fix
Bug: 374010474
Bug: 372746934
Test: atest AudioTrackOffloadTest AudioEffectTest --iterations 10
Test: atest CtsMediaAudioTestCases
Test: Offload playback with visualizer on/off on Pixel
Change-Id: I2fb7fe98df4dc63972511efe814841668d6645d3
parent 65881cf0
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -110,10 +110,6 @@ constexpr auto kNoEffectsFactory = "Effects Factory is absent\n"sv;

static constexpr char kAudioServiceName[] = "audio";

// In order to avoid invalidating offloaded tracks each time a Visualizer is turned on and off
// we define a minimum time during which a global effect is considered enabled.
static const nsecs_t kMinGlobalEffectEnabletimeNs = seconds(7200);

// Keep a strong reference to media.log service around forever.
// The service is within our parent process so it can never die in a way that we could observe.
// These two variables are const after initialization.
@@ -5019,11 +5015,6 @@ Exit:

bool AudioFlinger::isNonOffloadableGlobalEffectEnabled_l() const
{
    if (mGlobalEffectEnableTime != 0 &&
            ((systemTime() - mGlobalEffectEnableTime) < kMinGlobalEffectEnabletimeNs)) {
        return true;
    }

    for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
        const auto thread = mPlaybackThreads.valueAt(i);
        audio_utils::lock_guard l(thread->mutex());
@@ -5039,8 +5030,6 @@ void AudioFlinger::onNonOffloadableGlobalEffectEnable()
{
    audio_utils::lock_guard _l(mutex());

    mGlobalEffectEnableTime = systemTime();

    for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
        const sp<IAfPlaybackThread> t = mPlaybackThreads.valueAt(i);
        if (t->type() == IAfThreadBase::OFFLOAD) {
+0 −3
Original line number Diff line number Diff line
@@ -775,9 +775,6 @@ private:
    std::atomic<size_t> mClientSharedHeapSize = kMinimumClientSharedHeapSizeBytes;
    static constexpr size_t kMinimumClientSharedHeapSizeBytes = 1024 * 1024; // 1MB

    // when a global effect was last enabled
    nsecs_t mGlobalEffectEnableTime GUARDED_BY(mutex()) = 0;

    /* const */ sp<IAfPatchPanel> mPatchPanel;

    const sp<EffectsFactoryHalInterface> mEffectsFactoryHal =