Skip to content

Commit 96e35f2

Browse files
committed
Don't hold onto the lock while reconnecting to the server
to avoid stalling the readers. Change-Id: I73b646587c8a654a73ff7d800c0f17bd78001855
1 parent 421648e commit 96e35f2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

media/libstagefright/NuCachedSource2.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,33 @@ void NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) {
279279
void NuCachedSource2::fetchInternal() {
280280
LOGV("fetchInternal");
281281

282+
bool reconnect = false;
283+
282284
{
283285
Mutex::Autolock autoLock(mLock);
284286
CHECK(mFinalStatus == OK || mNumRetriesLeft > 0);
285287

286288
if (mFinalStatus != OK) {
287289
--mNumRetriesLeft;
288290

289-
status_t err =
290-
mSource->reconnectAtOffset(mCacheOffset + mCache->totalSize());
291+
reconnect = true;
292+
}
293+
}
291294

292-
if (err == ERROR_UNSUPPORTED) {
293-
mNumRetriesLeft = 0;
294-
return;
295-
} else if (err != OK) {
296-
LOGI("The attempt to reconnect failed, %d retries remaining",
297-
mNumRetriesLeft);
295+
if (reconnect) {
296+
status_t err =
297+
mSource->reconnectAtOffset(mCacheOffset + mCache->totalSize());
298298

299-
return;
300-
}
299+
Mutex::Autolock autoLock(mLock);
300+
301+
if (err == ERROR_UNSUPPORTED) {
302+
mNumRetriesLeft = 0;
303+
return;
304+
} else if (err != OK) {
305+
LOGI("The attempt to reconnect failed, %d retries remaining",
306+
mNumRetriesLeft);
307+
308+
return;
301309
}
302310
}
303311

0 commit comments

Comments
 (0)