Bug 1538023 - Change MDSM::HasLowBufferedData() to consider data buffered after end of decoded data rather than start. r=jya

When under pressure, the MediaCache evicts data before the last read on a
stream.  We typically have two demuxers reading from different offsets in a
stream. So if the MediaCache is under pressure, it may end up evicting data
between the two demuxers.

The MediaDecoderStateMachine currently goes into buffering state if there's
insufficient data available beginning at the start of its queue of decoded
samples. However since the MediaCache evicts data behind the streams read
cursor, the data after the beginning of the sample queue may have already been
evicted by the media cache. This will cause the MediaDecoderStateMachine to
enter a buffering state, and if its sample queues are full, there will be no
demuxers reading to cause the MediaCache to download the data between the two
demuxers, and we'll get stuck in buffering state indefinitely.

So change the MediaDecoderStateMachine to instead check whether there's
insufficient data available at the end of the decoded sample queues. This means
we won't get stuck in buffering state. Note the MediaCache may still evict data
which the other demuxer needed, causing us to re-request it, but at least we
won't get stuck in buffering state.

Differential Revision: https://phabricator.services.mozilla.com/D30310

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Pearce 2019-05-08 04:35:32 +00:00
Родитель b64a2d776d
Коммит 7402ebd65e
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -3274,12 +3274,12 @@ bool MediaDecoderStateMachine::HasLowBufferedData(const TimeUnit& aThreshold) {
// decoded all audio/video samples.
TimeUnit endOfDecodedVideo = (HasVideo() && !VideoQueue().IsFinished())
? mDecodedVideoEndTime
: TimeUnit::FromInfinity();
: TimeUnit::FromNegativeInfinity();
TimeUnit endOfDecodedAudio = (HasAudio() && !AudioQueue().IsFinished())
? mDecodedAudioEndTime
: TimeUnit::FromInfinity();
: TimeUnit::FromNegativeInfinity();
auto endOfDecodedData = std::min(endOfDecodedVideo, endOfDecodedAudio);
auto endOfDecodedData = std::max(endOfDecodedVideo, endOfDecodedAudio);
if (Duration() < endOfDecodedData) {
// Our duration is not up to date. No point buffering.
return false;