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

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 2910553002: fully cache small audio/video (Closed)
Patch Set: comment added Created 3 years, 7 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 | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer_data_source.cc
diff --git a/media/blink/multibuffer_data_source.cc b/media/blink/multibuffer_data_source.cc
index 4d8d045ab05e4ea40eb368ff577c37ab6daeba0a..c0e7c1dd9a2ed7d8b606a5eee483318cb95c55ba 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -505,6 +505,8 @@ void MultibufferDataSource::StartCallback() {
render_task_runner_->PostTask(
FROM_HERE, base::Bind(base::ResetAndReturn(&init_cb_), success));
+ UpdateBufferSizes();
+
// Even if data is cached, say that we're loading at this point for
// compatibility.
UpdateLoadingState_Locked(true);
@@ -610,6 +612,17 @@ void MultibufferDataSource::UpdateBufferSizes() {
std::min((kTargetSecondsBufferedAhead + kTargetSecondsBufferedBehind) *
bytes_per_second,
preload_high + pin_backward);
+
+ if (url_data_->FullyCached() ||
+ (url_data_->length() != kPositionNotSpecified &&
+ url_data_->length() < kDefaultPinSize)) {
+ // We just make pin_forwards/backwards big enough to encompass the
+ // whole file regardless of where we are, with some extra margins.
+ pin_forward = std::max(pin_forward, url_data_->length() * 2);
+ pin_backward = std::max(pin_backward, url_data_->length() * 2);
+ buffer_size = url_data_->length();
+ }
+
reader_->SetMaxBuffer(buffer_size);
reader_->SetPinRange(pin_backward, pin_forward);
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698