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

Commit fc22d932 authored by Andreas Huber's avatar Andreas Huber
Browse files

Do not hold onto the master lock while reading data from the datasource. This...

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.

related-to-bug: 2295438
parent 1b624fa1
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();