Bug 1271483 - p5. Remove 'canPlay', can be inferred otherwise - r=cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 12 May 2016 12:49:36 +1000
changeset 380468 fd0e44afb3b33ff03324e1eb2c23117526941047
parent 380467 5034c13188262c8f7ff83b80efbe0fb55078cf57
child 380469 a6106b8bfc58243337e83bbe6a70eefae7be5362
push id21229
push usergsquelart@mozilla.com
push dateWed, 22 Jun 2016 01:27:56 +0000
reviewerscpearce
bugs1271483
milestone50.0a1
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;