Commit 9044e32c authored by acolwell@chromium.org's avatar acolwell@chromium.org

Fix ChunkDemuxer seek and init callback dispatch.

This patch ensures that seek and init callbacks are always
dispatched from the message loop that initiated the Seek()
or Initialize() operation. This prevents reentrancy problems
and allows the code to jump through less locking hoops.

TESTS=All existing unittests and LayoutTests still pass.

Review URL: https://chromiumcodereview.appspot.com/17261029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207767 0039d316-1c4b-4281-b951-d872f2087c98
parent 970749f3
This diff is collapsed.
......@@ -124,7 +124,7 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
void ReportError_Locked(PipelineStatus error);
// Returns true if any stream has seeked to a time without buffered data.
bool IsSeekPending_Locked() const;
bool IsSeekWaitingForData_Locked() const;
// Returns true if all streams can successfully call EndOfStream,
// false if any can not.
......
......@@ -460,8 +460,10 @@ class ChunkDemuxerTest : public testing::Test {
}
void ShutdownDemuxer() {
if (demuxer_)
if (demuxer_) {
demuxer_->Shutdown();
message_loop_.RunUntilIdle();
}
}
void AddSimpleBlock(ClusterBuilder* cb, int track_num, int64 timecode) {
......@@ -893,6 +895,8 @@ TEST_F(ChunkDemuxerTest, TestAppendDataAfterSeek) {
AppendData(cluster->data(), cluster->size());
message_loop_.RunUntilIdle();
Checkpoint(2);
}
......@@ -1733,11 +1737,15 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamAfterPastEosSeek) {
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromMilliseconds(110),
base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called));
message_loop_.RunUntilIdle();
EXPECT_FALSE(seek_cb_was_called);
EXPECT_CALL(host_, SetDuration(
base::TimeDelta::FromMilliseconds(120)));
demuxer_->EndOfStream(PIPELINE_OK);
message_loop_.RunUntilIdle();
EXPECT_TRUE(seek_cb_was_called);
ShutdownDemuxer();
......@@ -1767,11 +1775,15 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringPendingSeek) {
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromMilliseconds(160),
base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called));
message_loop_.RunUntilIdle();
EXPECT_FALSE(seek_cb_was_called);
EXPECT_CALL(host_, SetDuration(
base::TimeDelta::FromMilliseconds(300)));
demuxer_->EndOfStream(PIPELINE_OK);
message_loop_.RunUntilIdle();
EXPECT_FALSE(seek_cb_was_called);
scoped_ptr<Cluster> cluster_a3(
......@@ -1780,6 +1792,9 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringPendingSeek) {
GenerateSingleStreamCluster(140, 180, kVideoTrackNum, 5));
AppendData(cluster_a3->data(), cluster_a3->size());
AppendData(cluster_v3->data(), cluster_v3->size());
message_loop_.RunUntilIdle();
EXPECT_TRUE(seek_cb_was_called);
ShutdownDemuxer();
......
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