Chromium Code Reviews| Index: media/base/pipeline.cc |
| diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc |
| index 059710525372976dad8118a21e144fc6542d154c..f76d31c655d2843d36037c36ac4ed233eca5f0d3 100644 |
| --- a/media/base/pipeline.cc |
| +++ b/media/base/pipeline.cc |
| @@ -29,6 +29,11 @@ using base::TimeDelta; |
| namespace media { |
| +// TODO(sriram): There are cases where current time falls short of duration |
| +// by a few milliseconds. This is a workaround till we find the actual fix and |
| +// 250ms is chosen here as it is the max time between timeupdate events. |
| +const int kCurrTimeErrorInMillisecondsOnPlaybackEnd = 250; |
|
Srirama
2014/12/02 11:16:29
Do we need this, or can i directly use 250 below?
DaleCurtis
2014/12/02 18:14:05
Since you only have one usage, it's fine to inline
Srirama
2014/12/03 14:43:02
Done.
|
| + |
| Pipeline::Pipeline( |
| const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| MediaLog* media_log) |
| @@ -162,7 +167,12 @@ TimeDelta Pipeline::GetMediaTime() const { |
| if (!renderer_) |
| return TimeDelta(); |
| + // TODO(sriram): In some cases GetMediaTime() returns a value few |
| + // milliseconds less than duration, even though playback has ended. |
| TimeDelta media_time = renderer_->GetMediaTime(); |
| + if (renderer_ended_) |
| + return duration_; |
| + |
| return std::min(media_time, duration_); |
| } |
| @@ -634,6 +644,14 @@ void Pipeline::RunEndedCallbackIfNeeded() { |
| if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_) |
| return; |
| + // Correct the duration if current time is less |
| + TimeDelta media_time = renderer_->GetMediaTime(); |
| + if (media_time < duration_) { |
| + if ((duration_ - media_time).InMilliseconds() > |
| + kCurrTimeErrorInMillisecondsOnPlaybackEnd) |
|
DaleCurtis
2014/12/02 18:14:05
You don't need the media_time < duration_ check si
Srirama
2014/12/03 14:43:02
Removed the condition but not inlined the function
|
| + SetDuration(media_time); |
| + } |
| + |
| DCHECK_EQ(status_, PIPELINE_OK); |
| ended_cb_.Run(); |
| } |