am 1024b041: Part of fix for double spins & faster startup

* commit '1024b041e824bb6eb232971fc4a2984d63f7e079':
  Part of fix for double spins & faster startup
This commit is contained in:
Jeff Tinker
2012-06-01 11:25:55 -07:00
committed by Android Git Automerger
3 changed files with 21 additions and 11 deletions

View File

@@ -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)