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

Unified Diff: media/base/pipeline_impl.cc

Issue 2621183002: [TO 56] Fix race in media Pipeline::GetMediaTime() after seeking. (Closed)
Patch Set: Created 3 years, 11 months 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 | « media/base/pipeline_impl.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl.cc
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 144291b681c66023724c083727b238458f653788..08a6ee042e0f00fad2987e2279d64ed548aec8d8 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -938,6 +938,7 @@ void PipelineImpl::Start(Demuxer* demuxer,
client_ = client;
seek_cb_ = seek_cb;
last_media_time_ = base::TimeDelta();
+ seek_time_ = kNoTimestamp;
std::unique_ptr<TextRenderer> text_renderer;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -1019,6 +1020,7 @@ void PipelineImpl::Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) {
DCHECK(seek_cb_.is_null());
seek_cb_ = seek_cb;
+ seek_time_ = time;
last_media_time_ = base::TimeDelta();
media_task_runner_->PostTask(
FROM_HERE, base::Bind(&RendererWrapper::Seek,
@@ -1049,6 +1051,7 @@ void PipelineImpl::Resume(std::unique_ptr<Renderer> renderer,
DCHECK(IsRunning());
DCHECK(seek_cb_.is_null());
seek_cb_ = seek_cb;
+ seek_time_ = time;
last_media_time_ = base::TimeDelta();
media_task_runner_->PostTask(
@@ -1103,6 +1106,14 @@ void PipelineImpl::SetVolume(float volume) {
base::TimeDelta PipelineImpl::GetMediaTime() const {
DCHECK(thread_checker_.CalledOnValidThread());
+ // Don't trust renderer time during a pending seek. Renderer may return
+ // pre-seek time which may corrupt |last_media_time_| used for clamping.
+ if (seek_time_ != kNoTimestamp) {
+ DVLOG(3) << __func__ << ": (seeking) " << seek_time_.InMilliseconds()
+ << " ms";
+ return seek_time_;
+ }
+
base::TimeDelta media_time = renderer_wrapper_->GetMediaTime();
// Clamp current media time to the last reported value, this prevents higher
@@ -1281,6 +1292,8 @@ void PipelineImpl::OnSeekDone() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(IsRunning());
+ seek_time_ = kNoTimestamp;
+
DCHECK(!seek_cb_.is_null());
base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
}
« no previous file with comments | « media/base/pipeline_impl.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698