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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/pipeline_impl.h" 5 #include "media/base/pipeline_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime)); 819 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime));
820 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); 820 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
821 821
822 // Media time should not go backwards even if the renderer returns an 822 // Media time should not go backwards even if the renderer returns an
823 // errorneous value. PipelineImpl should clamp it to last reported value. 823 // errorneous value. PipelineImpl should clamp it to last reported value.
824 EXPECT_CALL(*renderer_, GetMediaTime()) 824 EXPECT_CALL(*renderer_, GetMediaTime())
825 .WillRepeatedly(Return(base::TimeDelta::FromSeconds(1))); 825 .WillRepeatedly(Return(base::TimeDelta::FromSeconds(1)));
826 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); 826 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
827 } 827 }
828 828
829 // Seeking posts a task from main thread to media thread to seek the renderer,
830 // resetting its internal clock. Calling GetMediaTime() should be safe even
831 // when the renderer has not performed the seek (simulated by its continuing
832 // to return the pre-seek time). Verifies fix for http://crbug.com/675556
833 TEST_F(PipelineImplTest, GetMediaTimeAfterSeek) {
834 CreateAudioStream();
835 MockDemuxerStreamVector streams;
836 streams.push_back(audio_stream());
837 SetDemuxerExpectations(&streams);
838 SetRendererExpectations();
839 StartPipelineAndExpect(PIPELINE_OK);
840
841 // Pipeline should report the same media time returned by the renderer.
842 base::TimeDelta kMediaTime = base::TimeDelta::FromSeconds(2);
843 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime));
844 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
845
846 // Seek backward 1 second. Do not run RunLoop to ensure renderer is not yet
847 // notified of the seek (via media thread).
848 base::TimeDelta kSeekTime = kMediaTime - base::TimeDelta::FromSeconds(1);
849 ExpectSeek(kSeekTime, false);
850 pipeline_->Seek(kSeekTime, base::Bind(&CallbackHelper::OnSeek,
851 base::Unretained(&callbacks_)));
852
853 // Verify pipeline returns the seek time in spite of renderer returning the
854 // stale media time.
855 EXPECT_EQ(kSeekTime, pipeline_->GetMediaTime());
856 EXPECT_EQ(kMediaTime, renderer_->GetMediaTime());
857
858 // Allow seek task to post to the renderer.
859 base::RunLoop().RunUntilIdle();
860
861 // With seek completed, pipeline should again return the renderer's media time
862 // (as long as media time is moving forward).
863 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime());
864 }
865
829 class PipelineTeardownTest : public PipelineImplTest { 866 class PipelineTeardownTest : public PipelineImplTest {
830 public: 867 public:
831 enum TeardownState { 868 enum TeardownState {
832 kInitDemuxer, 869 kInitDemuxer,
833 kInitRenderer, 870 kInitRenderer,
834 kFlushing, 871 kFlushing,
835 kSeeking, 872 kSeeking,
836 kPlaying, 873 kPlaying,
837 kSuspending, 874 kSuspending,
838 kSuspended, 875 kSuspended,
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1128 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1092 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1129 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1093 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); 1130 INSTANTIATE_TEARDOWN_TEST(Error, Suspending);
1094 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); 1131 INSTANTIATE_TEARDOWN_TEST(Error, Suspended);
1095 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); 1132 INSTANTIATE_TEARDOWN_TEST(Error, Resuming);
1096 1133
1097 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1134 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1098 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); 1135 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended);
1099 1136
1100 } // namespace media 1137 } // namespace media
OLDNEW
« 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