summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/NuCachedSource2.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-10-17 15:49:01 -0700
committerAndreas Huber <andih@google.com>2011-10-17 15:49:01 -0700
commit95c4d6034dc356f70c6293ea53d4858415b2d020 (patch)
treec56b9ee32d2cdcd06c1fcc9803c0eb6ebee5a2a6 /media/libstagefright/NuCachedSource2.cpp
parent49c59815369616b0fd5451ccabd377e8fe1dc3fa (diff)
downloadframeworks_av-95c4d6034dc356f70c6293ea53d4858415b2d020.zip
frameworks_av-95c4d6034dc356f70c6293ea53d4858415b2d020.tar.gz
frameworks_av-95c4d6034dc356f70c6293ea53d4858415b2d020.tar.bz2
Don't hold onto the lock while reconnecting to the server
to avoid stalling the readers. Change-Id: I73b646587c8a654a73ff7d800c0f17bd78001855
Diffstat (limited to 'media/libstagefright/NuCachedSource2.cpp')
-rw-r--r--media/libstagefright/NuCachedSource2.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 4f183f5..1e1de04 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -279,6 +279,8 @@ void NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) {
void NuCachedSource2::fetchInternal() {
LOGV("fetchInternal");
+ bool reconnect = false;
+
{
Mutex::Autolock autoLock(mLock);
CHECK(mFinalStatus == OK || mNumRetriesLeft > 0);
@@ -286,18 +288,24 @@ void NuCachedSource2::fetchInternal() {
if (mFinalStatus != OK) {
--mNumRetriesLeft;
- status_t err =
- mSource->reconnectAtOffset(mCacheOffset + mCache->totalSize());
+ reconnect = true;
+ }
+ }
- if (err == ERROR_UNSUPPORTED) {
- mNumRetriesLeft = 0;
- return;
- } else if (err != OK) {
- LOGI("The attempt to reconnect failed, %d retries remaining",
- mNumRetriesLeft);
+ if (reconnect) {
+ status_t err =
+ mSource->reconnectAtOffset(mCacheOffset + mCache->totalSize());
- return;
- }
+ Mutex::Autolock autoLock(mLock);
+
+ if (err == ERROR_UNSUPPORTED) {
+ mNumRetriesLeft = 0;
+ return;
+ } else if (err != OK) {
+ LOGI("The attempt to reconnect failed, %d retries remaining",
+ mNumRetriesLeft);
+
+ return;
}
}