summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/NuCachedSource2.cpp
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2014-09-23 22:22:30 -0700
committerChong Zhang <chz@google.com>2014-09-24 05:44:37 +0000
commit9f3d1cffe3bbec35c1fb7fc7e206428728ac234e (patch)
tree76b6ef229b1f9af5608dd273b09769288a902573 /media/libstagefright/NuCachedSource2.cpp
parentfc55783d0886d5dbaa234f85a4313796d9ef1df4 (diff)
downloadframeworks_av-9f3d1cffe3bbec35c1fb7fc7e206428728ac234e.zip
frameworks_av-9f3d1cffe3bbec35c1fb7fc7e206428728ac234e.tar.gz
frameworks_av-9f3d1cffe3bbec35c1fb7fc7e206428728ac234e.tar.bz2
NuCachedSource2: more fixes for source read hang
- Do not try to read from HTTP source if already disconnecting - Let NuCachedSource2::readAt() return immediately when disconnecting Bug: 17613805 Change-Id: Ibca4d3a4288ae9a9e2f5658a4240ace54efeb220
Diffstat (limited to 'media/libstagefright/NuCachedSource2.cpp')
-rw-r--r--media/libstagefright/NuCachedSource2.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index be2a873..f469d4d 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -254,6 +254,10 @@ void NuCachedSource2::disconnect() {
// set mDisconnecting to true, if a fetch returns after
// this, the source will be marked as EOS.
mDisconnecting = true;
+
+ // explicitly signal mCondition so that the pending readAt()
+ // will immediately return
+ mCondition.signal();
}
// explicitly disconnect from the source, to allow any
@@ -325,7 +329,11 @@ void NuCachedSource2::fetchInternal() {
Mutex::Autolock autoLock(mLock);
- if (err == ERROR_UNSUPPORTED || err == -EPIPE) {
+ if (mDisconnecting) {
+ mNumRetriesLeft = 0;
+ mFinalStatus = ERROR_END_OF_STREAM;
+ return;
+ } else 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;
@@ -515,10 +523,14 @@ ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
CHECK(mAsyncResult == NULL);
msg->post();
- while (mAsyncResult == NULL) {
+ while (mAsyncResult == NULL && !mDisconnecting) {
mCondition.wait(mLock);
}
+ if (mDisconnecting) {
+ return ERROR_END_OF_STREAM;
+ }
+
int32_t result;
CHECK(mAsyncResult->findInt32("result", &result));