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

Unified Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 1491813002: Clamp currentTime to buffered ranges for MSE GC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sbs-gc-fix
Patch Set: Add a clarifying comment Created 5 years 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: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp
diff --git a/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp b/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp
index 74465757dcef8d8363b23e01936e77b90286d736..c38af942142f22e7568350d7d13ff0aae1a1430b 100644
--- a/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp
+++ b/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp
@@ -584,6 +584,21 @@ bool SourceBuffer::evictCodedFrames(size_t newDataSize)
ASSERT(m_source);
ASSERT(m_source->mediaElement());
double currentTime = m_source->mediaElement()->currentTime();
+
+ // Strictly speaking currentTime should always be in the buffered ranges,
+ // but media::Pipeline uses audio stream as the main time source. When audio
wolenetz 2015/12/02 23:11:00 nit: (when there is an audio stream)
+ // and video streams have different buffered ranges, then the currentTime
+ // value might be slightly outside of the video stream buffered range. In
+ // those cases we need to clamp currentTime value to the current stream
+ // buffered ranges, to ensure the MSE garbage collection algorithm works
+ // correctly (see crbug.com/563292 for details).
+ Member<TimeRanges> bufferedRanges(buffered(ASSERT_NO_EXCEPTION));
+ if (!bufferedRanges->contain(currentTime)) {
+ double nearest = bufferedRanges->nearest(currentTime, currentTime);
wolenetz 2015/12/02 23:11:00 Two strongly related comments: 1) This fix-up is s
+ WTF_LOG(Media, "SourceBuffer::evictCodedFrames %p currentTime %f outside of buffered ranges, adjusting currentTime to %f", this, currentTime, nearest);
+ currentTime = nearest;
+ }
+
return m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize);
}
« 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