Bug 1271483 - p5. Remove 'canPlay', can be inferred otherwise - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 12 May 2016 12:49:36 +1000
changeset 302276 32ec54498aee8a604ec4b0ec46556abd30de9daa
parent 302275 ed7dc9a4cbe6e0abcb45a101c34c1d89d45c0c07
child 302277 cb46c7802ff480513f2fa711f73982aa4f81c924
push id78676
push usergsquelart@mozilla.com
push dateWed, 22 Jun 2016 03:54:32 +0000
treeherdermozilla-inbound@da005aa1d83c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1271483
milestone50.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 1271483 - p5. Remove 'canPlay', can be inferred otherwise - r=cpearce Instead of having yet-another variable, just infer playability from the lists of playable&unplayable formats, which we need to look at anyway. MozReview-Commit-ID: ABc2WtWADzN
dom/media/DecoderDoctorDiagnostics.cpp
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -354,17 +354,16 @@ static void AppendToStringList(nsAString
   list += item;
 }
 
 void
 DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  bool canPlay = false;
 #if defined(XP_WIN)
   bool WMFNeeded = false;
 #endif
 #if defined(MOZ_FFMPEG)
   bool FFMpegNeeded = false;
 #endif
   nsAutoString playableFormats;
   nsAutoString unplayableFormats;
@@ -372,17 +371,16 @@ DecoderDoctorDocumentWatcher::Synthesize
   nsAutoString unsupportedKeySystems;
   DecoderDoctorDiagnostics::KeySystemIssue lastKeySystemIssue =
     DecoderDoctorDiagnostics::eUnset;
 
   for (const auto& diag : mDiagnosticsSequence) {
     switch (diag.mDecoderDoctorDiagnostics.Type()) {
       case DecoderDoctorDiagnostics::eFormatSupportCheck:
         if (diag.mDecoderDoctorDiagnostics.CanPlay()) {
-          canPlay = true;
           AppendToStringList(playableFormats,
                              diag.mDecoderDoctorDiagnostics.Format());
         } else {
 #if defined(XP_WIN)
           if (diag.mDecoderDoctorDiagnostics.DidWMFFailToLoad()) {
             WMFNeeded = true;
           }
 #endif
@@ -413,17 +411,17 @@ DecoderDoctorDocumentWatcher::Synthesize
         MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
                      == DecoderDoctorDiagnostics::eFormatSupportCheck
                    || diag.mDecoderDoctorDiagnostics.Type()
                         == DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
         break;
     }
   }
 
-  // Look at Key System issues first, as they may influence format checks.
+  // Look at Key System issues first, as they take precedence over format checks.
   if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) {
     // No supported key systems!
     switch (lastKeySystemIssue) {
       case DecoderDoctorDiagnostics::eWidevineWithNoWMF:
         if (CheckSilverlight() != eSilverlightEnabled) {
           DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
                    this, mDocument, NS_ConvertUTF16toUTF8(unsupportedKeySystems).get());
           ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
@@ -431,42 +429,46 @@ DecoderDoctorDocumentWatcher::Synthesize
           return;
         }
         break;
       default:
         break;
     }
   }
 
-  if (!canPlay && !unplayableFormats.IsEmpty()) {
+  // Next, check playability of requested formats.
+  if (!unplayableFormats.IsEmpty()) {
+    // Some requested formats cannot be played.
+    if (playableFormats.IsEmpty()) {
+      // No requested formats can be played. See if we can help the user...
 #if defined(XP_WIN)
-    if (WMFNeeded) {
-      DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found",
-               this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
-      ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
-                     "MediaWMFNeeded", unplayableFormats);
-      return;
-    }
+      if (WMFNeeded) {
+        DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found",
+                 this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
+        ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
+                       "MediaWMFNeeded", unplayableFormats);
+        return;
+      }
 #endif
 #if defined(MOZ_FFMPEG)
-    if (FFMpegNeeded) {
-      DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
-               this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
-      ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
-                     "MediaPlatformDecoderNotFound", unplayableFormats);
+      if (FFMpegNeeded) {
+        DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
+                 this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
+        ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
+                       "MediaPlatformDecoderNotFound", unplayableFormats);
+        return;
+      }
+#endif
+      DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
+              this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
+      ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
+                     "MediaCannotPlayNoDecoders", unplayableFormats);
       return;
     }
-#endif
-    DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
-            this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
-    ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
-                   "MediaCannotPlayNoDecoders", unplayableFormats);
-    return;
-  }
-  if (!unplayableFormats.IsEmpty()) {
+
     DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
             this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
     if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {
       ReportAnalysis(
         dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
         "MediaNoDecoders", unplayableFormats);
     }
     return;