Revert "Create unique cdm engines per WVDrmPlugin instance"
This change introduced b/77618383, need to revert.
This reverts commit 58234a69f2.
Change-Id: Ie7d515bcd94f2dcee6fa9b885cd0441845c82c22
Bug: 77618383
This commit is contained in:
committed by
Patrick Egloff
parent
58234a69f2
commit
90441e24df
@@ -24,7 +24,6 @@ Lock WvContentDecryptionModule::session_sharing_id_generation_lock_;
|
||||
WvContentDecryptionModule::WvContentDecryptionModule() {}
|
||||
|
||||
WvContentDecryptionModule::~WvContentDecryptionModule() {
|
||||
CloseAllCdms();
|
||||
ForceDisablePolicyTimer();
|
||||
}
|
||||
|
||||
@@ -76,6 +75,8 @@ CdmResponseType WvContentDecryptionModule::CloseSession(
|
||||
cdm_by_session_id_.erase(session_id);
|
||||
}
|
||||
|
||||
DisablePolicyTimer();
|
||||
|
||||
return sts;
|
||||
}
|
||||
|
||||
@@ -329,21 +330,12 @@ bool WvContentDecryptionModule::IsValidServiceCertificate(
|
||||
return cert.has_certificate();
|
||||
}
|
||||
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
const CdmIdentifier& identifier, drm_metrics::WvCdmMetrics* metrics) {
|
||||
if (!metrics) {
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
void WvContentDecryptionModule::GetSerializedMetrics(
|
||||
std::string* serialized_metrics) {
|
||||
AutoLock auto_lock(cdms_lock_);
|
||||
auto it = cdms_.find(identifier);
|
||||
if (it == cdms_.end()) {
|
||||
LOGE("WVContentDecryptionModule::Close. cdm_identifier not found");
|
||||
// TODO(blueeyes): Add a better error.
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
it->second.cdm_engine->GetMetrics()->Serialize(metrics);
|
||||
return NO_ERROR;
|
||||
CloseCdmsWithoutSessions();
|
||||
metrics_group_.SerializeToString(serialized_metrics);
|
||||
metrics_group_.Clear();
|
||||
}
|
||||
|
||||
WvContentDecryptionModule::CdmInfo::CdmInfo()
|
||||
@@ -379,26 +371,30 @@ CdmEngine* WvContentDecryptionModule::GetCdmForSessionId(
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::CloseAllCdms() {
|
||||
AutoLock auto_lock(cdms_lock_);
|
||||
// This method requires that the caller first acquire cdms_lock_.
|
||||
void WvContentDecryptionModule::CloseCdmsWithoutSessions() {
|
||||
for (auto it = cdms_.begin(); it != cdms_.end();) {
|
||||
it = cdms_.erase(it);
|
||||
}
|
||||
}
|
||||
if (it->second.cdm_engine->SessionSize() != 0) {
|
||||
++it;
|
||||
} else {
|
||||
// Retrieve the metrics from the engine and any completed
|
||||
// sessions. Clear the metrics from any completed sessions.
|
||||
metrics::EngineMetrics* engine_metrics =
|
||||
it->second.cdm_engine->GetMetrics();
|
||||
// engine_metrics should never be null.
|
||||
if (engine_metrics != NULL) {
|
||||
engine_metrics->Serialize(metrics_group_.add_metrics());
|
||||
} else {
|
||||
// Engine metrics should never be null.
|
||||
LOGI(
|
||||
"WvContentDecryptionModule::CloseCdmsWithoutSessions."
|
||||
"engine_metrics was unexpectedly NULL.");
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::CloseCdm(
|
||||
const CdmIdentifier& cdm_identifier) {
|
||||
AutoLock auto_lock(cdms_lock_);
|
||||
auto it = cdms_.find(cdm_identifier);
|
||||
if (it == cdms_.end()) {
|
||||
LOGE("WVContentDecryptionModule::Close. cdm_identifier not found");
|
||||
// TODO(blueeyes): Create a better error.
|
||||
return UNKNOWN_ERROR;
|
||||
// The CDM is no longer used for this identifier, delete it.
|
||||
it = cdms_.erase(it);
|
||||
}
|
||||
}
|
||||
cdms_.erase(it);
|
||||
|
||||
DisablePolicyTimer();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::EnablePolicyTimer() {
|
||||
@@ -407,16 +403,28 @@ void WvContentDecryptionModule::EnablePolicyTimer() {
|
||||
policy_timer_.Start(this, kCdmPolicyTimerDurationSeconds);
|
||||
}
|
||||
|
||||
// This implementation assumes that the caller has already acquired the
|
||||
// cdms_lock_.
|
||||
void WvContentDecryptionModule::DisablePolicyTimer() {
|
||||
bool cdms_is_empty = false;
|
||||
{
|
||||
AutoLock auto_lock(cdms_lock_);
|
||||
CloseCdmsWithoutSessions();
|
||||
cdms_is_empty = cdms_.empty();
|
||||
}
|
||||
|
||||
AutoLock auto_lock(policy_timer_lock_);
|
||||
if (cdms_.empty() && policy_timer_.IsRunning()) {
|
||||
policy_timer_.Stop();
|
||||
if (cdms_is_empty) {
|
||||
if (policy_timer_.IsRunning()) {
|
||||
policy_timer_.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::ForceDisablePolicyTimer() {
|
||||
{
|
||||
AutoLock auto_lock(cdms_lock_);
|
||||
CloseCdmsWithoutSessions();
|
||||
}
|
||||
|
||||
AutoLock auto_lock(policy_timer_lock_);
|
||||
if (policy_timer_.IsRunning()) {
|
||||
policy_timer_.Stop();
|
||||
|
||||
Reference in New Issue
Block a user