@@ -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+
19761993bool 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;
0 commit comments