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

Commit 2d4d919e authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Do not hold onto the master lock while reading data from the...

Merge "Do not hold onto the master lock while reading data from the datasource. This would prevent consumers from reading cached data immediately if it is available."
parents 6c1ddedf fc22d932
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -308,21 +308,26 @@ bool PrefetchedSource::getCacheDurationUs(int64_t *durationUs) {
}

void PrefetchedSource::cacheMore() {
    MediaSource::ReadOptions options;

    {
        Mutex::Autolock autoLock(mLock);

        if (!mStarted) {
            return;
        }

    MediaBuffer *buffer;
    MediaSource::ReadOptions options;
        if (mSeekTimeUs >= 0) {
            options.setSeekTo(mSeekTimeUs);
            mSeekTimeUs = -1;
        }
    }

    MediaBuffer *buffer;
    status_t err = mSource->read(&buffer, &options);

    Mutex::Autolock autoLock(mLock);

    if (err != OK) {
        mReachedEOS = true;
        mCondition.signal();