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

Commit d0c0bb40 authored by Pattara Teerapong's avatar Pattara Teerapong Committed by Android (Google) Code Review
Browse files

Merge "PlaybackThread: Request real-time priority on ARC" into main

parents cdee9b80 9a332c5e
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -223,6 +223,8 @@ static const enum {
static const int kPriorityAudioApp = 2;
static const int kPriorityFastMixer = 3;
static const int kPriorityFastCapture = 3;
// Request real-time priority for PlaybackThread in ARC
static const int kPriorityPlaybackThreadArc = 1;

// IAudioFlinger::createTrack() has an in/out parameter 'pFrameCount' for the total size of the
// track buffer in shared memory.  Zero on input means to use a default value.  For fast tracks,
@@ -3954,6 +3956,27 @@ NO_THREAD_SAFETY_ANALYSIS // manual locking of AudioFlinger
                stream()->setHalThreadPriority(priorityBoost);
            }
        }
    } else if (property_get_bool("ro.boot.container", false /* default_value */)) {
        // In ARC experiments (b/73091832), the latency under using CFS scheduler with any priority
        // is not enough for PlaybackThread to process audio data in time. We request the lowest
        // real-time priority, SCHED_FIFO=1, for PlaybackThread in ARC. ro.boot.container is true
        // only on ARC.
        const pid_t tid = getTid();
        if (tid == -1) {
            ALOGW("%s: Cannot update PlaybackThread priority for ARC, no tid", __func__);
        } else {
            const status_t status = requestPriority(getpid(),
                                                    tid,
                                                    kPriorityPlaybackThreadArc,
                                                    false /* isForApp */,
                                                    true /* asynchronous */);
            if (status != OK) {
                ALOGW("%s: Cannot update PlaybackThread priority for ARC, status %d", __func__,
                        status);
            } else {
                stream()->setHalThreadPriority(kPriorityPlaybackThreadArc);
            }
        }
    }

    Vector<sp<IAfTrack>> tracksToRemove;