Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: media/base/pipeline.cc

Issue 10581050: Ensure media's buffered ranges always have a range that includes currentTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline.cc
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index de7098341337ff4c9807aaec23e8e9120134373b..395e664cfcc70c7a8bea6d583fc4206bfbae6848 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -204,11 +204,21 @@ Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() {
Ranges<TimeDelta> time_ranges;
if (clock_->Duration() == TimeDelta() || total_bytes_ == 0)
return time_ranges;
+ TimeDelta current_time = GetCurrentTime_Locked();
for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) {
TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i));
TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i));
// Cap approximated buffered time at the length of the video.
end = std::min(end, clock_->Duration());
+ // HACK: Extend the last range preceding the current time to include the
+ // current time, to avoid disappearing/reappearing buffered bar.
+ // TODO(fischman): remove this HACK when we have time-based buffered-range
+ // tracking (http://crbug.com/133588).
+ if ((i + 1 == buffered_byte_ranges_.size()) ||
scherkus (not reviewing) 2012/06/21 01:10:38 brackets around (i + 1) for warm fuzzy feeling ple
+ (current_time > start && current_time <
+ TimeForByteOffset_Locked((buffered_byte_ranges_.start(i + 1))))) {
+ end = std::max(end, current_time + TimeDelta::FromSeconds(1));
+ }
time_ranges.Add(start, end);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698