Fix decoder instantiation during playback
When a decoder is created while another decoder
is in use and the two decoders share a common
crypto instance, decryption results would become
indeterminate, which could cause the decoder to
hang. This change adds a notification to the
crypto instance so it can update state when its
ownership changes.
bug: 36209723
Test: playbacktests-debug-androidTest.apk as
described in the bug.
Change-Id: I453c260eace5543dd79a3569bf6a9592394c4113
diff --git a/media/libmedia/include/CryptoHal.h b/media/libmedia/include/CryptoHal.h
index 28ade20..d6214c2 100644
--- a/media/libmedia/include/CryptoHal.h
+++ b/media/libmedia/include/CryptoHal.h
@@ -60,6 +60,9 @@
const ICrypto::DestinationBuffer &destination,
AString *errorDetailMsg);
+ virtual void setHeap(const sp<IMemoryHeap>& heap) { setHeapBase(heap); }
+ virtual void unsetHeap(const sp<IMemoryHeap>& heap) { clearHeapBase(heap); }
+
private:
mutable Mutex mLock;
@@ -82,6 +85,7 @@
const uint8_t uuid[16], const void *initData, size_t size);
void setHeapBase(const sp<IMemoryHeap>& heap);
+ void clearHeapBase(const sp<IMemoryHeap>& heap);
status_t toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer);