Merge "Make Properties::Init() Take Action Only Once"
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "cdm_client_property_set.h"
|
#include "cdm_client_property_set.h"
|
||||||
@@ -30,11 +31,14 @@ typedef std::map<CdmSessionId, CdmClientPropertySet*>
|
|||||||
// Setter methods are provided but their only planned use is for testing.
|
// Setter methods are provided but their only planned use is for testing.
|
||||||
class Properties {
|
class Properties {
|
||||||
public:
|
public:
|
||||||
// Called at least once before any properties are used. Depending on the
|
static void Init() {
|
||||||
// platform, this function may be called multiple times. It is called each
|
std::unique_lock<std::mutex> lock(init_mutex_);
|
||||||
// time a CdmEngine is created, and when running unit tests it is called in
|
|
||||||
// many tests' SetUp function.
|
if (!is_initialized_) {
|
||||||
static void Init();
|
InitOnce();
|
||||||
|
is_initialized_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool oem_crypto_use_secure_buffers() {
|
static inline bool oem_crypto_use_secure_buffers() {
|
||||||
return oem_crypto_use_secure_buffers_;
|
return oem_crypto_use_secure_buffers_;
|
||||||
@@ -108,6 +112,11 @@ class Properties {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Called at least once before any properties are used.
|
||||||
|
static void InitOnce();
|
||||||
|
|
||||||
|
static std::mutex init_mutex_;
|
||||||
|
static bool is_initialized_;
|
||||||
static bool oem_crypto_use_secure_buffers_;
|
static bool oem_crypto_use_secure_buffers_;
|
||||||
static bool oem_crypto_use_fifo_;
|
static bool oem_crypto_use_fifo_;
|
||||||
static bool oem_crypto_use_userspace_buffers_;
|
static bool oem_crypto_use_userspace_buffers_;
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ const char* kSecurityLevelDirs[] = {"L1/", "L3/"};
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
std::mutex Properties::init_mutex_;
|
||||||
|
bool Properties::is_initialized_ = false;
|
||||||
bool Properties::oem_crypto_use_secure_buffers_;
|
bool Properties::oem_crypto_use_secure_buffers_;
|
||||||
bool Properties::oem_crypto_use_fifo_;
|
bool Properties::oem_crypto_use_fifo_;
|
||||||
bool Properties::oem_crypto_use_userspace_buffers_;
|
bool Properties::oem_crypto_use_userspace_buffers_;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ bool GetAndroidProperty(const char* key, std::string* value) {
|
|||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
|
||||||
void Properties::Init() {
|
void Properties::InitOnce() {
|
||||||
oem_crypto_use_secure_buffers_ = kPropertyOemCryptoUseSecureBuffers;
|
oem_crypto_use_secure_buffers_ = kPropertyOemCryptoUseSecureBuffers;
|
||||||
oem_crypto_use_fifo_ = kPropertyOemCryptoUseFifo;
|
oem_crypto_use_fifo_ = kPropertyOemCryptoUseFifo;
|
||||||
oem_crypto_use_userspace_buffers_ = kPropertyOemCryptoUseUserSpaceBuffers;
|
oem_crypto_use_userspace_buffers_ = kPropertyOemCryptoUseUserSpaceBuffers;
|
||||||
|
|||||||
Reference in New Issue
Block a user