Bug 1345898: P2. Flush rather than drain decoder. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 30 May 2017 00:30:54 +0200
changeset 586314 ece574cc476677dfe822b722d56e61c9de7e105f
parent 586313 1c9d2131b80ed952af127029cac58fe171378f8a
child 586315 af918786921ae5583313e82d1c80d853cb7ecca8
push id61365
push userbmo:jyavenard@mozilla.com
push dateTue, 30 May 2017 07:37:44 +0000
reviewersgerald
bugs1345898
milestone55.0a1
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
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -2015,17 +2015,18 @@ MediaFormatReader::HandleDemuxedSamples(
     RefPtr<MediaRawData> sample = decoder.mQueuedSamples[0];
     RefPtr<TrackInfoSharedPtr> info = sample->mTrackInfo;
 
     if (info && decoder.mLastStreamSourceID != info->GetID()) {
       bool recyclable = MediaPrefs::MediaDecoderCheckRecycling()
                         && 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());
         decoder.RequestDrain();
         decoder.mNextStreamSourceID = Some(info->GetID());
         ScheduleUpdate(aTrack);
         return;
       }
@@ -2189,26 +2190,16 @@ MediaFormatReader::Update(TrackType aTra
     return;
   }
 
   if (aTrack == TrackType::kVideoTrack && mSkipRequest.Exists()) {
     LOGV("Skipping in progress, nothing more to do");
     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;
   }
 
   if (decoder.mSeekRequest.Exists()) {
     LOGV("Seeking hasn't completed, nothing more to do");
     return;