summaryrefslogtreecommitdiffstats
path: root/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2018-09-05 11:05:48 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-09-05 11:05:48 -0700
commitebbcb99ca11fb09a39900da010f30e7ca8b7db30 (patch)
tree7e623681475d9a69770ad7d49700d96565767683 /drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
parentfeeda6ddb0bc57eddb2d4468dc478ab6ac5ef1cb (diff)
parentc927af1287e3b90d77e40aae26f4a3b61de3ac09 (diff)
downloadframeworks_av-ebbcb99ca11fb09a39900da010f30e7ca8b7db30.tar.gz
frameworks_av-ebbcb99ca11fb09a39900da010f30e7ca8b7db30.tar.bz2
frameworks_av-ebbcb99ca11fb09a39900da010f30e7ca8b7db30.zip
Fix race condition for cas sessions -- DO NOT MERGE
am: c927af1287 Change-Id: I1c84f2fd3d49a7e784b2b44d20453796d070df8d
Diffstat (limited to 'drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp')
-rw-r--r--drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp b/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
index 4ed5fce8ad..757219484c 100644
--- a/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
+++ b/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
@@ -118,9 +118,9 @@ status_t ClearKeyCasPlugin::openSession(CasSessionId* sessionId) {
status_t ClearKeyCasPlugin::closeSession(const CasSessionId &sessionId) {
ALOGV("closeSession: sessionId=%s", sessionIdToString(sessionId).string());
- sp<ClearKeyCasSession> session =
+ std::shared_ptr<ClearKeyCasSession> session =
ClearKeySessionLibrary::get()->findSession(sessionId);
- if (session == NULL) {
+ if (session.get() == nullptr) {
return ERROR_DRM_SESSION_NOT_OPENED;
}
@@ -132,9 +132,9 @@ status_t ClearKeyCasPlugin::setSessionPrivateData(
const CasSessionId &sessionId, const CasData & /*data*/) {
ALOGV("setSessionPrivateData: sessionId=%s",
sessionIdToString(sessionId).string());
- sp<ClearKeyCasSession> session =
+ std::shared_ptr<ClearKeyCasSession> session =
ClearKeySessionLibrary::get()->findSession(sessionId);
- if (session == NULL) {
+ if (session.get() == nullptr) {
return ERROR_DRM_SESSION_NOT_OPENED;
}
return OK;
@@ -143,9 +143,9 @@ status_t ClearKeyCasPlugin::setSessionPrivateData(
status_t ClearKeyCasPlugin::processEcm(
const CasSessionId &sessionId, const CasEcm& ecm) {
ALOGV("processEcm: sessionId=%s", sessionIdToString(sessionId).string());
- sp<ClearKeyCasSession> session =
+ std::shared_ptr<ClearKeyCasSession> session =
ClearKeySessionLibrary::get()->findSession(sessionId);
- if (session == NULL) {
+ if (session.get() == nullptr) {
return ERROR_DRM_SESSION_NOT_OPENED;
}
@@ -415,15 +415,15 @@ status_t ClearKeyDescramblerPlugin::setMediaCasSession(
const CasSessionId &sessionId) {
ALOGV("setMediaCasSession: sessionId=%s", sessionIdToString(sessionId).string());
- sp<ClearKeyCasSession> session =
+ std::shared_ptr<ClearKeyCasSession> session =
ClearKeySessionLibrary::get()->findSession(sessionId);
- if (session == NULL) {
+ if (session.get() == nullptr) {
ALOGE("ClearKeyDescramblerPlugin: session not found");
return ERROR_DRM_SESSION_NOT_OPENED;
}
- mCASSession = session;
+ std::atomic_store(&mCASSession, session);
return OK;
}
@@ -444,12 +444,14 @@ ssize_t ClearKeyDescramblerPlugin::descramble(
subSamplesToString(subSamples, numSubSamples).string(),
srcPtr, dstPtr, srcOffset, dstOffset);
- if (mCASSession == NULL) {
+ std::shared_ptr<ClearKeyCasSession> session = std::atomic_load(&mCASSession);
+
+ if (session.get() == nullptr) {
ALOGE("Uninitialized CAS session!");
return ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED;
}
- return mCASSession->decrypt(
+ return session->decrypt(
secure, scramblingControl,
numSubSamples, subSamples,
(uint8_t*)srcPtr + srcOffset,