diff options
author | Andreas Huber <andih@google.com> | 2011-04-19 10:04:08 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-04-19 10:10:06 -0700 |
commit | 7bf8413f91fc072452f315a91618aeef2574d420 (patch) | |
tree | bfca52f8d270e6e37c90af65b8eddce1f888c4e5 /media/libstagefright | |
parent | b158c54511bfb32999525bca9e19f1b438c0bef5 (diff) | |
download | frameworks_av-7bf8413f91fc072452f315a91618aeef2574d420.zip frameworks_av-7bf8413f91fc072452f315a91618aeef2574d420.tar.gz frameworks_av-7bf8413f91fc072452f315a91618aeef2574d420.tar.bz2 |
Make sure a read restarts the prefetcher if necessary.
Change-Id: I87cac0e61e4dce7987ddf29c32f51e1672d1bbed
related-to-bug: 4286618
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/NuCachedSource2.cpp | 24 | ||||
-rw-r--r-- | media/libstagefright/include/NuCachedSource2.h | 4 |
2 files changed, 21 insertions, 7 deletions
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index c1aa46e..dc86885 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -323,25 +323,28 @@ void NuCachedSource2::onRead(const sp<AMessage> &msg) { } void NuCachedSource2::restartPrefetcherIfNecessary_l( - bool ignoreLowWaterThreshold) { + bool ignoreLowWaterThreshold, bool force) { static const size_t kGrayArea = 1024 * 1024; if (mFetching || mFinalStatus != OK) { return; } - if (!ignoreLowWaterThreshold + if (!ignoreLowWaterThreshold && !force && mCacheOffset + mCache->totalSize() - mLastAccessPos >= kLowWaterThreshold) { return; } size_t maxBytes = mLastAccessPos - mCacheOffset; - if (maxBytes < kGrayArea) { - return; - } - maxBytes -= kGrayArea; + if (!force) { + if (maxBytes < kGrayArea) { + return; + } + + maxBytes -= kGrayArea; + } size_t actualBytes = mCache->releaseFromStart(maxBytes); mCacheOffset += actualBytes; @@ -413,10 +416,19 @@ size_t NuCachedSource2::approxDataRemaining_l(status_t *finalStatus) { } ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) { + CHECK_LE(size, (size_t)kHighWaterThreshold); + LOGV("readInternal offset %lld size %d", offset, size); Mutex::Autolock autoLock(mLock); + if (!mFetching) { + mLastAccessPos = offset; + restartPrefetcherIfNecessary_l( + false, // ignoreLowWaterThreshold + true); // force + } + if (offset < mCacheOffset || offset >= (off64_t)(mCacheOffset + mCache->totalSize())) { static const off64_t kPadding = 256 * 1024; diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index 2128682..ed3e265 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -96,7 +96,9 @@ private: status_t seekInternal_l(off64_t offset); size_t approxDataRemaining_l(status_t *finalStatus); - void restartPrefetcherIfNecessary_l(bool ignoreLowWaterThreshold = false); + + void restartPrefetcherIfNecessary_l( + bool ignoreLowWaterThreshold = false, bool force = false); DISALLOW_EVIL_CONSTRUCTORS(NuCachedSource2); }; |