summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-04-18 15:39:09 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-04-18 15:39:09 -0700
commit5ce9eb9a34ffac3ff5aea0db81a902a380105d5b (patch)
treea8ea179c1f9a949d9a43890db2923578f8648b38
parent68cb0ffad05323dc1df7faeefa8f41586744c293 (diff)
parentf0f1ceeb517ff226532a407da6d55602f195e5b5 (diff)
downloadframeworks_base-5ce9eb9a34ffac3ff5aea0db81a902a380105d5b.zip
frameworks_base-5ce9eb9a34ffac3ff5aea0db81a902a380105d5b.tar.gz
frameworks_base-5ce9eb9a34ffac3ff5aea0db81a902a380105d5b.tar.bz2
am f0f1ceeb: DO NOT MERGE: Make sure we restart the prefetcher immediately when trying to satisfy a read.
* commit 'f0f1ceeb517ff226532a407da6d55602f195e5b5': DO NOT MERGE: Make sure we restart the prefetcher immediately when trying to satisfy a read.
-rw-r--r--media/libstagefright/AwesomePlayer.cpp2
-rw-r--r--media/libstagefright/NuCachedSource2.cpp34
-rw-r--r--media/libstagefright/include/NuCachedSource2.h2
3 files changed, 26 insertions, 12 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 6dc61c7..e7aec35 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1165,7 +1165,7 @@ void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) {
}
if (mAudioPlayer != NULL) {
- LOGV("seeking audio to %lld us (%.2f secs).", timeUs, timeUs / 1E6);
+ LOGV("seeking audio to %lld us (%.2f secs).", videoTimeUs, videoTimeUs / 1E6);
// If we don't have a video time, seek audio to the originally
// requested seek time instead.
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 5b0168b..3a37bf3 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -326,24 +326,31 @@ void NuCachedSource2::onRead(const sp<AMessage> &msg) {
mCondition.signal();
}
-void NuCachedSource2::restartPrefetcherIfNecessary_l() {
+void NuCachedSource2::restartPrefetcherIfNecessary_l(bool force) {
static const size_t kGrayArea = 256 * 1024;
if (mFetching || mFinalStatus != OK) {
return;
}
- if (mCacheOffset + mCache->totalSize() - mLastAccessPos
- >= kLowWaterThreshold) {
- return;
- }
+ size_t maxBytes;
- size_t maxBytes = mLastAccessPos - mCacheOffset;
- if (maxBytes < kGrayArea) {
- return;
- }
+ if (!force) {
+ if (mCacheOffset + mCache->totalSize() - mLastAccessPos
+ >= kLowWaterThreshold) {
+ return;
+ }
+
+ maxBytes = mLastAccessPos - mCacheOffset;
+ if (maxBytes < kGrayArea) {
+ return;
+ }
- maxBytes -= kGrayArea;
+ maxBytes -= kGrayArea;
+ } else {
+ // Empty it all out.
+ maxBytes = mLastAccessPos - mCacheOffset;
+ }
size_t actualBytes = mCache->releaseFromStart(maxBytes);
mCacheOffset += actualBytes;
@@ -415,10 +422,17 @@ size_t NuCachedSource2::approxDataRemaining_l(bool *eos) {
}
ssize_t NuCachedSource2::readInternal(off_t offset, void *data, size_t size) {
+ CHECK(size <= kHighWaterThreshold);
+
LOGV("readInternal offset %ld size %d", offset, size);
Mutex::Autolock autoLock(mLock);
+ if (!mFetching) {
+ mLastAccessPos = offset;
+ restartPrefetcherIfNecessary_l(true /* force */);
+ }
+
if (offset < mCacheOffset
|| offset >= (off_t)(mCacheOffset + mCache->totalSize())) {
static const off_t kPadding = 32768;
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index 1fb2088..a836ad7 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -94,7 +94,7 @@ private:
status_t seekInternal_l(off_t offset);
size_t approxDataRemaining_l(bool *eos);
- void restartPrefetcherIfNecessary_l();
+ void restartPrefetcherIfNecessary_l(bool force = false);
DISALLOW_EVIL_CONSTRUCTORS(NuCachedSource2);
};