OSDN Git Service

NuCachedSource2: fix disconnect process
authorRobert Shih <robertshih@google.com>
Tue, 30 Sep 2014 21:17:38 +0000 (14:17 -0700)
committerRobert Shih <robertshih@google.com>
Wed, 1 Oct 2014 00:25:27 +0000 (17:25 -0700)
 - clear mAsyncResult
 - return early from reads if mDisconnecting is set

Bug: 17696761
Change-Id: I98bfc3f5f06594915bd58faf71fbcded482664d2

media/libstagefright/NuCachedSource2.cpp

index f469d4d..bd0a41d 100644 (file)
@@ -456,6 +456,10 @@ void NuCachedSource2::onRead(const sp<AMessage> &msg) {
     }
 
     Mutex::Autolock autoLock(mLock);
+    if (mDisconnecting) {
+        mCondition.signal();
+        return;
+    }
 
     CHECK(mAsyncResult == NULL);
 
@@ -502,6 +506,9 @@ ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
     ALOGV("readAt offset %lld, size %zu", offset, size);
 
     Mutex::Autolock autoLock(mLock);
+    if (mDisconnecting) {
+        return ERROR_END_OF_STREAM;
+    }
 
     // If the request can be completely satisfied from the cache, do so.
 
@@ -528,6 +535,7 @@ ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
     }
 
     if (mDisconnecting) {
+        mAsyncResult.clear();
         return ERROR_END_OF_STREAM;
     }