diff options
author | Glenn Kasten <gkasten@google.com> | 2012-11-02 09:59:51 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-11-02 13:24:50 -0700 |
commit | 36665ac2e7edae3e733b7f52145b80dfed9821a6 (patch) | |
tree | 2c1737e1bd76636603fbe1af94426850eb99f164 /media | |
parent | 3d07702e3b95579370aa74d40b56c63685cbb518 (diff) | |
download | frameworks_av-36665ac2e7edae3e733b7f52145b80dfed9821a6.zip frameworks_av-36665ac2e7edae3e733b7f52145b80dfed9821a6.tar.gz frameworks_av-36665ac2e7edae3e733b7f52145b80dfed9821a6.tar.bz2 |
Fix spurious wakeup waiting for new IAudioTrack
If there was a spurious wakeup while waiting for another thread to create
a new IAudioTrack, we assumed that the track has been created when it
might not have been.
Change-Id: I5f3999b4f7a06a00aabd65a746cc7222fff396ab
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 5fc9b07..ffed161 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1407,19 +1407,27 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart) android_atomic_or(CBLK_RESTORED_ON, &cblk->flags); cblk->cv.broadcast(); } else { - if (!(cblk->flags & CBLK_RESTORED_MSK)) { - ALOGW("dead IAudioTrack, waiting for a new one TID %d", gettid()); - mLock.unlock(); - result = cblk->cv.waitRelative(cblk->lock, milliseconds(RESTORE_TIMEOUT_MS)); - if (result == NO_ERROR) { + bool haveLogged = false; + for (;;) { + if (cblk->flags & CBLK_RESTORED_MSK) { + ALOGW("dead IAudioTrack restored"); result = mRestoreStatus; + cblk->lock.unlock(); + break; + } + if (!haveLogged) { + ALOGW("dead IAudioTrack, waiting for a new one"); + haveLogged = true; } + mLock.unlock(); + result = cblk->cv.waitRelative(cblk->lock, milliseconds(RESTORE_TIMEOUT_MS)); cblk->lock.unlock(); mLock.lock(); - } else { - ALOGW("dead IAudioTrack, already restored TID %d", gettid()); - result = mRestoreStatus; - cblk->lock.unlock(); + if (result != NO_ERROR) { + ALOGW("timed out"); + break; + } + cblk->lock.lock(); } } ALOGV("restoreTrack_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x", |