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

Commit 9f8e0153 authored by Gloria Wang's avatar Gloria Wang Committed by Android (Google) Code Review
Browse files

Merge "Re-calculate mCurrentTimeUs for MP3 CBR seek because we might have...

Merge "Re-calculate mCurrentTimeUs for MP3 CBR seek because we might have called Resync() which changes mCurrentPos. For bug 4869063."
parents ba5ddf5c 7ffa1ea8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -407,6 +407,8 @@ status_t MP3Source::read(

    int64_t seekTimeUs;
    ReadOptions::SeekMode mode;
    bool seekCBR = false;

    if (options != NULL && options->getSeekTo(&seekTimeUs, &mode)) {
        int64_t actualSeekTimeUs = seekTimeUs;
        if (mSeeker == NULL
@@ -421,6 +423,7 @@ status_t MP3Source::read(

            mCurrentTimeUs = seekTimeUs;
            mCurrentPos = mFirstFramePos + seekTimeUs * bitrate / 8000000;
            seekCBR = true;
        } else {
            mCurrentTimeUs = actualSeekTimeUs;
        }
@@ -454,6 +457,13 @@ status_t MP3Source::read(
            && GetMPEGAudioFrameSize(
                header, &frame_size, &sample_rate, NULL,
                &bitrate, &num_samples)) {

            // re-calculate mCurrentTimeUs because we might have called Resync()
            if (seekCBR) {
                mCurrentTimeUs = (mCurrentPos - mFirstFramePos) * 8000 / bitrate;
                mBasisTimeUs = mCurrentTimeUs;
            }

            break;
        }