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

Commit fd4e20c2 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Run audio at priorities 2 and 3 above kernel 1

Also run the watchdog at same priority as the fast mixer.
requestPriority() originally used only the caller's pid to decide which
cgroup to assign, but in the future it might look at the priority also.
So it's safer to use same priority as the fast mixer to be sure we
run in the same cgroup.

Bug: 6461925
Change-Id: Ia59c93e4b22dacbb6746bfa6ad491be7b72f2b8d
parent d96c5724
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -161,6 +161,10 @@ static const enum {
static uint32_t gScreenState; // incremented by 2 when screen state changes, bit 0 == 1 means "off"
                              // AudioFlinger::setParameters() updates, other threads read w/o lock

// Priorities for requestPriority
static const int kPriorityAudioApp = 2;
static const int kPriorityFastMixer = 3;

// ----------------------------------------------------------------------------

#ifdef ADD_BATTERY_DATA
@@ -1795,10 +1799,10 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
        pid_t callingPid = IPCThreadState::self()->getCallingPid();
        // we don't have CAP_SYS_NICE, nor do we want to have it as it's too powerful,
        // so ask activity manager to do this on our behalf
        int err = requestPriority(callingPid, tid, 1);
        int err = requestPriority(callingPid, tid, kPriorityAudioApp);
        if (err != 0) {
            ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
                    1, callingPid, tid, err);
                    kPriorityAudioApp, callingPid, tid, err);
        }
    }

@@ -2281,10 +2285,10 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
        // start the fast mixer
        mFastMixer->run("FastMixer", PRIORITY_URGENT_AUDIO);
        pid_t tid = mFastMixer->getTid();
        int err = requestPriority(getpid_cached, tid, 2);
        int err = requestPriority(getpid_cached, tid, kPriorityFastMixer);
        if (err != 0) {
            ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
                    2, getpid_cached, tid, err);
                    kPriorityFastMixer, getpid_cached, tid, err);
        }

#ifdef AUDIO_WATCHDOG
@@ -2293,10 +2297,10 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
        mAudioWatchdog->setDump(&mAudioWatchdogDump);
        mAudioWatchdog->run("AudioWatchdog", PRIORITY_URGENT_AUDIO);
        tid = mAudioWatchdog->getTid();
        err = requestPriority(getpid_cached, tid, 1);
        err = requestPriority(getpid_cached, tid, kPriorityFastMixer);
        if (err != 0) {
            ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
                    1, getpid_cached, tid, err);
                    kPriorityFastMixer, getpid_cached, tid, err);
        }
#endif