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
--- 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;