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

Commit 0db13083 authored by Marco Nelissen's avatar Marco Nelissen Committed by Automerger Merge Worker
Browse files

Merge "Fix race condition in IMediaSource" into rvc-dev am: 789d4e90

Change-Id: I1692d294e214afbdbb7804ff6dd86b02ca2d8b47
parents 8da7171f 789d4e90
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public:
        data.writeInterfaceToken(BpMediaSource::getInterfaceDescriptor());
        status_t ret = remote()->transact(GETFORMAT, data, &reply);
        if (ret == NO_ERROR) {
            AutoMutex _l(mLock);
            AutoMutex _l(mBpLock);
            mMetaData = MetaData::createFromParcel(reply);
            return mMetaData;
        }
@@ -224,7 +224,7 @@ private:
    // XXX: could we use this for caching, or does metadata change on the fly?
    sp<MetaData> mMetaData;
    // ensure synchronize access to mMetaData
    Mutex mLock;
    Mutex mBpLock;

    // Cache all IMemory objects received from MediaExtractor.
    // We gc IMemory objects that are no longer active (referenced by a MediaBuffer).
@@ -301,6 +301,7 @@ status_t BnMediaSource::onTransact(
            CHECK_INTERFACE(IMediaSource, data, reply);
            mGroup->signalBufferReturned(nullptr);
            status_t status = stop();
            AutoMutex _l(mBnLock);
            mIndexCache.reset();
            mBuffersSinceStop = 0;
            return status;
@@ -340,6 +341,7 @@ status_t BnMediaSource::onTransact(
                    && len == sizeof(opts)
                    && data.read((void *)&opts, len) == NO_ERROR;

            AutoMutex _l(mBnLock);
            mGroup->signalBufferReturned(nullptr);
            mIndexCache.gc();
            size_t inlineTransferSize = 0;
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ protected:

private:
    uint32_t mBuffersSinceStop; // Buffer tracking variable
    Mutex mBnLock; // to guard readMultiple against concurrent access to the buffer cache

    std::unique_ptr<MediaBufferGroup> mGroup;