Commit 1cfee54d authored by Jean-Yves Avenard's avatar Jean-Yves Avenard
Browse files

Bug 1345898: P2. Flush rather than drain decoder. r=gerald

When encountering a change of stream ID while performing an internal seek to resume from the last playback position (following WAITING_FOR_DATA), we may as well perform a flush rather than a drain as the decoded data won't be used anyway.

MozReview-Commit-ID: E7wgTndTThs

--HG--
extra : rebase_source : 87f069515462276c4d80d3f49f9f0a0b3dffe5f0
parent 39bffaa8
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -2020,7 +2020,8 @@ MediaFormatReader::HandleDemuxedSamples(
                        && decoder.mDecoder->SupportDecoderRecycling();
      if (!recyclable
          && (decoder.mNextStreamSourceID.isNothing()
              || decoder.mNextStreamSourceID.ref() != info->GetID())) {
              || decoder.mNextStreamSourceID.ref() != info->GetID())
          && !decoder.HasWaitingPromise()) {
        LOG("%s stream id has changed from:%d to:%d, draining decoder.",
          TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
          info->GetID());
@@ -2194,16 +2195,6 @@ MediaFormatReader::Update(TrackType aTrack)
    return;
  }

  if (decoder.HasWaitingPromise() && decoder.HasCompletedDrain()) {
    // This situation will occur when a change of stream ID occurred during
    // internal seeking following a gap encountered in the data, a drain was
    // requested and has now completed. We need to complete the draining process
    // so that the new data can be processed.
    // We can complete the draining operation now as we have no pending
    // operation when a waiting promise is pending.
    decoder.mDrainState = DrainState::None;
  }

  if (UpdateReceivedNewData(aTrack)) {
    LOGV("Nothing more to do");
    return;