OSDN Git Service

Fix retries when server doesn't support range requests.
authorAndreas Huber <andih@google.com>
Tue, 28 Aug 2012 16:48:40 +0000 (09:48 -0700)
committerAndreas Huber <andih@google.com>
Tue, 28 Aug 2012 17:46:38 +0000 (10:46 -0700)
Change-Id: I2d137f3e799b87af36a279473c0077d860c14477
related-to-bug: 7021436

media/libstagefright/NuCachedSource2.cpp

index f1075b1..05e599b 100644 (file)
@@ -298,7 +298,9 @@ void NuCachedSource2::fetchInternal() {
 
         Mutex::Autolock autoLock(mLock);
 
-        if (err == ERROR_UNSUPPORTED) {
+        if (err == ERROR_UNSUPPORTED || err == -EPIPE) {
+            // These are errors that are not likely to go away even if we
+            // retry, i.e. the server doesn't support range requests or similar.
             mNumRetriesLeft = 0;
             return;
         } else if (err != OK) {
@@ -317,8 +319,14 @@ void NuCachedSource2::fetchInternal() {
     Mutex::Autolock autoLock(mLock);
 
     if (n < 0) {
-        ALOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
         mFinalStatus = n;
+        if (n == ERROR_UNSUPPORTED || n == -EPIPE) {
+            // These are errors that are not likely to go away even if we
+            // retry, i.e. the server doesn't support range requests or similar.
+            mNumRetriesLeft = 0;
+        }
+
+        ALOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
         mCache->releasePage(page);
     } else if (n == 0) {
         ALOGI("ERROR_END_OF_STREAM");