Commit 95dc1352 authored by Fredrik Hubinette's avatar Fredrik Hubinette Committed by Commit Bot

preload=metadata loads a little instead of none

Change the multibuffer code to preload 1/32th of the normal preload
when "preload=metadata" is used. This should work around problems
that occur because WMPI says we have enough data while the demuxer
may still be filling buffers.

For a lot of videos, this means we'll be preloading 64k.

Bug: 814328
Change-Id: Iae6945d63bf8298975eb51eda22b16189c7658df
Reviewed-on: https://chromium-review.googlesource.com/937997
Commit-Queue: Fredrik Hubinette <hubbe@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539911}
parent 87253340
......@@ -24,6 +24,14 @@ const int64_t kMinBufferPreload = 2 << 20; // 2 Mb
// Maxmimum preload buffer.
const int64_t kMaxBufferPreload = 50 << 20; // 50 Mb
// If preload_ == METADATA, preloading size will be
// shifted down this many bits. This shift turns
// one Mb into one 32k block.
// This seems to be the smallest amount of preload we can do without
// ending up repeatedly closing and re-opening the connection
// due to read calls after OnBufferingHaveEnough have been called.
const int64_t kMetadataShift = 6;
// Preload this much extra, then stop preloading until we fall below the
// kTargetSecondsBufferedAhead.
const int64_t kPreloadHighExtra = 1 << 20; // 1 Mb
......@@ -168,6 +176,7 @@ void MultibufferDataSource::CreateResourceLoader(int64_t first_byte_position,
SetReader(new MultiBufferReader(
url_data_->multibuffer(), first_byte_position, last_byte_position,
base::Bind(&MultibufferDataSource::ProgressCallback, weak_ptr_)));
reader_->SetIsClientAudioElement(is_client_audio_element_);
UpdateBufferSizes();
}
......@@ -191,7 +200,6 @@ void MultibufferDataSource::Initialize(const InitializeCB& init_cb) {
init_cb_ = init_cb;
CreateResourceLoader(0, kPositionNotSpecified);
reader_->SetIsClientAudioElement(is_client_audio_element_);
// We're not allowed to call Wait() if data is already available.
if (reader_->Available()) {
......@@ -752,10 +760,10 @@ void MultibufferDataSource::UpdateBufferSizes() {
reader_->SetPinRange(pin_backward, pin_forward);
if (preload_ == METADATA) {
reader_->SetPreload(0, 0);
} else {
reader_->SetPreload(preload_high, preload);
preload_high >>= kMetadataShift;
preload >>= kMetadataShift;
}
reader_->SetPreload(preload_high, preload);
}
} // namespace media
......@@ -389,8 +389,8 @@ class MultibufferDataSourceTest : public testing::Test {
}
void CheckReadThenDefer() {
EXPECT_EQ(0, preload_low());
EXPECT_EQ(0, preload_high());
EXPECT_EQ(2 << 14, preload_low());
EXPECT_EQ(3 << 14, preload_high());
}
void CheckNeverDefer() {
......@@ -1180,6 +1180,9 @@ TEST_F(MultibufferDataSourceTest, ExternalResource_Response206_VerifyDefer) {
EXPECT_CALL(*this, ReadCallback(kDataSize));
ReadAt(0);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
ReceiveData(kDataSize);
ASSERT_TRUE(active_loader());
EXPECT_TRUE(data_provider()->deferred());
}
......@@ -1204,6 +1207,12 @@ TEST_F(MultibufferDataSourceTest,
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
ReceiveData(kDataSize);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3));
ReceiveData(kDataSize);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 4));
ReceiveData(kDataSize);
EXPECT_FALSE(active_loader_allownull());
}
......@@ -1230,10 +1239,17 @@ TEST_F(MultibufferDataSourceTest,
ReceiveDataLow(2000);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2 + 2000));
EXPECT_CALL(host_, AddBufferedByteRange(kDataSize * 2, kDataSize * 2 + 2000));
ReceiveDataLow(kDataSize);
base::RunLoop().RunUntilIdle();
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3 + 2000));
ReceiveData(kDataSize);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 4 + 2000));
ReceiveData(kDataSize);
EXPECT_FALSE(active_loader_allownull());
}
......
......@@ -142,6 +142,8 @@ crbug.com/680917 http/tests/devtools/audits2/ [ Slow ]
# This test is intentionally SLOW as we're waiting for a connection timeout.
crbug.com/73609 http/tests/media/video-play-stall.html [ Slow ]
# This test is intentionally SLOW because of throttled loading.
crbug.com/73609 http/tests/media/video-preload-metadata.html [ Slow ]
# Many of the virtual animations tests are slow.
crbug.com/311482 virtual/threaded/animations/prefixed/keyframes-unprefixed-03.html [ Slow ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment