summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/WVMExtractor.cpp
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2011-07-01 07:13:42 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-01 07:13:42 -0700
commite301545a292987b6f7f3b316003eb8b76e3a5e2e (patch)
tree13a39a80c67625240791eab94842dcdc662c63fe /media/libstagefright/WVMExtractor.cpp
parent50255a92dfb2ffd35955035ae9ac9d4b85f606b8 (diff)
downloadframeworks_av-e301545a292987b6f7f3b316003eb8b76e3a5e2e.zip
frameworks_av-e301545a292987b6f7f3b316003eb8b76e3a5e2e.tar.gz
frameworks_av-e301545a292987b6f7f3b316003eb8b76e3a5e2e.tar.bz2
Revert "Fix for b/4165024: Serious Memory leak when playing a WV protected streaming video."
This reverts commit d63d947d406977c7c307f69369908b4342c98ef3
Diffstat (limited to 'media/libstagefright/WVMExtractor.cpp')
-rw-r--r--media/libstagefright/WVMExtractor.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index 7072d58..26eda0c 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -33,25 +33,26 @@
#include <utils/Errors.h>
+/* The extractor lifetime is short - just long enough to get
+ * the media sources constructed - so the shared lib needs to remain open
+ * beyond the lifetime of the extractor. So keep the handle as a global
+ * rather than a member of the extractor
+ */
+void *gVendorLibHandle = NULL;
+
namespace android {
-Mutex WVMExtractor::sMutex;
-uint32_t WVMExtractor::sActiveExtractors = 0;
-void *WVMExtractor::sVendorLibHandle = NULL;
+static Mutex gWVMutex;
WVMExtractor::WVMExtractor(const sp<DataSource> &source)
: mDataSource(source) {
{
- Mutex::Autolock autoLock(sMutex);
-
- if (sVendorLibHandle == NULL) {
- CHECK(sActiveExtractors == 0);
- sVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
+ Mutex::Autolock autoLock(gWVMutex);
+ if (gVendorLibHandle == NULL) {
+ gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
}
- sActiveExtractors++;
-
- if (sVendorLibHandle == NULL) {
+ if (gVendorLibHandle == NULL) {
LOGE("Failed to open libwvm.so");
return;
}
@@ -59,7 +60,7 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
GetInstanceFunc getInstanceFunc =
- (GetInstanceFunc) dlsym(sVendorLibHandle,
+ (GetInstanceFunc) dlsym(gVendorLibHandle,
"_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE");
if (getInstanceFunc) {
@@ -71,17 +72,6 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
}
WVMExtractor::~WVMExtractor() {
- Mutex::Autolock autoLock(sMutex);
-
- CHECK(sActiveExtractors > 0);
- sActiveExtractors--;
-
- // Close lib after last use
- if (sActiveExtractors == 0) {
- if (sVendorLibHandle != NULL)
- dlclose(sVendorLibHandle);
- sVendorLibHandle = NULL;
- }
}
size_t WVMExtractor::countTracks() {