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

Unified Diff: media/base/pipeline_impl.cc

Issue 1815013002: Restore CDM context on Resume(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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') | no next file » | 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 da4e210500e4f66b664cd38bc4f0defd1327c4bd..4b87a4729e922dc0bb0ce24405cda1e9d015a4fc 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -47,7 +47,7 @@ PipelineImpl::PipelineImpl(
renderer_ended_(false),
text_renderer_ended_(false),
demuxer_(NULL),
- pending_cdm_context_(nullptr),
+ cdm_context_(nullptr),
weak_factory_(this) {
media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated));
}
@@ -533,12 +533,6 @@ void PipelineImpl::StartTask() {
weak_factory_.GetWeakPtr()));
}
- // Set CDM early to avoid unnecessary delay in Renderer::Initialize().
- if (pending_cdm_context_) {
- renderer_->SetCdm(pending_cdm_context_, base::Bind(&IgnoreCdmAttached));
- pending_cdm_context_ = nullptr;
- }
-
StateTransitionTask(PIPELINE_OK);
}
@@ -742,12 +736,23 @@ void PipelineImpl::SetCdmTask(CdmContext* cdm_context,
const CdmAttachedCB& cdm_attached_cb) {
base::AutoLock auto_lock(lock_);
if (!renderer_) {
- pending_cdm_context_ = cdm_context;
+ cdm_context_ = cdm_context;
cdm_attached_cb.Run(true);
return;
}
- renderer_->SetCdm(cdm_context, cdm_attached_cb);
+ renderer_->SetCdm(cdm_context, base::Bind(&PipelineImpl::OnCdmAttached,
+ weak_factory_.GetWeakPtr(),
xhwang 2016/03/17 23:11:15 It seems we are already calling GetWeakPtr() on tw
sandersd (OOO until July 31) 2016/03/17 23:25:03 It's safe to call from two threads; the rule is th
xhwang 2016/03/18 17:05:55 +wez GetWeakPtr() call is not thread safe accordi
Wez 2016/03/18 19:49:28 GetWeakPtr is safe to call from different threads,
xhwang 2016/03/18 20:05:34 This is one of the oldest piece of our code base a
+ cdm_attached_cb, cdm_context));
+}
+
+void PipelineImpl::OnCdmAttached(const CdmAttachedCB& cdm_attached_cb,
+ CdmContext* cdm_context,
+ bool success) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ if (success)
+ cdm_context_ = cdm_context;
+ cdm_attached_cb.Run(success);
}
void PipelineImpl::OnRendererEnded() {
@@ -840,6 +845,9 @@ void PipelineImpl::InitializeRenderer(const PipelineStatusCB& done_cb) {
return;
}
+ if (cdm_context_)
+ renderer_->SetCdm(cdm_context_, base::Bind(&IgnoreCdmAttached));
+
base::WeakPtr<PipelineImpl> weak_this = weak_factory_.GetWeakPtr();
renderer_->Initialize(
demuxer_, done_cb,
« no previous file with comments | « media/base/pipeline_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698