summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrackShared.cpp
diff options
context:
space:
mode:
authorzunkyu.lee <zunkyu.lee@lge.com>2014-11-07 15:47:32 +0900
committerGlenn Kasten <gkasten@google.com>2014-12-08 16:04:24 -0800
commit82a69ea8b090d57bff5e02774688b546a711bbb8 (patch)
treeb4712a7df9c4431103b1d1a4a77ad5b237703637 /media/libmedia/AudioTrackShared.cpp
parentca7b4bc40604ae4f06718cb34945fdab278987ae (diff)
downloadframeworks_av-82a69ea8b090d57bff5e02774688b546a711bbb8.zip
frameworks_av-82a69ea8b090d57bff5e02774688b546a711bbb8.tar.gz
frameworks_av-82a69ea8b090d57bff5e02774688b546a711bbb8.tar.bz2
Prevent ANR when AudioTrack is paused or re-routed
If ClientProxy was interrupted by AudioTrack::pause() just before futex syscall() in obtainBuffer() was called, It will not call releaseBuffer to wake up AudioTrackThread. It puts the AudioTrackThread to sleep and then a deadlock occurs. In this case, CBLK_INTERRUPT flags can't prevent a deadlock, so this patch set mFutex to FUTEX_WAKE during interrupt() to avoid deadlock. A similar problem could occur due to re-route or recovery after mediaserver death. Bug: 18641665 Change-Id: I66fcae43af9a91eb55f6cdb52c644ee6c0999772
Diffstat (limited to 'media/libmedia/AudioTrackShared.cpp')
-rw-r--r--media/libmedia/AudioTrackShared.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp
index 4a783b3..ff24475 100644
--- a/media/libmedia/AudioTrackShared.cpp
+++ b/media/libmedia/AudioTrackShared.cpp
@@ -307,6 +307,7 @@ void ClientProxy::binderDied()
{
audio_track_cblk_t* cblk = mCblk;
if (!(android_atomic_or(CBLK_INVALID, &cblk->mFlags) & CBLK_INVALID)) {
+ android_atomic_or(CBLK_FUTEX_WAKE, &cblk->mFutex);
// it seems that a FUTEX_WAKE_PRIVATE will not wake a FUTEX_WAIT, even within same process
(void) syscall(__NR_futex, &cblk->mFutex, mClientInServer ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE,
1);
@@ -317,6 +318,7 @@ void ClientProxy::interrupt()
{
audio_track_cblk_t* cblk = mCblk;
if (!(android_atomic_or(CBLK_INTERRUPT, &cblk->mFlags) & CBLK_INTERRUPT)) {
+ android_atomic_or(CBLK_FUTEX_WAKE, &cblk->mFutex);
(void) syscall(__NR_futex, &cblk->mFutex, mClientInServer ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE,
1);
}