Skip to content

Commit

Permalink
Merge branch 'jb51730' into 'master'
Browse files Browse the repository at this point in the history
[sailfishos][gecko] Buffer when the video decoder lags behind. Fixes JB#51730

See merge request mer-core/gecko-dev!194
  • Loading branch information
Andrew Branson committed Nov 24, 2020
2 parents a28558c + 6b6e6f7 commit e96fd36
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
@@ -0,0 +1,65 @@
From 65a5eb298c442386afe4de0b7ba03eb84f1f39f5 Tue, 24 Nov 2020 11:56:06 +0100
From: Andrew Branson <andrew.branson@jolla.com>
Date: Tue, 24 Nov 2020 11:55:44 +0100
Subject: [PATCH] [sailfishos][gecko] Buffer when the video decoder lags behind. Fixes JB#51730


MediaFormatReader assumes that decoders will only process one frame at a
time, so it won't provide the extra frames that droidmedia needs when
the stream switches to a higher resolution. For non-adaptive streams,
preroll will make sure there's already enough of a lag.

If we run out of decoded frames, then enter the buffering state even if
we're waiting for the decoder. Stay in that state until we have ample
frames again.

diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp
index 0d5556d..ae4f437 100644
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2207,7 +2207,8 @@

// Note we could have a wait promise pending when playing non-MSE EME.
if ((mMaster->OutOfDecodedAudio() && mMaster->IsWaitingAudioData()) ||
- (mMaster->OutOfDecodedVideo() && mMaster->IsWaitingVideoData())) {
+ mMaster->OutOfDecodedVideo()) {
+ // Can still buffer if the video codec doesn't have enough data
SetState<BufferingState>();
return;
}
@@ -2291,13 +2292,14 @@
// With buffering heuristics, we exit buffering state when we:
// 1. can play through or
// 2. time out (specified by mBufferingWait) or
- // 3. have enough buffered data.
+ // 3. have enough buffered data (allow a larger head start for video streams).
TimeDuration elapsed = now - mBufferingStart;
TimeDuration timeout =
TimeDuration::FromSeconds(mBufferingWait * mMaster->mPlaybackRate);
bool stopBuffering =
mMaster->mCanPlayThrough || elapsed >= timeout ||
- !mMaster->HasLowBufferedData(TimeUnit::FromSeconds(mBufferingWait));
+ (!mMaster->HasLowBufferedData(TimeUnit::FromSeconds(mBufferingWait)) && !mMaster->HasVideo()) ||
+ mMaster->HaveEnoughDecodedVideo();
if (!stopBuffering) {
SLOG("Buffering: wait %ds, timeout in %.3lfs", mBufferingWait,
mBufferingWait - elapsed.ToSeconds());
diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp
index bbedb53..65ea3b2 100644
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1960,11 +1960,12 @@
bool MediaFormatReader::NeedInput(DecoderData& aDecoder) {
// The decoder will not be fed a new raw sample until the current decoding
// requests has completed.
+ // Above restriction removed as gmp-droid always needs more samples
return (aDecoder.HasPromise() || aDecoder.mTimeThreshold.isSome()) &&
!aDecoder.HasPendingDrain() && !aDecoder.HasFatalError() &&
!aDecoder.mDemuxRequest.Exists() && !aDecoder.mOutput.Length() &&
- !aDecoder.HasInternalSeekPending() &&
- !aDecoder.mDecodeRequest.Exists();
+ !aDecoder.HasInternalSeekPending();
+ // !aDecoder.mDecodeRequest.Exists();
}

void MediaFormatReader::ScheduleUpdate(TrackType aTrack) {
1 change: 1 addition & 0 deletions rpm/xulrunner-qt5.spec
Expand Up @@ -92,6 +92,7 @@ Patch46: 0046-sailfishos-gecko-Force-recycling-of-gmpdroid-instanc.patch
Patch47: 0047-sailfishos-gecko-Hardcode-loopback-address-for-profi.patch
Patch48: 0048-sailfishos-backport-Enable-MOZ_GECKO_PROFILER-on-And.patch
Patch49: 0049-sailfishos-backport-Implement-DWARF-stack-walker-for.patch
Patch50: 0050-sailfishos-gecko-Buffer-when-the-video-decoder-lags-.patch

BuildRequires: rust
BuildRequires: rust-std-static
Expand Down

0 comments on commit e96fd36

Please sign in to comment.