Delete Singleton on Library Unload

(This is a merge of http://go/wvgerrit/14531)

As an optimization, the Media Server now unloads our library when not
in use. This has exposed a bug by which we were never deleting the CDM
singleton. Fix is to make WvContentDecryptionModule an Android smart
pointer ref base and then make sure all the plugins store a strong
pointer to it. The singleton is a weak pointer, so when the last
plugin is cleaned up, the CDM will be as well. And on the off chance
that the library isn't immediately unloaded, the singleton code will
generate a new CDM next time one is needed.

Bug: 21153732
Change-Id: Ifaf02fa9afe0a70a8b53e8b92ee0a3d1359ca001
This commit is contained in:
John "Juce" Bruce
2015-06-03 15:57:00 -07:00
parent a54ae37ceb
commit a8328dd2f9
7 changed files with 25 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
#include "utils/KeyedVector.h"
#include "utils/List.h"
#include "utils/String8.h"
#include "utils/StrongPointer.h"
#include "utils/Vector.h"
#include "wv_cdm_event_listener.h"
#include "wv_content_decryption_module.h"
@@ -41,7 +42,7 @@ const OEMCrypto_Algorithm kInvalidCrytpoAlgorithm =
class WVDrmPlugin : public android::DrmPlugin,
public wvcdm::WvCdmEventListener {
public:
WVDrmPlugin(WvContentDecryptionModule* cdm,
WVDrmPlugin(const android::sp<wvcdm::WvContentDecryptionModule>& cdm,
WVGenericCryptoInterface* crypto);
virtual ~WVDrmPlugin();
@@ -248,7 +249,7 @@ class WVDrmPlugin : public android::DrmPlugin,
std::string mAppId;
} mPropertySet;
WvContentDecryptionModule* mCDM;
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
WVGenericCryptoInterface* mCrypto;
std::string mOrigin;
map<CdmSessionId, CryptoSession> mCryptoSessions;