summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrav90 <travawine@protonmail.com>2017-05-14 04:51:26 -0500
committertrav90 <travawine@protonmail.com>2017-05-14 04:51:26 -0500
commitcc0200827eca72c9f815ddfde0b6bc3f1156b280 (patch)
treec5738c08f9b81b8f6172e406f1e83a5b19777a02
parent10874c611282a1d203e5dc7e466d16e7853529dc (diff)
downloadpalemoon-gre-cc0200827eca72c9f815ddfde0b6bc3f1156b280.tar.gz
Wait until current drain completes before decoding new data
-rw-r--r--dom/media/MediaFormatReader.cpp11
-rw-r--r--dom/media/MediaFormatReader.h3
2 files changed, 11 insertions, 3 deletions
diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp
index e6dbf27ce..3dadf051e 100644
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -478,7 +478,8 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
MOZ_ASSERT(OnTaskQueue());
MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(), "No sample requests allowed while seeking");
MOZ_DIAGNOSTIC_ASSERT(!mVideo.HasPromise(), "No duplicate sample requests");
- MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists());
+ MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists() ||
+ mVideo.mTimeThreshold.isSome());
MOZ_DIAGNOSTIC_ASSERT(!mSkipRequest.Exists(), "called mid-skipping");
MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek");
LOGV("RequestVideoData(%d, %lld)", aSkipToNextKeyframe, aTimeThreshold);
@@ -574,7 +575,8 @@ MediaFormatReader::RequestAudioData()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(), "No sample requests allowed while seeking");
- MOZ_DIAGNOSTIC_ASSERT(!mAudio.mSeekRequest.Exists());
+ MOZ_DIAGNOSTIC_ASSERT(!mAudio.mSeekRequest.Exists() ||
+ mAudio.mTimeThreshold.isSome());
MOZ_DIAGNOSTIC_ASSERT(!mAudio.HasPromise(), "No duplicate sample requests");
MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek");
LOGV("");
@@ -700,6 +702,7 @@ MediaFormatReader::NeedInput(DecoderData& aDecoder)
// run of input than we input, decoders fire an "input exhausted" callback,
// which overrides our "few more samples" threshold.
return
+ !aDecoder.mDraining &&
!aDecoder.mError &&
aDecoder.HasPromise() &&
!aDecoder.mDemuxRequest.Exists() &&
@@ -908,12 +911,13 @@ MediaFormatReader::DrainDecoder(TrackType aTrack)
MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack);
- if (!decoder.mNeedDraining) {
+ if (!decoder.mNeedDraining || decoder.mDraining) {
return;
}
decoder.mOutputRequested = true;
decoder.mDecoder->Drain();
decoder.mNeedDraining = false;
+ decoder.mDraining = true;
LOG("Requesting %s decoder to drain", TrackTypeToStr(aTrack));
}
@@ -971,6 +975,7 @@ MediaFormatReader::Update(TrackType aTrack)
}
} else if (decoder.mDrainComplete) {
decoder.mDrainComplete = false;
+ decoder.mDraining = false;
if (decoder.mError) {
LOG("Decoding Error");
decoder.RejectPromise(DECODE_ERROR, __func__);
diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h
index 9e607c5a5..fc782a2d9 100644
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -210,6 +210,7 @@ private:
, mInputExhausted(false)
, mError(false)
, mNeedDraining(false)
+ , mDraining(false)
, mDrainComplete(false)
, mNumSamplesInput(0)
, mNumSamplesOutput(0)
@@ -258,6 +259,7 @@ private:
bool mInputExhausted;
bool mError;
bool mNeedDraining;
+ bool mDraining;
bool mDrainComplete;
// If set, all decoded samples prior mTimeThreshold will be dropped.
// Used for internal seeking when a change of stream is detected.
@@ -293,6 +295,7 @@ private:
mOutputRequested = false;
mInputExhausted = false;
mNeedDraining = false;
+ mDraining = false;
mDrainComplete = false;
mTimeThreshold.reset();
mOutput.Clear();