diff options
author | Andreas Huber <andih@google.com> | 2010-06-22 10:11:15 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-06-22 10:11:15 -0700 |
commit | 40f388ef8bad7a9ab16db8f90904656cd39c793d (patch) | |
tree | 62cdb417938f60d151bf48339e8108a54894aaf0 /media | |
parent | 5603f749d5903898b5018cf907f194830bf4ff2b (diff) | |
parent | a5273ebd1746368662a597643d6701a5046d5c7b (diff) | |
download | frameworks_av-40f388ef8bad7a9ab16db8f90904656cd39c793d.zip frameworks_av-40f388ef8bad7a9ab16db8f90904656cd39c793d.tar.gz frameworks_av-40f388ef8bad7a9ab16db8f90904656cd39c793d.tar.bz2 |
Merge "Make the prefetcher read packets from the network after a keep-alive timeout expires regardless of whether its currently actively fetching data or not." into gingerbread
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/NuCachedSource2.cpp | 18 | ||||
-rw-r--r-- | media/libstagefright/include/NuCachedSource2.h | 11 |
2 files changed, 23 insertions, 6 deletions
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index f29e7fb..c02b7f3 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -178,7 +178,8 @@ NuCachedSource2::NuCachedSource2(const sp<DataSource> &source) mCacheOffset(0), mFinalStatus(OK), mLastAccessPos(0), - mFetching(true) { + mFetching(true), + mLastFetchTimeUs(-1) { mLooper->registerHandler(mReflector); mLooper->start(); @@ -259,10 +260,21 @@ void NuCachedSource2::onFetch() { mFetching = false; } - if (mFetching) { + bool keepAlive = + !mFetching + && mFinalStatus == OK + && ALooper::GetNowUs() >= mLastFetchTimeUs + kKeepAliveIntervalUs; + + if (mFetching || keepAlive) { + if (keepAlive) { + LOG(INFO) << "Keep alive"; + } + fetchInternal(); - if (mCache->totalSize() >= kHighWaterThreshold) { + mLastFetchTimeUs = ALooper::GetNowUs(); + + if (mFetching && mCache->totalSize() >= kHighWaterThreshold) { LOG(INFO) << "Cache full, done prefetching for now"; mFetching = false; } diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index c30f029..f73e837 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -49,9 +49,13 @@ private: friend struct AHandlerReflector<NuCachedSource2>; enum { - kPageSize = 16384, - kHighWaterThreshold = 3 * 1024 * 1024, - kLowWaterThreshold = 512 * 1024, + kPageSize = 16384, + kHighWaterThreshold = 3 * 1024 * 1024, + kLowWaterThreshold = 512 * 1024, + + // Read data after a 15 sec timeout whether we're actively + // fetching or not. + kKeepAliveIntervalUs = 15000000, }; enum { @@ -73,6 +77,7 @@ private: off_t mLastAccessPos; sp<AMessage> mAsyncResult; bool mFetching; + int64_t mLastFetchTimeUs; void onMessageReceived(const sp<AMessage> &msg); void onFetch(); |