Added mutex protection for session_property_set_. am: 381f879ff7
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/19561012 Change-Id: Iec56b526fd95cafbd09aae9894796c959924f48a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -142,6 +142,7 @@ class Properties {
|
||||
static void InitOnce();
|
||||
|
||||
static std::mutex init_mutex_;
|
||||
static std::mutex session_mutex_;
|
||||
static bool is_initialized_;
|
||||
static bool oem_crypto_use_secure_buffers_;
|
||||
static bool oem_crypto_use_fifo_;
|
||||
|
||||
@@ -12,7 +12,10 @@ const char* kSecurityLevelDirs[] = {"L1/", "L3/"};
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
using UniqueLock = std::unique_lock<std::mutex>;
|
||||
|
||||
std::mutex Properties::init_mutex_;
|
||||
std::mutex Properties::session_mutex_;
|
||||
bool Properties::is_initialized_ = false;
|
||||
bool Properties::oem_crypto_use_secure_buffers_;
|
||||
bool Properties::oem_crypto_use_fifo_;
|
||||
@@ -26,6 +29,7 @@ std::unique_ptr<CdmClientPropertySetMap> Properties::session_property_set_;
|
||||
|
||||
bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
||||
CdmClientPropertySet* property_set) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
if (!session_property_set_) {
|
||||
return false;
|
||||
}
|
||||
@@ -37,6 +41,7 @@ bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
||||
}
|
||||
|
||||
bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
if (!session_property_set_) {
|
||||
return false;
|
||||
}
|
||||
@@ -45,6 +50,7 @@ bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
||||
|
||||
CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
||||
const CdmSessionId& session_id) {
|
||||
// Call must obtain |session_mutex_|.
|
||||
if (session_property_set_) {
|
||||
CdmClientPropertySetMap::iterator it =
|
||||
session_property_set_->find(session_id);
|
||||
@@ -57,6 +63,7 @@ CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
||||
|
||||
bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
||||
std::string* app_id) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (property_set == nullptr) {
|
||||
@@ -68,6 +75,7 @@ bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
||||
|
||||
bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||
std::string* service_certificate) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (property_set == nullptr) {
|
||||
@@ -79,6 +87,7 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||
|
||||
bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
||||
const std::string& service_certificate) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id);
|
||||
if (property_set == nullptr) {
|
||||
return false;
|
||||
@@ -88,6 +97,7 @@ bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
||||
}
|
||||
|
||||
bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (property_set == nullptr) {
|
||||
@@ -97,6 +107,7 @@ bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||
}
|
||||
|
||||
uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) {
|
||||
UniqueLock lock(session_mutex_);
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (property_set == nullptr) {
|
||||
|
||||
@@ -52,7 +52,10 @@ void Properties::InitOnce() {
|
||||
allow_restore_of_offline_licenses_with_release_ =
|
||||
kAllowRestoreOfflineLicenseWithRelease;
|
||||
delay_oem_crypto_termination_ = kPropertyDelayOemCryptoTermination;
|
||||
session_property_set_.reset(new CdmClientPropertySetMap());
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(session_mutex_);
|
||||
session_property_set_.reset(new CdmClientPropertySetMap());
|
||||
}
|
||||
}
|
||||
|
||||
bool Properties::GetCompanyName(std::string* company_name) {
|
||||
|
||||
Reference in New Issue
Block a user