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

Commit e2cc5db8 authored by Wonsik Kim's avatar Wonsik Kim Committed by Android Git Automerger
Browse files

am 6961db7e: am 04bbef0b: am 5c09132b: Merge "DO NOT MERGE NuCachedSource2:...

am 6961db7e: am 04bbef0b: am 5c09132b: Merge "DO NOT MERGE NuCachedSource2: fix possible erroneous early free" into lmp-dev

* commit '6961db7e':
  DO NOT MERGE NuCachedSource2: fix possible erroneous early free
parents 93c38623 6961db7e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2283,11 +2283,11 @@ status_t AwesomePlayer::finishSetDataSource_l() {
            // The widevine extractor does its own caching.

#if 0
            mCachedSource = new NuCachedSource2(
            mCachedSource = NuCachedSource2::Create(
                    new ThrottledSource(
                        mConnectingDataSource, 50 * 1024 /* bytes/sec */));
#else
            mCachedSource = new NuCachedSource2(
            mCachedSource = NuCachedSource2::Create(
                    mConnectingDataSource,
                    cacheConfig.isEmpty() ? NULL : cacheConfig.string(),
                    disconnectAtHighwatermark);
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ sp<DataSource> DataSource::CreateFromURI(
                *contentType = httpSource->getMIMEType();
            }

            source = new NuCachedSource2(
            source = NuCachedSource2::Create(
                    httpSource,
                    cacheConfig.isEmpty() ? NULL : cacheConfig.string(),
                    disconnectAtHighwatermark);
+12 −3
Original line number Diff line number Diff line
@@ -224,9 +224,6 @@ NuCachedSource2::NuCachedSource2(
    // So whenever we call DataSource::readAt it may end up in a call to
    // IMediaHTTPConnection::readAt and therefore call back into JAVA.
    mLooper->start(false /* runOnCallingThread */, true /* canCallJava */);

    Mutex::Autolock autoLock(mLock);
    (new AMessage(kWhatFetchMore, mReflector->id()))->post();
}

NuCachedSource2::~NuCachedSource2() {
@@ -237,6 +234,18 @@ NuCachedSource2::~NuCachedSource2() {
    mCache = NULL;
}

// static
sp<NuCachedSource2> NuCachedSource2::Create(
        const sp<DataSource> &source,
        const char *cacheConfig,
        bool disconnectAtHighwatermark) {
    sp<NuCachedSource2> instance = new NuCachedSource2(
            source, cacheConfig, disconnectAtHighwatermark);
    Mutex::Autolock autoLock(instance->mLock);
    (new AMessage(kWhatFetchMore, instance->mReflector->id()))->post();
    return instance;
}

status_t NuCachedSource2::getEstimatedBandwidthKbps(int32_t *kbps) {
    if (mSource->flags() & kIsHTTPBasedSource) {
        HTTPBase* source = static_cast<HTTPBase *>(mSource.get());
+6 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ struct ALooper;
struct PageCache;

struct NuCachedSource2 : public DataSource {
    NuCachedSource2(
    static sp<NuCachedSource2> Create(
            const sp<DataSource> &source,
            const char *cacheConfig = NULL,
            bool disconnectAtHighwatermark = false);
@@ -72,6 +72,11 @@ protected:
private:
    friend struct AHandlerReflector<NuCachedSource2>;

    NuCachedSource2(
            const sp<DataSource> &source,
            const char *cacheConfig,
            bool disconnectAtHighwatermark);

    enum {
        kPageSize                       = 65536,
        kDefaultHighWaterThreshold      = 20 * 1024 * 1024,