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