Skip to content

Commit 2521a01

Browse files
committed
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
1 parent 56694ce commit 2521a01

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,23 @@ void CpuStats::sample() {
19731973
#endif
19741974
};
19751975

1976+
void AudioFlinger::PlaybackThread::checkSilentMode_l()
1977+
{
1978+
if (!mMasterMute) {
1979+
char value[PROPERTY_VALUE_MAX];
1980+
if (property_get("ro.audio.silent", value, "0") > 0) {
1981+
char *endptr;
1982+
unsigned long ul = strtoul(value, &endptr, 0);
1983+
if (*endptr == '\0' && ul != 0) {
1984+
ALOGD("Silence is golden");
1985+
// The setprop command will not allow a property to be changed after
1986+
// the first time it is set, so we don't have to worry about un-muting.
1987+
setMasterMute_l(true);
1988+
}
1989+
}
1990+
}
1991+
}
1992+
19761993
bool AudioFlinger::MixerThread::threadLoop()
19771994
{
19781995
Vector< sp<Track> > tracksToRemove;
@@ -2042,14 +2059,7 @@ bool AudioFlinger::MixerThread::threadLoop()
20422059
acquireWakeLock_l();
20432060

20442061
mPrevMixerStatus = MIXER_IDLE;
2045-
if (!mMasterMute) {
2046-
char value[PROPERTY_VALUE_MAX];
2047-
property_get("ro.audio.silent", value, "0");
2048-
if (atoi(value)) {
2049-
ALOGD("Silence is golden");
2050-
setMasterMute_l(true);
2051-
}
2052-
}
2062+
checkSilentMode_l();
20532063

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

2754-
if (!mMasterMute) {
2755-
char value[PROPERTY_VALUE_MAX];
2756-
property_get("ro.audio.silent", value, "0");
2757-
if (atoi(value)) {
2758-
ALOGD("Silence is golden");
2759-
setMasterMute_l(true);
2760-
}
2761-
}
2764+
checkSilentMode_l();
27622765

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

3150-
mPrevMixerStatus = MIXER_IDLE;
3151-
if (!mMasterMute) {
3152-
char value[PROPERTY_VALUE_MAX];
3153-
property_get("ro.audio.silent", value, "0");
3154-
if (atoi(value)) {
3155-
ALOGD("Silence is golden");
3156-
setMasterMute_l(true);
3157-
}
3158-
}
3153+
checkSilentMode_l();
31593154

31603155
standbyTime = systemTime() + mStandbyTimeInNsecs;
31613156
sleepTime = idleSleepTime;

services/audioflinger/AudioFlinger.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,9 @@ class AudioFlinger :
859859
virtual uint32_t idleSleepTimeUs() = 0;
860860
virtual uint32_t suspendSleepTimeUs() = 0;
861861

862+
// Code snippets that are temporarily lifted up out of threadLoop() until the merge
863+
void checkSilentMode_l();
864+
862865
private:
863866

864867
friend class AudioFlinger;

0 commit comments

Comments
 (0)