Bug 1277508: P2. Add HasPendingDrain convenience method. r?kamidphish
MozReview-Commit-ID: Lcij7sc2y9d
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -745,17 +745,17 @@ bool
MediaFormatReader::NeedInput(DecoderData& aDecoder)
{
// We try to keep a few more compressed samples input than decoded samples
// have been output, provided the state machine has requested we send it a
// decoded sample. To account for H.264 streams which may require a longer
// run of input than we input, decoders fire an "input exhausted" callback,
// which overrides our "few more samples" threshold.
return
- !(aDecoder.mDraining || aDecoder.mDrainComplete) &&
+ !aDecoder.HasPendingDrain() &&
!aDecoder.HasFatalError() &&
aDecoder.mDecodingRequested &&
!aDecoder.mDemuxRequest.Exists() &&
!aDecoder.HasInternalSeekPending() &&
aDecoder.mOutput.Length() <= aDecoder.mDecodeAhead &&
(aDecoder.mInputExhausted || !aDecoder.mQueuedSamples.IsEmpty() ||
aDecoder.mTimeThreshold.isSome() ||
aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput <= aDecoder.mDecodeAhead);
@@ -808,17 +808,17 @@ MediaFormatReader::UpdateReceivedNewData
}
if (decoder.mDemuxRequest.Exists()) {
// We may have pending operations to process, so we want to continue
// after UpdateReceivedNewData returns.
return false;
}
- if (decoder.mDrainComplete || decoder.mDraining) {
+ if (decoder.HasPendingDrain()) {
// We do not want to clear mWaitingForData or mDemuxEOS while
// a drain is in progress in order to properly complete the operation.
return false;
}
bool hasLastEnd;
media::TimeUnit lastEnd = decoder.mTimeRanges.GetEnd(&hasLastEnd);
if (hasLastEnd) {
@@ -1200,18 +1200,17 @@ MediaFormatReader::Update(TrackType aTra
// Now that draining has completed, we check if we have received
// new data again as the result may now be different from the earlier
// run.
if (UpdateReceivedNewData(aTrack) || decoder.mSeekRequest.Exists()) {
LOGV("Nothing more to do");
return;
}
} else if (decoder.mDemuxEOS && !decoder.mNeedDraining &&
- !decoder.mDraining && !decoder.mDrainComplete &&
- decoder.mQueuedSamples.IsEmpty()) {
+ !decoder.HasPendingDrain() && decoder.mQueuedSamples.IsEmpty()) {
// It is possible to transition from WAITING_FOR_DATA directly to EOS
// state during the internal seek; in which case no draining would occur.
// There is no more samples left to be decoded and we are already in
// EOS state. We can immediately reject the data promise.
LOG("Rejecting %s promise: EOS", TrackTypeToStr(aTrack));
decoder.RejectPromise(END_OF_STREAM, __func__);
}
}
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -306,16 +306,21 @@ private:
// rejected or prior a seek operation.
bool mDecodingRequested;
bool mOutputRequested;
bool mInputExhausted;
bool mNeedDraining;
bool mDraining;
bool mDrainComplete;
+ bool HasPendingDrain() const
+ {
+ return mDraining || mDrainComplete;
+ }
+
uint32_t mNumOfConsecutiveError;
uint32_t mMaxConsecutiveError;
Maybe<MediaDataDecoderError> mError;
bool HasFatalError() const
{
return mError.isSome() && mError.ref() == MediaDataDecoderError::FATAL_ERROR;
}