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

Unified Diff: media/base/pipeline_impl.cc

Issue 2616703002: Fix race condition in media Pipeline::GetMediaTime() after seeking. (Closed)
Patch Set: Feedback 2 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 85d470a022758459ac8f8f7f7bae599a088d7b76..85b54ec6a274af7867d7cff74ea3ec45a72dbea5 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();
+ 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;
+ seek_time_ = time;
last_media_time_ = base::TimeDelta();
media_task_runner_->PostTask(
FROM_HERE, base::Bind(&RendererWrapper::Seek,
@@ -1069,6 +1071,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(
@@ -1123,6 +1126,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
@@ -1301,6 +1312,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