summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/AudioPolicyEffects.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-10-07 09:08:47 -0700
committerEric Laurent <elaurent@google.com>2014-10-07 12:24:30 -0700
commit8b1e80bf1e9f214feea219cfe981ba533b806003 (patch)
tree0d6b46a05d685e02750433f6779eb1ce09d84294 /services/audiopolicy/AudioPolicyEffects.h
parentf0011d49c0f08753dc2dc254c5a70885a9986602 (diff)
downloadframeworks_av-8b1e80bf1e9f214feea219cfe981ba533b806003.zip
frameworks_av-8b1e80bf1e9f214feea219cfe981ba533b806003.tar.gz
frameworks_av-8b1e80bf1e9f214feea219cfe981ba533b806003.tar.bz2
audio policy: fix lockup during mediaserver restart
When pre or post processing effects are applied by audio policy service automatically there is a potential lockup if the first call into AudioPolicyService is made while creating one of those effects. This is because effects are created with AudioPolicyService mutex held and effect creation calls into methods (e.g registerClient()) which also acquire the mutex. The fix consists in adding a new mutex to AudioPolicyEffects class and not hold the AudioPolicyService mutex when calling methods in of class. Bug: 17830596. Change-Id: Ie61c3671d3147f46e99ba208f39c1a3bf180779f
Diffstat (limited to 'services/audiopolicy/AudioPolicyEffects.h')
-rw-r--r--services/audiopolicy/AudioPolicyEffects.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/services/audiopolicy/AudioPolicyEffects.h b/services/audiopolicy/AudioPolicyEffects.h
index dbe0d0e..6b0d538 100644
--- a/services/audiopolicy/AudioPolicyEffects.h
+++ b/services/audiopolicy/AudioPolicyEffects.h
@@ -45,6 +45,10 @@ public:
AudioPolicyEffects();
virtual ~AudioPolicyEffects();
+ // NOTE: methods on AudioPolicyEffects should never be called with the AudioPolicyService
+ // main mutex (mLock) held as they will indirectly call back into AudioPolicyService when
+ // managing audio effects.
+
// Return a list of effect descriptors for default input effects
// associated with audioSession
status_t queryDefaultInputEffects(int audioSession,
@@ -133,6 +137,10 @@ private:
public:
EffectVector(int session) : mSessionId(session), mRefCount(0) {}
/*virtual*/ ~EffectVector() {}
+
+ // Enable or disable all effects in effect vector
+ void setProcessorEnabled(bool enabled);
+
const int mSessionId;
// AudioPolicyManager keeps mLock, no need for lock on reference count here
int mRefCount;
@@ -141,14 +149,11 @@ private:
static const char * const kInputSourceNames[AUDIO_SOURCE_CNT -1];
- audio_source_t inputSourceNameToEnum(const char *name);
+ static audio_source_t inputSourceNameToEnum(const char *name);
static const char *kStreamNames[AUDIO_STREAM_CNT+1]; //+1 required as streams start from -1
audio_stream_type_t streamNameToEnum(const char *name);
- // Enable or disable all effects in effect vector
- void setProcessorEnabled(const EffectVector *effectVector, bool enabled);
-
// Parse audio_effects.conf
status_t loadAudioEffectConfig(const char *path);
@@ -173,6 +178,8 @@ private:
size_t *curSize,
size_t *totSize);
+ // protects access to mInputSources, mInputs, mOutputStreams, mOutputSessions
+ Mutex mLock;
// Automatic input effects are configured per audio_source_t
KeyedVector< audio_source_t, EffectDescVector* > mInputSources;
// Automatic input effects are unique for audio_io_handle_t