summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-11-08 10:04:06 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-11-08 10:04:07 -0800
commit4f3ebe4090a3be3bb7622cc01b2f9af476914798 (patch)
treed563e9b5c676b176832ffb37c5cd0cc2eb00b19a /media/libmedia/AudioTrack.cpp
parentba85098eb31bd2637db49816f0591361211024f2 (diff)
parenta96bd95dcfe886436652debbda77ceb634729da0 (diff)
downloadframeworks_av-4f3ebe4090a3be3bb7622cc01b2f9af476914798.zip
frameworks_av-4f3ebe4090a3be3bb7622cc01b2f9af476914798.tar.gz
frameworks_av-4f3ebe4090a3be3bb7622cc01b2f9af476914798.tar.bz2
Merge "Fix call to restoreTrack_l() without lock held"
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r--media/libmedia/AudioTrack.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f55ec9a..f7921ba 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1121,8 +1121,14 @@ TimedAudioTrack::TimedAudioTrack() {
status_t TimedAudioTrack::allocateTimedBuffer(size_t size, sp<IMemory>* buffer)
{
+ AutoMutex lock(mLock);
status_t result = UNKNOWN_ERROR;
+ // acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
+ // while we are accessing the cblk
+ sp<IAudioTrack> audioTrack = mAudioTrack;
+ sp<IMemory> iMem = mCblkMemory;
+
// If the track is not invalid already, try to allocate a buffer. alloc
// fails indicating that the server is dead, flag the track as invalid so
// we can attempt to restore in just a bit.