Commit 7ab2c15c authored by Aidan Wolter's avatar Aidan Wolter Committed by Commit Bot

Manually release MediaCrypto plugin

After the end of a stream, we now manually release the MediaCrypto
plugin, so that it can be cleaned up on the TZ-side. If this is not
done, then we risk the chance of GC not cleaning up before the TZ heap
overflows.

TEST=Switch HBO Go cast stream multiple times, and watch the TZ heap
BUG=b:69682820

Change-Id: I6fda96b74525533b64638d859cb79a4aa6375248
Reviewed-on: https://chromium-review.googlesource.com/790570
Commit-Queue: Aidan Wolter <awolter@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519911}
parent edd9c5a2
......@@ -453,6 +453,11 @@ class MediaCodecBridge {
Log.e(TAG, "Failed to queue secure input buffer, CryptoException with error code "
+ e.getErrorCode());
return MediaCodecStatus.ERROR;
} catch (IllegalArgumentException e) {
// IllegalArgumentException can occur when release() is called on the MediaCrypto
// object, but the MediaCodecBridge is unaware of the change.
Log.e(TAG, "Failed to queue secure input buffer, IllegalArgumentException " + e);
return MediaCodecStatus.ERROR;
} catch (IllegalStateException e) {
Log.e(TAG, "Failed to queue secure input buffer, IllegalStateException " + e);
return MediaCodecStatus.ERROR;
......
......@@ -74,6 +74,7 @@ public class MediaDrmBridge {
private static final byte[] UNPROVISION = "unprovision".getBytes();
private MediaDrm mMediaDrm;
private MediaCrypto mMediaCrypto;
private long mNativeMediaDrmBridge;
private UUID mSchemeUUID;
......@@ -306,9 +307,9 @@ public class MediaDrmBridge {
// Create MediaCrypto object.
try {
if (MediaCrypto.isCryptoSchemeSupported(mSchemeUUID)) {
MediaCrypto mediaCrypto = new MediaCrypto(mSchemeUUID, mMediaCryptoSession.drmId());
mMediaCrypto = new MediaCrypto(mSchemeUUID, mMediaCryptoSession.drmId());
Log.d(TAG, "MediaCrypto successfully created!");
onMediaCryptoReady(mediaCrypto);
onMediaCryptoReady(mMediaCrypto);
return true;
} else {
Log.e(TAG, "Cannot create MediaCrypto for unsupported scheme.");
......@@ -601,6 +602,11 @@ public class MediaDrmBridge {
mMediaDrm.release();
mMediaDrm = null;
}
if (mMediaCrypto != null) {
mMediaCrypto.release();
mMediaCrypto = null;
}
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment