}
void AwesomePlayer::onPrepareAsyncEvent() {
+ sp<Prefetcher> prefetcher;
+
{
Mutex::Autolock autoLock(mLock);
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;
}
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);
}
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;
}