Bug 1242845 - Make the computation of MediaDecoderStateMachine::HasLowUndecodedData() more accurate and consistent. r=jya.
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1870,24 +1870,25 @@ bool MediaDecoderStateMachine::HasLowUnd
if (Duration().IsInfinite()) {
return false;
}
if (mBuffered.Ref().IsInvalid()) {
return false;
}
- int64_t endOfDecodedVideoData = INT64_MAX;
- if (HasVideo() && !VideoQueue().AtEndOfStream()) {
- endOfDecodedVideoData = VideoQueue().Peek() ? VideoQueue().Peek()->GetEndTime() : VideoEndTime();
- }
- int64_t endOfDecodedAudioData = INT64_MAX;
- if (HasAudio() && !AudioQueue().AtEndOfStream()) {
- endOfDecodedAudioData = mDecodedAudioEndTime;
- }
+ // We are never low in decoded data when we don't have audio/video or have
+ // decoded all audio/video samples.
+ int64_t endOfDecodedVideoData = HasVideo() && !VideoQueue().IsFinished() ?
+ mDecodedVideoEndTime :
+ INT64_MAX;
+ int64_t endOfDecodedAudioData = HasAudio() && !AudioQueue().IsFinished() ?
+ mDecodedAudioEndTime :
+ INT64_MAX;
+
int64_t endOfDecodedData = std::min(endOfDecodedVideoData, endOfDecodedAudioData);
if (Duration().ToMicroseconds() < endOfDecodedData) {
// Our duration is not up to date. No point buffering.
return false;
}
media::TimeInterval interval(media::TimeUnit::FromMicroseconds(endOfDecodedData),
media::TimeUnit::FromMicroseconds(std::min(endOfDecodedData + aUsecs, Duration().ToMicroseconds())));
return endOfDecodedData != INT64_MAX && !mBuffered.Ref().Contains(interval);