diff options
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/NuCachedSource2.cpp | 34 | ||||
-rw-r--r-- | media/libstagefright/include/NuCachedSource2.h | 3 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ASessionDescription.cpp | 5 |
3 files changed, 34 insertions, 8 deletions
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index c1feff8..be2a873 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -191,6 +191,7 @@ NuCachedSource2::NuCachedSource2( mFinalStatus(OK), mLastAccessPos(0), mFetching(true), + mDisconnecting(false), mLastFetchTimeUs(-1), mNumRetriesLeft(kMaxNumRetries), mHighwaterThresholdBytes(kDefaultHighWaterThreshold), @@ -244,6 +245,23 @@ status_t NuCachedSource2::getEstimatedBandwidthKbps(int32_t *kbps) { return ERROR_UNSUPPORTED; } +void NuCachedSource2::disconnect() { + if (mSource->flags() & kIsHTTPBasedSource) { + ALOGV("disconnecting HTTPBasedSource"); + + { + Mutex::Autolock autoLock(mLock); + // set mDisconnecting to true, if a fetch returns after + // this, the source will be marked as EOS. + mDisconnecting = true; + } + + // explicitly disconnect from the source, to allow any + // pending reads to return more promptly + static_cast<HTTPBase *>(mSource.get())->disconnect(); + } +} + status_t NuCachedSource2::setCacheStatCollectFreq(int32_t freqMs) { if (mSource->flags() & kIsHTTPBasedSource) { HTTPBase *source = static_cast<HTTPBase *>(mSource.get()); @@ -327,7 +345,14 @@ void NuCachedSource2::fetchInternal() { Mutex::Autolock autoLock(mLock); - if (n < 0) { + if (n == 0 || mDisconnecting) { + ALOGI("ERROR_END_OF_STREAM"); + + mNumRetriesLeft = 0; + mFinalStatus = ERROR_END_OF_STREAM; + + mCache->releasePage(page); + } else if (n < 0) { mFinalStatus = n; if (n == ERROR_UNSUPPORTED || n == -EPIPE) { // These are errors that are not likely to go away even if we @@ -337,13 +362,6 @@ void NuCachedSource2::fetchInternal() { ALOGE("source returned error %zd, %d retries left", n, mNumRetriesLeft); mCache->releasePage(page); - } else if (n == 0) { - ALOGI("ERROR_END_OF_STREAM"); - - mNumRetriesLeft = 0; - mFinalStatus = ERROR_END_OF_STREAM; - - mCache->releasePage(page); } else { if (mFinalStatus != OK) { ALOGI("retrying a previously failed read succeeded."); diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index 5db4b4b..4252706 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -37,6 +37,8 @@ struct NuCachedSource2 : public DataSource { virtual ssize_t readAt(off64_t offset, void *data, size_t size); + virtual void disconnect(); + virtual status_t getSize(off64_t *size); virtual uint32_t flags(); @@ -103,6 +105,7 @@ private: off64_t mLastAccessPos; sp<AMessage> mAsyncResult; bool mFetching; + bool mDisconnecting; int64_t mLastFetchTimeUs; int32_t mNumRetriesLeft; diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp index a9b3330..98498e9 100644 --- a/media/libstagefright/rtsp/ASessionDescription.cpp +++ b/media/libstagefright/rtsp/ASessionDescription.cpp @@ -319,6 +319,11 @@ bool ASessionDescription::parseNTPRange( s = end + 1; // skip the dash. + if (*s == '\0') { + *npt2 = FLT_MAX; // open ended. + return true; + } + if (!strncmp("now", s, 3)) { return false; // no absolute end time available } |