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

Commit 76b704e3 authored by Robert Shih's avatar Robert Shih Committed by Android Git Automerger
Browse files

am f3eb8268: DO NOT MERGE: Protect data source access with mutex during disconnect

* commit 'f3eb8268':
  DO NOT MERGE: Protect data source access with mutex during disconnect
parents b18c0276 f3eb8268
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -374,9 +374,17 @@ void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) {
        mMetaDataSize = -1ll;
        mContentType = "";
        mSniffedMIME = "";
        {
            sp<DataSource> dataSource = mDataSource;
            sp<NuCachedSource2> cachedSource = mCachedSource;
            sp<DataSource> httpSource = mHttpSource;
            {
                Mutex::Autolock _l(mDisconnectLock);
                mDataSource.clear();
                mCachedSource.clear();
                mHttpSource.clear();
            }
        }

        cancelPollBuffering();
    }
@@ -498,13 +506,20 @@ void NuPlayer::GenericSource::resume() {
}

void NuPlayer::GenericSource::disconnect() {
    if (mDataSource != NULL) {
    sp<DataSource> dataSource, httpSource;
    {
        Mutex::Autolock _l(mDisconnectLock);
        dataSource = mDataSource;
        httpSource = mHttpSource;
    }

    if (dataSource != NULL) {
        // disconnect data source
        if (mDataSource->flags() & DataSource::kIsCachingDataSource) {
            static_cast<NuCachedSource2 *>(mDataSource.get())->disconnect();
        if (dataSource->flags() & DataSource::kIsCachingDataSource) {
            static_cast<NuCachedSource2 *>(dataSource.get())->disconnect();
        }
    } else if (mHttpSource != NULL) {
        static_cast<HTTPBase *>(mHttpSource.get())->disconnect();
    } else if (httpSource != NULL) {
        static_cast<HTTPBase *>(httpSource.get())->disconnect();
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ private:
    int32_t mPollBufferingGeneration;
    uint32_t mPendingReadBufferTypes;
    mutable Mutex mReadBufferLock;
    mutable Mutex mDisconnectLock;

    sp<ALooper> mLooper;