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

Commit 27b71aa7 authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "NuPlayer:seek handling on kWhatAudioTearDown" into mnc-dev

parents d24b430c 1a5c8590
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ NuPlayer::NuPlayer(pid_t pid)
      mAudioDecoderGeneration(0),
      mVideoDecoderGeneration(0),
      mRendererGeneration(0),
      mPreviousSeekTimeUs(0),
      mAudioEOS(false),
      mVideoEOS(false),
      mScanSourcesPending(false),
@@ -1114,7 +1115,9 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                }

                int64_t positionUs;
                CHECK(msg->findInt64("positionUs", &positionUs));
                if (!msg->findInt64("positionUs", &positionUs)) {
                    positionUs = mPreviousSeekTimeUs;
                }
                performSeek(positionUs);

                if (reason == Renderer::kDueToError && needsToCreateAudioDecoder) {
@@ -1857,6 +1860,7 @@ void NuPlayer::performSeek(int64_t seekTimeUs) {
                mAudioDecoder.get(), mVideoDecoder.get());
        return;
    }
    mPreviousSeekTimeUs = seekTimeUs;
    mSource->seekTo(seekTimeUs);
    ++mTimedTextGeneration;

+2 −0
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ private:
    int32_t mVideoDecoderGeneration;
    int32_t mRendererGeneration;

    int64_t mPreviousSeekTimeUs;

    List<sp<Action> > mDeferredActions;

    bool mAudioEOS;
+3 −4
Original line number Diff line number Diff line
@@ -1586,16 +1586,15 @@ void NuPlayer::Renderer::onAudioTearDown(AudioTearDownReason reason) {
    mAudioTornDown = true;

    int64_t currentPositionUs;
    if (getCurrentPosition(&currentPositionUs) != OK) {
        currentPositionUs = 0;
    sp<AMessage> notify = mNotify->dup();
    if (getCurrentPosition(&currentPositionUs) == OK) {
        notify->setInt64("positionUs", currentPositionUs);
    }

    mAudioSink->stop();
    mAudioSink->flush();

    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", kWhatAudioTearDown);
    notify->setInt64("positionUs", currentPositionUs);
    notify->setInt32("reason", reason);
    notify->post();
}