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

Commit ebfd3230 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix crash when seeking fragmented mp4 files

Rewinding a fragmented mp4 file without a segment index (sidx)
after playing it to the end would crash.
b/13028840

Change-Id: I280e74364589f0acefd432a59f85a6594c009a21
parent 1ebd04b5
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -3724,6 +3724,14 @@ status_t MPEG4Source::fragmentedRead(
            mCurrentSampleIndex = 0;
            parseChunk(&totalOffset);
            mCurrentTime = totalTime * mTimescale / 1000000ll;
        } else {
            // without sidx boxes, we can only seek to 0
            mCurrentMoofOffset = mFirstMoofOffset;
            mCurrentSamples.clear();
            mCurrentSampleIndex = 0;
            off64_t tmp = mCurrentMoofOffset;
            parseChunk(&tmp);
            mCurrentTime = 0;
        }

        if (mBuffer != NULL) {
@@ -3744,8 +3752,7 @@ status_t MPEG4Source::fragmentedRead(

        if (mCurrentSampleIndex >= mCurrentSamples.size()) {
            // move to next fragment
            Sample lastSample = mCurrentSamples[mCurrentSamples.size() - 1];
            off64_t nextMoof = mNextMoofOffset; // lastSample.offset + lastSample.size;
            off64_t nextMoof = mNextMoofOffset;
            mCurrentMoofOffset = nextMoof;
            mCurrentSamples.clear();
            mCurrentSampleIndex = 0;