Bug 1368619: Flush decoder on Android. r?jolin
In the situation described in
bug 1345898, on android where the decoder is recycled rather than shut down, we would have potentially returned multiple frames with the same timestamp.
It is necessary to flush the decoder.
MozReview-Commit-ID: 6ovaD9PEdOG
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -2041,16 +2041,18 @@ MediaFormatReader::HandleDemuxedSamples(
LOG("Decoder does not support recycling, recreate decoder.");
// If flushing is required, it will clear our array of queued samples.
// So make a copy now.
nsTArray<RefPtr<MediaRawData>> samples{ Move(decoder.mQueuedSamples) };
ShutdownDecoder(aTrack);
if (sample->mKeyframe) {
decoder.mQueuedSamples.AppendElements(Move(samples));
}
+ } else if (decoder.HasWaitingPromise()) {
+ decoder.Flush();
}
decoder.mInfo = info;
if (sample->mKeyframe) {
ScheduleUpdate(aTrack);
} else {
auto time = TimeInterval(sample->mTime, sample->GetEndTime());