Commit d496219f authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Keep |cdm_context_ref_| in mojo media services on failure

When unexpected failure happens, we expect the service to stay in a
valid state.

Bug: 1004730
Test: Manually tested
Change-Id: Ib35035705e4604b9aa8cf5212de07bc1069e73d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810846
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697907}
parent 12437e0b
...@@ -40,13 +40,16 @@ void MojoAudioDecoderService::Initialize(const AudioDecoderConfig& config, ...@@ -40,13 +40,16 @@ void MojoAudioDecoderService::Initialize(const AudioDecoderConfig& config,
// Get CdmContext from cdm_id if the stream is encrypted. // Get CdmContext from cdm_id if the stream is encrypted.
CdmContext* cdm_context = nullptr; CdmContext* cdm_context = nullptr;
if (config.is_encrypted()) { if (config.is_encrypted()) {
cdm_context_ref_ = mojo_cdm_service_context_->GetCdmContextRef(cdm_id); auto cdm_context_ref = mojo_cdm_service_context_->GetCdmContextRef(cdm_id);
if (!cdm_context_ref_) { if (!cdm_context_ref) {
DVLOG(1) << "CdmContextRef not found for CDM id: " << cdm_id; DVLOG(1) << "CdmContextRef not found for CDM id: " << cdm_id;
std::move(callback).Run(false, false); std::move(callback).Run(false, false);
return; return;
} }
// |cdm_context_ref_| must be kept as long as |cdm_context| is used by the
// |decoder_|.
cdm_context_ref_ = std::move(cdm_context_ref);
cdm_context = cdm_context_ref_->GetCdmContext(); cdm_context = cdm_context_ref_->GetCdmContext();
DCHECK(cdm_context); DCHECK(cdm_context);
} }
......
...@@ -127,13 +127,16 @@ void MojoRendererService::SetCdm(int32_t cdm_id, SetCdmCallback callback) { ...@@ -127,13 +127,16 @@ void MojoRendererService::SetCdm(int32_t cdm_id, SetCdmCallback callback) {
return; return;
} }
cdm_context_ref_ = mojo_cdm_service_context_->GetCdmContextRef(cdm_id); auto cdm_context_ref = mojo_cdm_service_context_->GetCdmContextRef(cdm_id);
if (!cdm_context_ref_) { if (!cdm_context_ref) {
DVLOG(1) << "CdmContextRef not found for CDM ID: " << cdm_id; DVLOG(1) << "CdmContextRef not found for CDM ID: " << cdm_id;
std::move(callback).Run(false); std::move(callback).Run(false);
return; return;
} }
// |cdm_context_ref_| must be kept as long as |cdm_context| is used by the
// |renderer_|.
cdm_context_ref_ = std::move(cdm_context_ref);
auto* cdm_context = cdm_context_ref_->GetCdmContext(); auto* cdm_context = cdm_context_ref_->GetCdmContext();
DCHECK(cdm_context); DCHECK(cdm_context);
......
...@@ -178,13 +178,16 @@ void MojoVideoDecoderService::Initialize(const VideoDecoderConfig& config, ...@@ -178,13 +178,16 @@ void MojoVideoDecoderService::Initialize(const VideoDecoderConfig& config,
// Get CdmContext from cdm_id if the stream is encrypted. // Get CdmContext from cdm_id if the stream is encrypted.
CdmContext* cdm_context = nullptr; CdmContext* cdm_context = nullptr;
if (cdm_id != CdmContext::kInvalidCdmId) { if (cdm_id != CdmContext::kInvalidCdmId) {
cdm_context_ref_ = mojo_cdm_service_context_->GetCdmContextRef(cdm_id); auto cdm_context_ref = mojo_cdm_service_context_->GetCdmContextRef(cdm_id);
if (!cdm_context_ref_) { if (!cdm_context_ref) {
DVLOG(1) << "CdmContextRef not found for CDM id: " << cdm_id; DVLOG(1) << "CdmContextRef not found for CDM id: " << cdm_id;
OnDecoderInitialized(false); OnDecoderInitialized(false);
return; return;
} }
// |cdm_context_ref_| must be kept as long as |cdm_context| is used by the
// |decoder_|.
cdm_context_ref_ = std::move(cdm_context_ref);
cdm_context = cdm_context_ref_->GetCdmContext(); cdm_context = cdm_context_ref_->GetCdmContext();
DCHECK(cdm_context); DCHECK(cdm_context);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment