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

Commit d979fe0b authored by Lajos Molnar's avatar Lajos Molnar Committed by The Android Automerger
Browse files

stagefright: handle seeking to before first cue-point.

Bug: 16446994
Change-Id: Id3f9d6780a7c4f62171cbfa8675a67334e8dfa10
parent ad6fa219
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -320,22 +320,26 @@ status_t MyVorbisExtractor::seekToTime(int64_t timeUs) {
    }

    size_t left = 0;
    size_t right = mTableOfContents.size() - 1;
    while (left <= right) {
        size_t center = left + (right - left) / 2;
    size_t right_plus_one = mTableOfContents.size();
    while (left < right_plus_one) {
        size_t center = left + (right_plus_one - left) / 2;

        const TOCEntry &entry = mTableOfContents.itemAt(center);

        if (timeUs < entry.mTimeUs) {
            right = center - 1;
            right_plus_one = center;
        } else if (timeUs > entry.mTimeUs) {
            left = center + 1;
        } else {
            left = right = center;
            left = center;
            break;
        }
    }

    if (left == mTableOfContents.size()) {
        --left;
    }

    const TOCEntry &entry = mTableOfContents.itemAt(left);

    ALOGV("seeking to entry %zu / %zu at offset %lld",
+8 −8
Original line number Diff line number Diff line
@@ -525,14 +525,14 @@ status_t SampleTable::findSampleAtTime(
    buildSampleEntriesTable();

    uint32_t left = 0;
    uint32_t right = mNumSampleSizes - 1;
    while (left <= right) {
        uint32_t center = left + (right - left) / 2;
    uint32_t right_plus_one = mNumSampleSizes;
    while (left < right_plus_one) {
        uint32_t center = left + (right_plus_one - left) / 2;
        uint64_t centerTime =
            getSampleTime(center, scale_num, scale_den);

        if (req_time < centerTime) {
            right = center - 1;
            right_plus_one = center;
        } else if (req_time > centerTime) {
            left = center + 1;
        } else {
@@ -607,13 +607,13 @@ status_t SampleTable::findSyncSampleNear(
    }

    uint32_t left = 0;
    uint32_t right = mNumSyncSamples - 1;
    while (left <= right) {
        uint32_t center = left + (right - left) / 2;
    uint32_t right_plus_one = mNumSyncSamples;
    while (left < right_plus_one) {
        uint32_t center = left + (right_plus_one - left) / 2;
        uint32_t x = mSyncSamples[center];

        if (start_sample_index < x) {
            right = center - 1;
            right_plus_one = center;
        } else if (start_sample_index > x) {
            left = center + 1;
        } else {