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

Commit 2521a019 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Pull out duplicated copies of silent mode check

Also fix the error handling for the property_get.

This is part of preparation for the threadLoop() merge.

Change-Id: I6405190ea18146d1271575e1dfe9f279e8f36b17
parent 56694cec
Loading
Loading
Loading
Loading
+20 −25
Original line number Diff line number Diff line
@@ -1973,6 +1973,23 @@ void CpuStats::sample() {
#endif
};

void AudioFlinger::PlaybackThread::checkSilentMode_l()
{
    if (!mMasterMute) {
        char value[PROPERTY_VALUE_MAX];
        if (property_get("ro.audio.silent", value, "0") > 0) {
            char *endptr;
            unsigned long ul = strtoul(value, &endptr, 0);
            if (*endptr == '\0' && ul != 0) {
                ALOGD("Silence is golden");
                // The setprop command will not allow a property to be changed after
                // the first time it is set, so we don't have to worry about un-muting.
                setMasterMute_l(true);
            }
        }
    }
}

bool AudioFlinger::MixerThread::threadLoop()
{
    Vector< sp<Track> > tracksToRemove;
@@ -2042,14 +2059,7 @@ bool AudioFlinger::MixerThread::threadLoop()
                    acquireWakeLock_l();

                    mPrevMixerStatus = MIXER_IDLE;
                    if (!mMasterMute) {
                        char value[PROPERTY_VALUE_MAX];
                        property_get("ro.audio.silent", value, "0");
                        if (atoi(value)) {
                            ALOGD("Silence is golden");
                            setMasterMute_l(true);
                        }
                    }
                    checkSilentMode_l();

                    standbyTime = systemTime() + mStandbyTimeInNsecs;
                    sleepTime = idleSleepTime;
@@ -2751,14 +2761,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
                    ALOGV("DirectOutputThread %p TID %d waking up in active mode", this, gettid());
                    acquireWakeLock_l();

                    if (!mMasterMute) {
                        char value[PROPERTY_VALUE_MAX];
                        property_get("ro.audio.silent", value, "0");
                        if (atoi(value)) {
                            ALOGD("Silence is golden");
                            setMasterMute_l(true);
                        }
                    }
                    checkSilentMode_l();

                    standbyTime = systemTime() + standbyDelay;
                    sleepTime = idleSleepTime;
@@ -3147,15 +3150,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
                    ALOGV("DuplicatingThread %p TID %d waking up", this, gettid());
                    acquireWakeLock_l();

                    mPrevMixerStatus = MIXER_IDLE;
                    if (!mMasterMute) {
                        char value[PROPERTY_VALUE_MAX];
                        property_get("ro.audio.silent", value, "0");
                        if (atoi(value)) {
                            ALOGD("Silence is golden");
                            setMasterMute_l(true);
                        }
                    }
                    checkSilentMode_l();

                    standbyTime = systemTime() + mStandbyTimeInNsecs;
                    sleepTime = idleSleepTime;
+3 −0
Original line number Diff line number Diff line
@@ -859,6 +859,9 @@ private:
        virtual uint32_t        idleSleepTimeUs() = 0;
        virtual uint32_t        suspendSleepTimeUs() = 0;

        // Code snippets that are temporarily lifted up out of threadLoop() until the merge
                    void        checkSilentMode_l();

    private:

        friend class AudioFlinger;