summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Huber <andih@google.com> 2010-03-08 12:28:22 -0800
committer Andreas Huber <andih@google.com> 2010-03-08 12:28:22 -0800
commit55864df7b64d14a79fe3a193f3bb0005f64b9452 (patch)
treed593ad5c90b94340951c85aecb31117e3e574d71
parent3c53c69a4e7bf19907f9ee0dbe4029965e2cfa05 (diff)
Increase the amount of data buffered at preparation time. Make sure to start preparing after the codecs have been started, otherwise no buffering will happen.
Change-Id: I2c54db085cc76f4069ab381177e94e1b81005b02 related-to-bug: 2474091
-rw-r--r--media/libstagefright/AwesomePlayer.cpp41
-rw-r--r--media/libstagefright/Prefetcher.cpp4
2 files changed, 21 insertions, 24 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 5090c3939cb0..b8a50bf097ed 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1064,6 +1064,8 @@ void AwesomePlayer::abortPrepare(status_t err) {
}
void AwesomePlayer::onPrepareAsyncEvent() {
+ sp<Prefetcher> prefetcher;
+
{
Mutex::Autolock autoLock(mLock);
@@ -1075,12 +1077,25 @@ void AwesomePlayer::onPrepareAsyncEvent() {
return;
}
}
- }
- sp<Prefetcher> prefetcher;
+ if (mVideoTrack != NULL && mVideoSource == NULL) {
+ status_t err = initVideoDecoder();
+
+ if (err != OK) {
+ abortPrepare(err);
+ return;
+ }
+ }
+
+ if (mAudioTrack != NULL && mAudioSource == NULL) {
+ status_t err = initAudioDecoder();
+
+ if (err != OK) {
+ abortPrepare(err);
+ return;
+ }
+ }
- {
- Mutex::Autolock autoLock(mLock);
prefetcher = mPrefetcher;
}
@@ -1091,24 +1106,6 @@ void AwesomePlayer::onPrepareAsyncEvent() {
Mutex::Autolock autoLock(mLock);
- if (mVideoTrack != NULL && mVideoSource == NULL) {
- status_t err = initVideoDecoder();
-
- if (err != OK) {
- abortPrepare(err);
- return;
- }
- }
-
- if (mAudioTrack != NULL && mAudioSource == NULL) {
- status_t err = initAudioDecoder();
-
- if (err != OK) {
- abortPrepare(err);
- return;
- }
- }
-
if (mIsAsyncPrepare) {
if (mVideoWidth < 0 || mVideoHeight < 0) {
notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0);
diff --git a/media/libstagefright/Prefetcher.cpp b/media/libstagefright/Prefetcher.cpp
index 89cd30e2f15f..493570a20637 100644
--- a/media/libstagefright/Prefetcher.cpp
+++ b/media/libstagefright/Prefetcher.cpp
@@ -220,13 +220,13 @@ int64_t Prefetcher::getCachedDurationUs(bool *noMoreData) {
}
status_t Prefetcher::prepare() {
- // Buffer about 2 secs worth of data on prepare.
+ // Fill the cache.
int64_t duration;
bool noMoreData;
do {
duration = getCachedDurationUs(&noMoreData);
- } while (!noMoreData && duration < 2000000);
+ } while (!noMoreData && duration < kMaxCacheDurationUs);
return OK;
}