From: Bryan Mawhinney Date: Wed, 18 Jan 2012 13:40:07 +0000 (+0000) Subject: Make sure seek triggers a reconnect if needed. X-Git-Tag: android-x86-4.4-r1~1579^2~297^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=40a4e1440869b2e3981f261b0d301cd16c0cf0aa;p=android-x86%2Fframeworks-av.git Make sure seek triggers a reconnect if needed. Previously, if we had disconnected at the high watermark, the read immediately following a seek would fail, and would not be retried, resulting in an error. Change-Id: I45a53563fe17d6b54893815abc7750a7dfb0a124 --- diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index 693c506879..0957426b79 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -370,6 +370,7 @@ void NuCachedSource2::onFetch() { && (mSource->flags() & DataSource::kIsHTTPBasedSource)) { ALOGV("Disconnecting at high watermark"); static_cast(mSource.get())->disconnect(); + mFinalStatus = -EAGAIN; } } } else { @@ -549,7 +550,7 @@ ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) { size_t delta = offset - mCacheOffset; - if (mFinalStatus != OK) { + if (mFinalStatus != OK && mNumRetriesLeft == 0) { if (delta >= mCache->totalSize()) { return mFinalStatus; } @@ -591,7 +592,7 @@ status_t NuCachedSource2::seekInternal_l(off64_t offset) { size_t totalSize = mCache->totalSize(); CHECK_EQ(mCache->releaseFromStart(totalSize), totalSize); - mFinalStatus = OK; + mNumRetriesLeft = kMaxNumRetries; mFetching = true; return OK;