diff options
author | Andreas Huber <andih@google.com> | 2010-02-08 16:39:24 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-02-08 16:39:24 -0800 |
commit | 2dd73b65542c9eeb82bb567098f235349d18b06f (patch) | |
tree | 6d473e627e5c8f78f7380db7b550d7f3d932f66b /media/libstagefright/Prefetcher.cpp | |
parent | 940ad815a1a30abf0268949e3d3937d7e0d672c0 (diff) | |
parent | c23f12af0394aa2f6651968a3c8840f1af317aa1 (diff) | |
download | frameworks_av-2dd73b65542c9eeb82bb567098f235349d18b06f.zip frameworks_av-2dd73b65542c9eeb82bb567098f235349d18b06f.tar.gz frameworks_av-2dd73b65542c9eeb82bb567098f235349d18b06f.tar.bz2 |
Merge "Properly implement asynchronous preparation of media playback."
Diffstat (limited to 'media/libstagefright/Prefetcher.cpp')
-rw-r--r-- | media/libstagefright/Prefetcher.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/media/libstagefright/Prefetcher.cpp b/media/libstagefright/Prefetcher.cpp index 862998a..835e167 100644 --- a/media/libstagefright/Prefetcher.cpp +++ b/media/libstagefright/Prefetcher.cpp @@ -171,7 +171,7 @@ void Prefetcher::threadFunc() { } } -int64_t Prefetcher::getCachedDurationUs() { +int64_t Prefetcher::getCachedDurationUs(bool *noMoreData) { Mutex::Autolock autoLock(mLock); int64_t minCacheDurationUs = -1; @@ -197,9 +197,25 @@ int64_t Prefetcher::getCachedDurationUs() { } } + if (noMoreData) { + *noMoreData = minCacheDurationUs < 0; + } + return minCacheDurationUs < 0 ? 0 : minCacheDurationUs; } +status_t Prefetcher::prepare() { + // Buffer about 2 secs worth of data on prepare. + + int64_t duration; + bool noMoreData; + do { + duration = getCachedDurationUs(&noMoreData); + } while (!noMoreData && duration < 2000000); + + return OK; +} + //////////////////////////////////////////////////////////////////////////////// PrefetchedSource::PrefetchedSource( @@ -232,15 +248,6 @@ status_t PrefetchedSource::start(MetaData *params) { mStarted = true; - for (;;) { - // Buffer 2 secs on startup. - if (mReachedEOS || mCacheDurationUs > 2000000) { - break; - } - - mCondition.wait(mLock); - } - return OK; } |