diff options
author | Eric Laurent <elaurent@google.com> | 2011-09-13 15:04:17 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2011-09-13 17:33:29 -0700 |
commit | cfe2ba6b01a258e39f9c215ffc7b750e0b68f708 (patch) | |
tree | c4a213cfc30955cc61a8c9673e032caff41a0947 /media | |
parent | 98afd841e8f0803a00d1970e4a28ea8999e9c498 (diff) | |
download | frameworks_av-cfe2ba6b01a258e39f9c215ffc7b750e0b68f708.zip frameworks_av-cfe2ba6b01a258e39f9c215ffc7b750e0b68f708.tar.gz frameworks_av-cfe2ba6b01a258e39f9c215ffc7b750e0b68f708.tar.bz2 |
Issue 5298399: Lost speech after a crash in gTalk.
Fixed problem in AudioTrack::restoreTrack_l() causing a permanent
failure if the IAudioTrack interface to AudioFlinger could not be
restored at the first attempt.
Change-Id: I039d4fe2dca8d3baf71f1a6c51119f27a67b6611
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index c2c6715..8ebb652 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -262,7 +262,7 @@ status_t AudioTrack::set( mFlushed = false; mFlags = flags; AudioSystem::acquireAudioSessionId(mSessionId); - + mRestoreStatus = NO_ERROR; return NO_ERROR; } @@ -1161,8 +1161,8 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart) status_t result; if (!(android_atomic_or(CBLK_RESTORING_ON, &cblk->flags) & CBLK_RESTORING_MSK)) { - LOGW("dead IAudioTrack, creating a new one from %s", - fromStart ? "start()" : "obtainBuffer()"); + LOGW("dead IAudioTrack, creating a new one from %s TID %d", + fromStart ? "start()" : "obtainBuffer()", gettid()); // signal old cblk condition so that other threads waiting for available buffers stop // waiting now @@ -1217,33 +1217,35 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart) } if (mActive) { result = mAudioTrack->start(); + LOGW_IF(result != NO_ERROR, "restoreTrack_l() start() failed status %d", result); } if (fromStart && result == NO_ERROR) { mNewPosition = mCblk->server + mUpdatePeriod; } } if (result != NO_ERROR) { - mActive = false; + android_atomic_and(~CBLK_RESTORING_ON, &cblk->flags); + LOGW_IF(result != NO_ERROR, "restoreTrack_l() failed status %d", result); } - + mRestoreStatus = result; // signal old cblk condition for other threads waiting for restore completion android_atomic_or(CBLK_RESTORED_ON, &cblk->flags); cblk->cv.broadcast(); } else { if (!(cblk->flags & CBLK_RESTORED_MSK)) { - LOGW("dead IAudioTrack, waiting for a new one"); + LOGW("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) { + result = mRestoreStatus; + } cblk->lock.unlock(); mLock.lock(); } else { - LOGW("dead IAudioTrack, already restored"); - result = NO_ERROR; + LOGW("dead IAudioTrack, already restored TID %d", gettid()); + result = mRestoreStatus; cblk->lock.unlock(); } - if (result != NO_ERROR || mActive == 0) { - result = status_t(STOPPED); - } } LOGV("restoreTrack_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x", result, mActive, mCblk, cblk, mCblk->flags, cblk->flags); @@ -1254,7 +1256,7 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart) } cblk->lock.lock(); - LOGW_IF(result != NO_ERROR, "restoreTrack_l() error %d", result); + LOGW_IF(result != NO_ERROR, "restoreTrack_l() error %d TID %d", result, gettid()); return result; } |