am a8328dd2: Delete Singleton on Library Unload
* commit 'a8328dd2f945e8357b3a58c76b0a71a4a2463aa1': Delete Singleton on Library Unload
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#define CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
#define CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||||
|
|
||||||
#include <UniquePtr.h>
|
#include <UniquePtr.h>
|
||||||
|
#include <utils/RefBase.h>
|
||||||
|
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
@@ -15,7 +16,7 @@ class CdmClientPropertySet;
|
|||||||
class CdmEngine;
|
class CdmEngine;
|
||||||
class WvCdmEventListener;
|
class WvCdmEventListener;
|
||||||
|
|
||||||
class WvContentDecryptionModule : public TimerHandler {
|
class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||||
public:
|
public:
|
||||||
WvContentDecryptionModule();
|
WvContentDecryptionModule();
|
||||||
virtual ~WvContentDecryptionModule();
|
virtual ~WvContentDecryptionModule();
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
#ifndef WV_CDM_SINGLETON_H_
|
#ifndef WV_CDM_SINGLETON_H_
|
||||||
#define WV_CDM_SINGLETON_H_
|
#define WV_CDM_SINGLETON_H_
|
||||||
|
|
||||||
|
#include "utils/StrongPointer.h"
|
||||||
|
|
||||||
#include "wv_content_decryption_module.h"
|
#include "wv_content_decryption_module.h"
|
||||||
|
|
||||||
namespace wvdrm {
|
namespace wvdrm {
|
||||||
|
|
||||||
wvcdm::WvContentDecryptionModule* getCDM();
|
android::sp<wvcdm::WvContentDecryptionModule> getCDM();
|
||||||
|
|
||||||
} // namespace wvdrm
|
} // namespace wvdrm
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "utils/StrongPointer.h"
|
||||||
#include "utils/Vector.h"
|
#include "utils/Vector.h"
|
||||||
|
|
||||||
#include "media/hardware/CryptoAPI.h"
|
#include "media/hardware/CryptoAPI.h"
|
||||||
@@ -19,7 +20,7 @@ namespace wvdrm {
|
|||||||
class WVCryptoPlugin : public android::CryptoPlugin {
|
class WVCryptoPlugin : public android::CryptoPlugin {
|
||||||
public:
|
public:
|
||||||
WVCryptoPlugin(const void* data, size_t size,
|
WVCryptoPlugin(const void* data, size_t size,
|
||||||
wvcdm::WvContentDecryptionModule* cdm);
|
const android::sp<wvcdm::WvContentDecryptionModule>& cdm);
|
||||||
virtual ~WVCryptoPlugin() {}
|
virtual ~WVCryptoPlugin() {}
|
||||||
|
|
||||||
virtual bool requiresSecureDecoderComponent(const char* mime) const;
|
virtual bool requiresSecureDecoderComponent(const char* mime) const;
|
||||||
@@ -37,7 +38,7 @@ class WVCryptoPlugin : public android::CryptoPlugin {
|
|||||||
private:
|
private:
|
||||||
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoPlugin);
|
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoPlugin);
|
||||||
|
|
||||||
wvcdm::WvContentDecryptionModule* const mCDM;
|
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
|
||||||
|
|
||||||
bool mTestMode;
|
bool mTestMode;
|
||||||
wvcdm::CdmSessionId mSessionId;
|
wvcdm::CdmSessionId mSessionId;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ using namespace std;
|
|||||||
using namespace wvcdm;
|
using namespace wvcdm;
|
||||||
|
|
||||||
WVCryptoPlugin::WVCryptoPlugin(const void* data, size_t size,
|
WVCryptoPlugin::WVCryptoPlugin(const void* data, size_t size,
|
||||||
WvContentDecryptionModule* cdm)
|
const sp<WvContentDecryptionModule>& cdm)
|
||||||
: mCDM(cdm),
|
: mCDM(cdm),
|
||||||
mTestMode(false),
|
mTestMode(false),
|
||||||
mSessionId(configureTestMode(data, size)) {}
|
mSessionId(configureTestMode(data, size)) {}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "utils/KeyedVector.h"
|
#include "utils/KeyedVector.h"
|
||||||
#include "utils/List.h"
|
#include "utils/List.h"
|
||||||
#include "utils/String8.h"
|
#include "utils/String8.h"
|
||||||
|
#include "utils/StrongPointer.h"
|
||||||
#include "utils/Vector.h"
|
#include "utils/Vector.h"
|
||||||
#include "wv_cdm_event_listener.h"
|
#include "wv_cdm_event_listener.h"
|
||||||
#include "wv_content_decryption_module.h"
|
#include "wv_content_decryption_module.h"
|
||||||
@@ -41,7 +42,7 @@ const OEMCrypto_Algorithm kInvalidCrytpoAlgorithm =
|
|||||||
class WVDrmPlugin : public android::DrmPlugin,
|
class WVDrmPlugin : public android::DrmPlugin,
|
||||||
public wvcdm::WvCdmEventListener {
|
public wvcdm::WvCdmEventListener {
|
||||||
public:
|
public:
|
||||||
WVDrmPlugin(WvContentDecryptionModule* cdm,
|
WVDrmPlugin(const android::sp<wvcdm::WvContentDecryptionModule>& cdm,
|
||||||
WVGenericCryptoInterface* crypto);
|
WVGenericCryptoInterface* crypto);
|
||||||
|
|
||||||
virtual ~WVDrmPlugin();
|
virtual ~WVDrmPlugin();
|
||||||
@@ -248,7 +249,7 @@ class WVDrmPlugin : public android::DrmPlugin,
|
|||||||
std::string mAppId;
|
std::string mAppId;
|
||||||
} mPropertySet;
|
} mPropertySet;
|
||||||
|
|
||||||
WvContentDecryptionModule* mCDM;
|
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
|
||||||
WVGenericCryptoInterface* mCrypto;
|
WVGenericCryptoInterface* mCrypto;
|
||||||
std::string mOrigin;
|
std::string mOrigin;
|
||||||
map<CdmSessionId, CryptoSession> mCryptoSessions;
|
map<CdmSessionId, CryptoSession> mCryptoSessions;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ DrmPlugin::KeyStatusType ConvertFromCdmKeyStatus(CdmKeyStatus keyStatus) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WVDrmPlugin::WVDrmPlugin(WvContentDecryptionModule* cdm,
|
WVDrmPlugin::WVDrmPlugin(const sp<WvContentDecryptionModule>& cdm,
|
||||||
WVGenericCryptoInterface* crypto)
|
WVGenericCryptoInterface* crypto)
|
||||||
: mCDM(cdm), mCrypto(crypto), mOrigin(), mCryptoSessions() {}
|
: mCDM(cdm), mCrypto(crypto), mOrigin(), mCryptoSessions() {}
|
||||||
|
|
||||||
|
|||||||
@@ -9,21 +9,30 @@
|
|||||||
#include "WVCDMSingleton.h"
|
#include "WVCDMSingleton.h"
|
||||||
|
|
||||||
#include "utils/Mutex.h"
|
#include "utils/Mutex.h"
|
||||||
|
#include "utils/RefBase.h"
|
||||||
|
|
||||||
namespace wvdrm {
|
namespace wvdrm {
|
||||||
|
|
||||||
using wvcdm::WvContentDecryptionModule;
|
using wvcdm::WvContentDecryptionModule;
|
||||||
using android::Mutex;
|
using android::Mutex;
|
||||||
|
using android::sp;
|
||||||
|
using android::wp;
|
||||||
|
|
||||||
Mutex cdmLock;
|
Mutex cdmLock;
|
||||||
WvContentDecryptionModule* cdm = NULL;
|
// The strong pointers that keep this object alive live in the plugin objects.
|
||||||
|
// If all the plugins are deleted, the CDM will be deleted, and subsequent
|
||||||
|
// invocations of this code will construct a new CDM.
|
||||||
|
wp<WvContentDecryptionModule> sCdm;
|
||||||
|
|
||||||
WvContentDecryptionModule* getCDM() {
|
sp<WvContentDecryptionModule> getCDM() {
|
||||||
Mutex::Autolock lock(cdmLock);
|
Mutex::Autolock lock(cdmLock); // This function is a critical section.
|
||||||
|
|
||||||
|
sp<WvContentDecryptionModule> cdm = sCdm.promote();
|
||||||
|
|
||||||
if (cdm == NULL) {
|
if (cdm == NULL) {
|
||||||
ALOGD("Instantiating CDM.");
|
ALOGD("Instantiating CDM.");
|
||||||
cdm = new WvContentDecryptionModule();
|
cdm = new WvContentDecryptionModule();
|
||||||
|
sCdm = cdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdm;
|
return cdm;
|
||||||
|
|||||||
Reference in New Issue
Block a user