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

Unified Diff: media/base/pipeline.cc

Issue 740663002: Relanding 'Ignore seek operations to the current time in pause state' patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified GetMediaTime() as per review Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/pipeline_unittest.cc » ('j') | media/base/pipeline_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | media/base/pipeline_unittest.cc » ('j') | media/base/pipeline_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698