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

Unified Diff: media/base/pipeline_impl_unittest.cc

Issue 2621183002: [TO 56] Fix race in media Pipeline::GetMediaTime() after seeking. (Closed)
Patch Set: Created 3 years, 11 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 | « media/base/pipeline_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl_unittest.cc
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index a654c12040c00bc83af05c0a32887e248b3ca46a..be014d7b9f129622def7ab33dc413b7d561a2ae4 100644
--- a/media/base/pipeline_impl_unittest.cc
+++ b/media/base/pipeline_impl_unittest.cc
@@ -826,6 +826,43 @@ TEST_F(PipelineImplTest, GetMediaTime) {
EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
}
+// Seeking posts a task from main thread to media thread to seek the renderer,
+// resetting its internal clock. Calling GetMediaTime() should be safe even
+// when the renderer has not performed the seek (simulated by its continuing
+// to return the pre-seek time). Verifies fix for http://crbug.com/675556
+TEST_F(PipelineImplTest, GetMediaTimeAfterSeek) {
+ CreateAudioStream();
+ MockDemuxerStreamVector streams;
+ streams.push_back(audio_stream());
+ SetDemuxerExpectations(&streams);
+ SetRendererExpectations();
+ StartPipelineAndExpect(PIPELINE_OK);
+
+ // Pipeline should report the same media time returned by the renderer.
+ base::TimeDelta kMediaTime = base::TimeDelta::FromSeconds(2);
+ EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime));
+ EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
+
+ // Seek backward 1 second. Do not run RunLoop to ensure renderer is not yet
+ // notified of the seek (via media thread).
+ base::TimeDelta kSeekTime = kMediaTime - base::TimeDelta::FromSeconds(1);
+ ExpectSeek(kSeekTime, false);
+ pipeline_->Seek(kSeekTime, base::Bind(&CallbackHelper::OnSeek,
+ base::Unretained(&callbacks_)));
+
+ // Verify pipeline returns the seek time in spite of renderer returning the
+ // stale media time.
+ EXPECT_EQ(kSeekTime, pipeline_->GetMediaTime());
+ EXPECT_EQ(kMediaTime, renderer_->GetMediaTime());
+
+ // Allow seek task to post to the renderer.
+ base::RunLoop().RunUntilIdle();
+
+ // With seek completed, pipeline should again return the renderer's media time
+ // (as long as media time is moving forward).
+ EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
+}
+
class PipelineTeardownTest : public PipelineImplTest {
public:
enum TeardownState {
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698