Chromium Code Reviews| Index: media/base/pipeline_impl.cc |
| diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc |
| index da4e210500e4f66b664cd38bc4f0defd1327c4bd..6b5442cfc35d88202489f9a230c3bdbddb17536d 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, |
| + base::Unretained(this), |
| + cdm_attached_cb, cdm_context)); |
|
xhwang
2016/03/18 17:05:55
Typically when you use base::Unretained() you'll w
Wez
2016/03/18 19:49:28
Agreed; the comment on SetCdm() implies that it ma
sandersd (OOO until July 31)
2016/03/18 20:26:18
This is safe because ~RendererImpl resets the call
|
| +} |
| + |
| +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, |