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

Unified Diff: media/base/pipeline_impl.cc

Issue 2616703002: Fix race condition in media Pipeline::GetMediaTime() after seeking. (Closed)
Patch Set: Fix SharedState. 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
Index: media/base/pipeline_impl.cc
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 85d470a022758459ac8f8f7f7bae599a088d7b76..5dcc4b60ce3c516a29a2d859f1c9edf7c4cfd73f 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -958,6 +958,7 @@ void PipelineImpl::Start(Demuxer* demuxer,
client_ = client;
seek_cb_ = seek_cb;
last_media_time_ = base::TimeDelta();
+ pending_seek_time_ = kNoTimestamp;
std::unique_ptr<TextRenderer> text_renderer;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -1039,6 +1040,7 @@ void PipelineImpl::Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) {
DCHECK(seek_cb_.is_null());
seek_cb_ = seek_cb;
+ pending_seek_time_ = time;
last_media_time_ = base::TimeDelta();
media_task_runner_->PostTask(
FROM_HERE, base::Bind(&RendererWrapper::Seek,
@@ -1123,7 +1125,11 @@ void PipelineImpl::SetVolume(float volume) {
base::TimeDelta PipelineImpl::GetMediaTime() const {
DCHECK(thread_checker_.CalledOnValidThread());
- base::TimeDelta media_time = renderer_wrapper_->GetMediaTime();
+ // Don't trust renderer time during a pending seek. Renderer may return
+ // pre-seek time which may corrupt |last_media_time_| used for clamping.
+ base::TimeDelta media_time = pending_seek_time_ == kNoTimestamp
sandersd (OOO until July 31) 2017/01/04 21:10:23 Nit: Swap order.
chcunningham 2017/01/04 21:15:46 Done.
+ ? renderer_wrapper_->GetMediaTime()
+ : pending_seek_time_;
// Clamp current media time to the last reported value, this prevents higher
// level clients from seeing time go backwards based on inaccurate or spurious
@@ -1301,6 +1307,8 @@ void PipelineImpl::OnSeekDone() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(IsRunning());
+ pending_seek_time_ = kNoTimestamp;
chcunningham 2017/01/04 21:01:37 Should I also be clearing this in PipelineImp::Res
sandersd (OOO until July 31) 2017/01/04 21:10:23 Resume() should also set the seek time, I believe
chcunningham 2017/01/04 21:15:46 Done.
+
DCHECK(!seek_cb_.is_null());
base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
}

Powered by Google App Engine
This is Rietveld 408576698