Update selected range after truncation

   
Update |SourceBufferStream::selected_range_| after |TruncateAt| is called in case the range pointed to by it gets deleted.

There are situations where next_buffer_index_ remains at -1 
where|ChunkDemuxer::AppendData| is invoked. This eventually
causes crash. This changes prevents such cases.

The crash is occasionally observed when YouTube MSE/EME
conformance test http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/tot.html
(41.MediaSourceDuration) is done on Android TV device.

BUG=313102

Review URL: https://codereview.chromium.org/51983002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233468 0039d316-1c4b-4281-b951-d872f2087c98
parent a1221aea
...@@ -1054,6 +1054,8 @@ void SourceBufferStream::OnSetDuration(base::TimeDelta duration) { ...@@ -1054,6 +1054,8 @@ void SourceBufferStream::OnSetDuration(base::TimeDelta duration) {
// Need to partially truncate this range. // Need to partially truncate this range.
if ((*itr)->GetStartTimestamp() < duration) { if ((*itr)->GetStartTimestamp() < duration) {
(*itr)->TruncateAt(duration, NULL, false); (*itr)->TruncateAt(duration, NULL, false);
if ((*itr == selected_range_) && !selected_range_->HasNextBufferPosition())
SetSelectedRange(NULL);
++itr; ++itr;
} }
......
...@@ -2864,6 +2864,31 @@ TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeletePartialSelectedRange) { ...@@ -2864,6 +2864,31 @@ TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeletePartialSelectedRange) {
CheckExpectedRanges("{ [0,4) [10,10) }"); CheckExpectedRanges("{ [0,4) [10,10) }");
} }
// Test the case where duration is set while the stream parser buffers
// already start passing the data to decoding pipeline. Selected range,
// when invalidated by getting truncated, should be updated to NULL
// accordingly so that successive append operations keep working.
TEST_F(SourceBufferStreamTest, SetExplicitDuration_UpdateSelectedRange) {
// Seek to start of stream.
SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
NewSegmentAppend("0K 30 60 90");
// Read out the first few buffers.
CheckExpectedBuffers("0K 30");
// Set duration to be right before buffer 1.
stream_->OnSetDuration(base::TimeDelta::FromMilliseconds(60));
// Verify that there is no next buffer.
CheckNoNextBuffer();
// We should be able to append new buffers at this point.
NewSegmentAppend("120K 150");
CheckExpectedRangesByTimestamp("{ [0,60) [120,180) }");
}
// Test the case were the current playback position is at the end of the // Test the case were the current playback position is at the end of the
// buffered data and several overlaps occur that causes the selected // buffered data and several overlaps occur that causes the selected
// range to get split and then merged back into a single range. // range to get split and then merged back into a single range.
......
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