diff options
author | Glenn Kasten <gkasten@google.com> | 2012-02-24 07:21:48 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-02-24 16:02:24 -0800 |
commit | 37d825e72a6c606553a745da1212590a425996d3 (patch) | |
tree | 268310fe31b44c0eee84b1d91adfbbaff2103a76 /services | |
parent | 5ce96d97feafc6989f6141bb2633eae3d87ddf28 (diff) | |
download | frameworks_av-37d825e72a6c606553a745da1212590a425996d3.zip frameworks_av-37d825e72a6c606553a745da1212590a425996d3.tar.gz frameworks_av-37d825e72a6c606553a745da1212590a425996d3.tar.bz2 |
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
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 45 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 3 |
2 files changed, 23 insertions, 25 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 2c3329e..d522091 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -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; diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index a2ab680..2a5d805 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -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; |