Part of fix for double spins & faster startup
This change alters the way that the media player interacts with the Widevine adaptive streaming buffer logic. It eliminates the reliance on cached buffer duration to determine pause/play states and instead only generates buffering events when the widevine library is not producing data (i.e. when it is buffering). This eliminates unnecessary pause and rebuffer cycles, reducing startup time and the frequency and duration of spinners. Multi-repo commit, depends on related changes in frameworks/av Change-Id: I5b71f954268fbd390eed7f27db98a1bb470d5cfb related-to-bug:6503294 related-to-bug:6463780
This commit is contained in:
@@ -35,6 +35,7 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
|
||||
mIsLiveStream(isLive),
|
||||
mNewSegment(false),
|
||||
mCryptoInitialized(false),
|
||||
mIsStalled(false),
|
||||
mGroup(NULL),
|
||||
mKeyTime(0),
|
||||
mDts(0),
|
||||
@@ -203,6 +204,8 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
mIsStalled = false;
|
||||
|
||||
CHECK(mStarted);
|
||||
|
||||
*buffer = NULL;
|
||||
@@ -333,16 +336,20 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
return ERROR_IO;
|
||||
} else {
|
||||
// Didn't get anything, sleep a bit so we don't hog the CPU then try again
|
||||
if (retryCount > 10)
|
||||
mIsStalled = true;
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define PCR_HZ 90000
|
||||
mKeyTime = (int64_t)mPts * 1000000 / PCR_HZ;
|
||||
|
||||
if (seekNextSync && ((mKeyTime < seekTimeUs) || !syncFrame)) {
|
||||
// drop frames up to next sync if requested
|
||||
mIsStalled = true;
|
||||
usleep(10000);
|
||||
#ifdef REQUIRE_SECURE_BUFFERS
|
||||
mDecryptContext.Initialize(mediaBuf);
|
||||
@@ -351,6 +358,8 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
continue;
|
||||
}
|
||||
|
||||
mIsStalled = false;
|
||||
|
||||
if (offset + bytesRead < mediaBuf->size())
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user