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

Commit 97de37de authored by Wang Liyong's avatar Wang Liyong Committed by Steve Kondik
Browse files

Fix for getPosition after seek

When starting playback with a seek pending
(calling seek before start) there is a brief period
when the audioplayer returns an incorrect position (zero)

This is caused by that mSeeking is set to false
before the position in the audioplayer actually is updated.

Change-Id: Iaec355c8fdfe589d9b826d20c2531034f2b4e6fb
parent f4a117ec
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
    MediaSource::ReadOptions options;
    if (mSeeking) {
        options.setSeekTo(mSeekTimeUs);
        mSeeking = false;
    }

    do {
@@ -126,8 +125,25 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
        CHECK(mFirstBuffer == NULL);
        mFirstBufferResult = OK;
        mIsFirstBuffer = false;

        if (mSeeking) {
            mPositionTimeRealUs = 0;
            mPositionTimeMediaUs = mSeekTimeUs;
            mSeeking = false;
        }

    } else {
        mIsFirstBuffer = true;

        if (mSeeking) {
            mPositionTimeRealUs = 0;
            if (mFirstBuffer == NULL || !mFirstBuffer->meta_data()->findInt64(
                    kKeyTime, &mPositionTimeMediaUs)) {
                return UNKNOWN_ERROR;
            }
            mSeeking = false;
        }

    }

    sp<MetaData> format = mSource->getFormat();