Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3edf4509 authored by Edwin Wong's avatar Edwin Wong Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fix for b/4165024: Serious Memory leak when playing a WV...

Merge "Revert "Fix for b/4165024: Serious Memory leak when playing a WV protected streaming video.""
parents ab23dc04 e301545a
Loading
Loading
Loading
Loading
+13 −23
Original line number Original line Diff line number Diff line
@@ -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;
        }
        }
@@ -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) {
@@ -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() {
+0 −5
Original line number Original line Diff line number Diff line
@@ -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>


@@ -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