Index: media/base/pipeline.cc |
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc |
index 059710525372976dad8118a21e144fc6542d154c..9052a73f7b617e581abca584c14cd156a46ed15c 100644 |
--- a/media/base/pipeline.cc |
+++ b/media/base/pipeline.cc |
@@ -162,7 +162,13 @@ TimeDelta Pipeline::GetMediaTime() const { |
if (!renderer_) |
return TimeDelta(); |
+ // FIXME: In some cases GetMediaTime() returns a value few milli seconds |
DaleCurtis
2014/12/01 19:33:48
In chromium code the syntax is "TODO(<your user na
Srirama
2014/12/02 11:16:29
Done.
|
+ // less than duration even though playback has ended. |
TimeDelta media_time = renderer_->GetMediaTime(); |
+ if (renderer_ended_ && media_time < duration_) { |
+ if ((duration_ - media_time).ToInternalValue() <= 250000) |
DaleCurtis
2014/12/01 19:33:48
Note: Use InMilliseconds() not ToInternalValue().
Srirama
2014/12/02 11:16:29
Done.
|
+ return duration_; |
+ } |
return std::min(media_time, duration_); |
} |
@@ -634,6 +640,12 @@ 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).ToInternalValue() > 250000) |
+ SetDuration(media_time); |
+ } |
DCHECK_EQ(status_, PIPELINE_OK); |
ended_cb_.Run(); |
} |