| Index: media/base/pipeline.cc
|
| diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
|
| index 059710525372976dad8118a21e144fc6542d154c..2e6b12eeb1a06ad933bdff9b9e97118c24bf4788 100644
|
| --- a/media/base/pipeline.cc
|
| +++ b/media/base/pipeline.cc
|
| @@ -162,7 +162,13 @@ 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
|
| + // http://crbug.com/438581
|
| TimeDelta media_time = renderer_->GetMediaTime();
|
| + if (renderer_ended_)
|
| + return duration_;
|
| +
|
| return std::min(media_time, duration_);
|
| }
|
|
|
| @@ -634,6 +640,16 @@ void Pipeline::RunEndedCallbackIfNeeded() {
|
| if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_)
|
| return;
|
|
|
| + // Correct the duration against current time if it turns out that
|
| + // the initially reported duration is wrong
|
| + // TODO(sriram): There are cases where duration is correct and 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 (http://crbug.com/438581).
|
| + TimeDelta media_time = renderer_->GetMediaTime();
|
| + if ((duration_ - media_time).InMilliseconds() > 250)
|
| + SetDuration(media_time);
|
| +
|
| DCHECK_EQ(status_, PIPELINE_OK);
|
| ended_cb_.Run();
|
| }
|
|
|