Loading media/libstagefright/WVMExtractor.cpp +23 −13 Original line number Diff line number Diff line Loading @@ -33,26 +33,25 @@ #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 { static Mutex gWVMutex; Mutex WVMExtractor::sMutex; uint32_t WVMExtractor::sActiveExtractors = 0; void *WVMExtractor::sVendorLibHandle = NULL; WVMExtractor::WVMExtractor(const sp<DataSource> &source) : mDataSource(source) { { Mutex::Autolock autoLock(gWVMutex); if (gVendorLibHandle == NULL) { gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); Mutex::Autolock autoLock(sMutex); if (sVendorLibHandle == NULL) { CHECK(sActiveExtractors == 0); sVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); } if (gVendorLibHandle == NULL) { sActiveExtractors++; if (sVendorLibHandle == NULL) { LOGE("Failed to open libwvm.so"); return; } Loading @@ -60,7 +59,7 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source) typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>); GetInstanceFunc getInstanceFunc = (GetInstanceFunc) dlsym(gVendorLibHandle, (GetInstanceFunc) dlsym(sVendorLibHandle, "_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE"); if (getInstanceFunc) { Loading @@ -72,6 +71,17 @@ 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() { Loading media/libstagefright/include/WVMExtractor.h +5 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define WVM_EXTRACTOR_H_ #include <media/stagefright/DataSource.h> #include <media/stagefright/MediaExtractor.h> #include <utils/Errors.h> Loading Loading @@ -67,6 +68,10 @@ private: WVMExtractor(const WVMExtractor &); WVMExtractor &operator=(const WVMExtractor &); static Mutex sMutex; static uint32_t sActiveExtractors; static void *sVendorLibHandle; }; } // namespace android Loading Loading
media/libstagefright/WVMExtractor.cpp +23 −13 Original line number Diff line number Diff line Loading @@ -33,26 +33,25 @@ #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 { static Mutex gWVMutex; Mutex WVMExtractor::sMutex; uint32_t WVMExtractor::sActiveExtractors = 0; void *WVMExtractor::sVendorLibHandle = NULL; WVMExtractor::WVMExtractor(const sp<DataSource> &source) : mDataSource(source) { { Mutex::Autolock autoLock(gWVMutex); if (gVendorLibHandle == NULL) { gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); Mutex::Autolock autoLock(sMutex); if (sVendorLibHandle == NULL) { CHECK(sActiveExtractors == 0); sVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); } if (gVendorLibHandle == NULL) { sActiveExtractors++; if (sVendorLibHandle == NULL) { LOGE("Failed to open libwvm.so"); return; } Loading @@ -60,7 +59,7 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source) typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>); GetInstanceFunc getInstanceFunc = (GetInstanceFunc) dlsym(gVendorLibHandle, (GetInstanceFunc) dlsym(sVendorLibHandle, "_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE"); if (getInstanceFunc) { Loading @@ -72,6 +71,17 @@ 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() { Loading
media/libstagefright/include/WVMExtractor.h +5 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define WVM_EXTRACTOR_H_ #include <media/stagefright/DataSource.h> #include <media/stagefright/MediaExtractor.h> #include <utils/Errors.h> Loading Loading @@ -67,6 +68,10 @@ private: WVMExtractor(const WVMExtractor &); WVMExtractor &operator=(const WVMExtractor &); static Mutex sMutex; static uint32_t sActiveExtractors; static void *sVendorLibHandle; }; } // namespace android Loading