diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 02:27:15 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 02:27:15 +0000 |
commit | fc71bb7b2d1420df75b530be4e1d65cbe6a416cd (patch) | |
tree | 4e801d25de9f45bdff8b1985f1949cab4c640b2a /media | |
parent | 59b89cbe5228715a4cbbb17a77a739ffb16b02ae (diff) | |
download | chromium_src-fc71bb7b2d1420df75b530be4e1d65cbe6a416cd.zip chromium_src-fc71bb7b2d1420df75b530be4e1d65cbe6a416cd.tar.gz chromium_src-fc71bb7b2d1420df75b530be4e1d65cbe6a416cd.tar.bz2 |
Nice and easy fix for the media clock interpolating past the duration.
I considered adding duration to Clock itself, but that felt like it would pollute Clock's simple purposes of keeping track of time. Furthermore, by keeping duration checking in PipelineImpl we can handle future scenarios such as streaming media where clock really should run forever.
BUG=16508
TEST=currentTime should never exceed duration
Review URL: http://codereview.chromium.org/159573
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/mock_filters.h | 6 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 6 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 16 |
3 files changed, 20 insertions, 8 deletions
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index c933bd2..7954aa9 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -336,6 +336,12 @@ ACTION_P2(SetError, filter, error) { filter->host()->SetError(error); } +// Helper gmock action that calls SetDuration() on behalf of the provided +// filter. +ACTION_P2(SetDuration, filter, duration) { + filter->host()->SetDuration(duration); +} + } // namespace media #endif // MEDIA_BASE_MOCK_FILTERS_H_ diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 21b9338..a09c2c7 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -202,7 +202,11 @@ void PipelineImpl::SetVolume(float volume) { base::TimeDelta PipelineImpl::GetCurrentTime() const { AutoLock auto_lock(lock_); - return clock_.Elapsed(); + base::TimeDelta elapsed = clock_.Elapsed(); + if (elapsed > duration_) { + return duration_; + } + return elapsed; } base::TimeDelta PipelineImpl::GetBufferedTime() const { diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index e745761..7e69ce5 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -75,10 +75,12 @@ class PipelineImplTest : public ::testing::Test { // Sets up expectations to allow the demuxer to initialize. typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; - void InitializeDemuxer(MockDemuxerStreamVector* streams) { + void InitializeDemuxer(MockDemuxerStreamVector* streams, + const base::TimeDelta& duration) { EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source(), NotNull())) - .WillOnce(Invoke(&RunFilterCallback)); + .WillOnce(DoAll(SetDuration(mocks_->data_source(), duration), + Invoke(&RunFilterCallback))); EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) .WillRepeatedly(Return(streams->size())); EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); @@ -277,7 +279,7 @@ TEST_F(PipelineImplTest, AudioStream) { streams.push_back(stream); InitializeDataSource(); - InitializeDemuxer(&streams); + InitializeDemuxer(&streams, base::TimeDelta()); InitializeAudioDecoder(stream); InitializeAudioRenderer(); @@ -295,7 +297,7 @@ TEST_F(PipelineImplTest, VideoStream) { streams.push_back(stream); InitializeDataSource(); - InitializeDemuxer(&streams); + InitializeDemuxer(&streams, base::TimeDelta()); InitializeVideoDecoder(stream); InitializeVideoRenderer(); @@ -316,7 +318,7 @@ TEST_F(PipelineImplTest, AudioVideoStream) { streams.push_back(video_stream); InitializeDataSource(); - InitializeDemuxer(&streams); + InitializeDemuxer(&streams, base::TimeDelta()); InitializeAudioDecoder(audio_stream); InitializeAudioRenderer(); InitializeVideoDecoder(video_stream); @@ -339,7 +341,7 @@ TEST_F(PipelineImplTest, Seek) { streams.push_back(video_stream); InitializeDataSource(); - InitializeDemuxer(&streams); + InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); InitializeAudioDecoder(audio_stream); InitializeAudioRenderer(); InitializeVideoDecoder(video_stream); @@ -382,7 +384,7 @@ TEST_F(PipelineImplTest, SetVolume) { streams.push_back(audio_stream); InitializeDataSource(); - InitializeDemuxer(&streams); + InitializeDemuxer(&streams, base::TimeDelta()); InitializeAudioDecoder(audio_stream); InitializeAudioRenderer(); |