Bug 1062664 - Select newest decoder for a given TrackBuffer. r=cajbir
authorMatthew Gregan <kinetik@flim.org>
Mon, 08 Sep 2014 12:13:50 +1200
changeset 204215 b8eaf4b01762717a0f2a17bcec7cfcf5dbffccf3
parent 204214 5cf7d475651b01c495770778786e293904c313fe
child 204216 0411677efc84c72adf258e6931d94e1360b86644
push id27452
push usercbook@mozilla.com
push dateTue, 09 Sep 2014 13:57:12 +0000
treeherdermozilla-central@2eaf94a4f837 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1062664
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1062664 - Select newest decoder for a given TrackBuffer. r=cajbir
content/media/mediasource/MediaSourceReader.cpp
--- a/content/media/mediasource/MediaSourceReader.cpp
+++ b/content/media/mediasource/MediaSourceReader.cpp
@@ -270,17 +270,19 @@ MediaSourceReader::CanSelectVideoReader(
 
 already_AddRefed<MediaDecoderReader>
 MediaSourceReader::SelectReader(double aTarget,
                                 bool (MediaSourceReader::*aCanSelectReader)(MediaDecoderReader*),
                                 const nsTArray<nsRefPtr<SourceBufferDecoder>>& aTrackDecoders)
 {
   mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
-  for (uint32_t i = 0; i < aTrackDecoders.Length(); ++i) {
+  // Consider decoders in order of newest to oldest, as a newer decoder
+  // providing a given buffered range is expected to replace an older one.
+  for (int32_t i = aTrackDecoders.Length() - 1; i >= 0; --i) {
     nsRefPtr<MediaDecoderReader> newReader = aTrackDecoders[i]->GetReader();
 
     // Check the track-type-specific aspects first, as it's assumed these
     // are cheaper than a buffered range comparison, which seems worthwhile
     // to avoid on any reader we'd subsequently reject.
     if (!(this->*aCanSelectReader)(newReader)) {
       continue;
     }