summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-05-13 10:18:14 -0700
committerEric Laurent <elaurent@google.com>2014-05-13 13:09:17 -0700
commit021cf9634ab09c0753a40b7c9ef4ba603be5c3da (patch)
tree03fb2a864179983e482cae4dac6a502a6dcef136 /services/audioflinger/AudioFlinger.h
parentaa0315f9fdcf99e84a969a4f81192150ddaef260 (diff)
downloadframeworks_av-021cf9634ab09c0753a40b7c9ef4ba603be5c3da.zip
frameworks_av-021cf9634ab09c0753a40b7c9ef4ba603be5c3da.tar.gz
frameworks_av-021cf9634ab09c0753a40b7c9ef4ba603be5c3da.tar.bz2
AudioFlinger: add specific mutex for client lists
Add a specific mutex to protect access to mClients and mNotificationClients lists. This avoids locking the main AudioFlinger mutex from inside thread loops and allows not to worry about cross deadlocks when sending a config event with status reply while keeping the ThreadBase or AudioFlinger mutex locked. As a way of consequence, remove notification client list passed to processConfigEvents_l() and audioConfigChanged() as the list can now be accessed by locking client mutex only. Change-Id: I228022204b6709a8bb60cc96d9514a6ffe59b62e
Diffstat (limited to 'services/audioflinger/AudioFlinger.h')
-rw-r--r--services/audioflinger/AudioFlinger.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 894bd35..c1d4c08 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -453,11 +453,7 @@ private:
// no range check, doesn't check per-thread stream volume, AudioFlinger::mLock held
float streamVolume_l(audio_stream_type_t stream) const
{ return mStreamTypes[stream].volume; }
- void audioConfigChanged_l(const DefaultKeyedVector< pid_t,sp<NotificationClient> >&
- notificationClients,
- int event,
- audio_io_handle_t ioHandle,
- const void *param2);
+ void audioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2);
// Allocate an audio_io_handle_t, session ID, effect ID, or audio_module_handle_t.
// They all share the same ID space, but the namespaces are actually independent
@@ -482,8 +478,6 @@ private:
void removeClient_l(pid_t pid);
void removeNotificationClient(pid_t pid);
- DefaultKeyedVector< pid_t,sp<NotificationClient> > notificationClients() {
- Mutex::Autolock _l(mLock); return mNotificationClients; }
bool isNonOffloadableGlobalEffectEnabled_l();
void onNonOffloadableGlobalEffectEnable();
@@ -553,7 +547,11 @@ private:
};
mutable Mutex mLock;
-
+ // protects mClients and mNotificationClients.
+ // must be locked after mLock and ThreadBase::mLock if both must be locked
+ // avoids acquiring AudioFlinger::mLock from inside thread loop.
+ mutable Mutex mClientLock;
+ // protected by mClientLock
DefaultKeyedVector< pid_t, wp<Client> > mClients; // see ~Client()
mutable Mutex mHardwareLock;
@@ -602,6 +600,7 @@ private:
DefaultKeyedVector< audio_io_handle_t, sp<RecordThread> > mRecordThreads;
+ // protected by mClientLock
DefaultKeyedVector< pid_t, sp<NotificationClient> > mNotificationClients;
volatile int32_t mNextUniqueId; // updated by android_atomic_inc
@@ -622,7 +621,7 @@ private:
// to be created
private:
- sp<Client> registerPid_l(pid_t pid); // always returns non-0
+ sp<Client> registerPid(pid_t pid); // always returns non-0
// for use from destructor
status_t closeOutput_nonvirtual(audio_io_handle_t output);