Loading media/libstagefright/AwesomePlayer.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,13 @@ void AwesomePlayer::abortPrepare(status_t err) { mPreparedCondition.broadcast(); } // static bool AwesomePlayer::ContinuePreparation(void *cookie) { AwesomePlayer *me = static_cast<AwesomePlayer *>(cookie); return (me->mFlags & PREPARE_CANCELLED) == 0; } void AwesomePlayer::onPrepareAsyncEvent() { sp<Prefetcher> prefetcher; Loading Loading @@ -1161,10 +1168,22 @@ void AwesomePlayer::onPrepareAsyncEvent() { } LOGI("calling prefetcher->prepare()"); prefetcher->prepare(); LOGV("prefetcher is done preparing"); status_t result = prefetcher->prepare(&AwesomePlayer::ContinuePreparation, this); prefetcher.clear(); if (result == OK) { LOGV("prefetcher is done preparing"); } else { Mutex::Autolock autoLock(mLock); CHECK_EQ(result, -EINTR); LOGI("prefetcher->prepare() was cancelled early."); abortPrepare(UNKNOWN_ERROR); return; } } Mutex::Autolock autoLock(mLock); Loading media/libstagefright/Prefetcher.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -220,12 +220,19 @@ int64_t Prefetcher::getCachedDurationUs(bool *noMoreData) { return minCacheDurationUs < 0 ? 0 : minCacheDurationUs; } status_t Prefetcher::prepare() { status_t Prefetcher::prepare( bool (*continueFunc)(void *cookie), void *cookie) { // Fill the cache. int64_t duration; bool noMoreData; do { usleep(100000); if (continueFunc && !(*continueFunc)(cookie)) { return -EINTR; } duration = getCachedDurationUs(&noMoreData); } while (!noMoreData && duration < 2000000ll); Loading media/libstagefright/include/AwesomePlayer.h +2 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,8 @@ private: status_t finishSetDataSource_l(); static bool ContinuePreparation(void *cookie); AwesomePlayer(const AwesomePlayer &); AwesomePlayer &operator=(const AwesomePlayer &); }; Loading media/libstagefright/include/Prefetcher.h +6 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,12 @@ struct Prefetcher : public RefBase { int64_t getCachedDurationUs(bool *noMoreData = NULL); status_t prepare(); // If provided (non-NULL), "continueFunc" will be called repeatedly // while preparing and preparation will finish early if it returns // false. In this case "-EINTR" is returned as a result. status_t prepare( bool (*continueFunc)(void *cookie) = NULL, void *cookie = NULL); protected: virtual ~Prefetcher(); Loading Loading
media/libstagefright/AwesomePlayer.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,13 @@ void AwesomePlayer::abortPrepare(status_t err) { mPreparedCondition.broadcast(); } // static bool AwesomePlayer::ContinuePreparation(void *cookie) { AwesomePlayer *me = static_cast<AwesomePlayer *>(cookie); return (me->mFlags & PREPARE_CANCELLED) == 0; } void AwesomePlayer::onPrepareAsyncEvent() { sp<Prefetcher> prefetcher; Loading Loading @@ -1161,10 +1168,22 @@ void AwesomePlayer::onPrepareAsyncEvent() { } LOGI("calling prefetcher->prepare()"); prefetcher->prepare(); LOGV("prefetcher is done preparing"); status_t result = prefetcher->prepare(&AwesomePlayer::ContinuePreparation, this); prefetcher.clear(); if (result == OK) { LOGV("prefetcher is done preparing"); } else { Mutex::Autolock autoLock(mLock); CHECK_EQ(result, -EINTR); LOGI("prefetcher->prepare() was cancelled early."); abortPrepare(UNKNOWN_ERROR); return; } } Mutex::Autolock autoLock(mLock); Loading
media/libstagefright/Prefetcher.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -220,12 +220,19 @@ int64_t Prefetcher::getCachedDurationUs(bool *noMoreData) { return minCacheDurationUs < 0 ? 0 : minCacheDurationUs; } status_t Prefetcher::prepare() { status_t Prefetcher::prepare( bool (*continueFunc)(void *cookie), void *cookie) { // Fill the cache. int64_t duration; bool noMoreData; do { usleep(100000); if (continueFunc && !(*continueFunc)(cookie)) { return -EINTR; } duration = getCachedDurationUs(&noMoreData); } while (!noMoreData && duration < 2000000ll); Loading
media/libstagefright/include/AwesomePlayer.h +2 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,8 @@ private: status_t finishSetDataSource_l(); static bool ContinuePreparation(void *cookie); AwesomePlayer(const AwesomePlayer &); AwesomePlayer &operator=(const AwesomePlayer &); }; Loading
media/libstagefright/include/Prefetcher.h +6 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,12 @@ struct Prefetcher : public RefBase { int64_t getCachedDurationUs(bool *noMoreData = NULL); status_t prepare(); // If provided (non-NULL), "continueFunc" will be called repeatedly // while preparing and preparation will finish early if it returns // false. In this case "-EINTR" is returned as a result. status_t prepare( bool (*continueFunc)(void *cookie) = NULL, void *cookie = NULL); protected: virtual ~Prefetcher(); Loading