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:
@@ -499,19 +499,24 @@ int64_t WVMExtractorImpl::getCachedDurationUs(status_t *finalStatus) {
|
||||
}
|
||||
|
||||
uint64_t durationUs = 0;
|
||||
float secondsBuffered;
|
||||
status = WV_Info_TimeBuffered(mSession, &secondsBuffered);
|
||||
|
||||
if (!mVideoSource->isStalled() && !mAudioSource->isStalled()) {
|
||||
// Data is buffered as long as the pull isn't stalled.
|
||||
// The amount indicated doesn't matter as long as it
|
||||
// is more than the high water mark.
|
||||
durationUs = 10000000LL;
|
||||
}
|
||||
|
||||
if (status == WV_Status_End_Of_Media) {
|
||||
*finalStatus = ERROR_END_OF_STREAM;
|
||||
} else if (status != WV_Status_OK) {
|
||||
*finalStatus = ERROR_IO;
|
||||
} else {
|
||||
durationUs = (uint64_t)(secondsBuffered * 1000000LL);
|
||||
|
||||
if (mIsLiveStream) {
|
||||
*finalStatus = ERROR_END_OF_STREAM;
|
||||
} else {
|
||||
*finalStatus = OK;
|
||||
|
||||
int64_t current_time = 0; // usec.
|
||||
if (mVideoSource != NULL) {
|
||||
current_time = mVideoSource->getTime();
|
||||
@@ -530,13 +535,7 @@ int64_t WVMExtractorImpl::getCachedDurationUs(status_t *finalStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
// Scale the duration to account for Stagefright's conservative buffering.
|
||||
// This provides much more responsive operation and due to the ability to
|
||||
// adapt, we don't need to prebuffer so much data. Based on testing, 2x
|
||||
// is a reasonable compromise between faster startup time and additional
|
||||
// pauses after playback starts.
|
||||
|
||||
return durationUs * 2;
|
||||
return durationUs;
|
||||
}
|
||||
|
||||
void WVMExtractorImpl::setAdaptiveStreamingMode(bool adaptive)
|
||||
|
||||
Reference in New Issue
Block a user