diff options
author | Glenn Kasten <gkasten@google.com> | 2012-02-24 14:12:20 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-02-24 14:20:29 -0800 |
commit | 91540aeb6cd0ff2aacf0466160c3dacb30251ce2 (patch) | |
tree | 156ae9ea48ae3cfcf425b0fbafce724f2b99dd37 /services/audioflinger | |
parent | be3835c64dc782c1c40ebf75badd1db47aff7b1a (diff) | |
download | frameworks_base-91540aeb6cd0ff2aacf0466160c3dacb30251ce2.zip frameworks_base-91540aeb6cd0ff2aacf0466160c3dacb30251ce2.tar.gz frameworks_base-91540aeb6cd0ff2aacf0466160c3dacb30251ce2.tar.bz2 |
Fix theoretical race condition in addOutputTrack
This is not a real race, because addOutputTrack was only called in two
places, and in both places there could be no other threads referencing
the DuplicatingThread instance.
Those two places are:
- the DuplicatingThread constructor, which is of course safe
- openDuplicateOutput - this is safe because it's called immediately
after the new DuplicatingThread, and there are no sp<> either in the
constructor or here which could cause onFirstRef() to do Thread::run().
But for safety in case addOutputTrack is ever called somewhere else,
or there are sp<> created earlier, it is safer to take the thread lock.
Change-Id: I1502d014fa37ec5dbf4bf40d3e2884af311cd5e9
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 6256951..93e3963 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -3229,6 +3229,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop() void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread) { + Mutex::Autolock _l(mLock); // FIXME explain this formula int frameCount = (3 * mFrameCount * mSampleRate) / thread->sampleRate(); OutputTrack *outputTrack = new OutputTrack(thread, |