Bug 1268379 - Delay WMF checks in GMPParent - r=jesup
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 02 May 2016 15:03:11 +1000
changeset 320285 2481a3d507a0bcd4cb71ee9d4424052fea182e32
parent 320284 3b5d1530f701ff8530d6c8fd108d7b3a6e7ca994
child 320286 3152d79aa59336db4f5527b91926806ffb5d4796
push id9671
push userraliiev@mozilla.com
push dateMon, 06 Jun 2016 20:27:52 +0000
treeherdermozilla-aurora@cea65ca3d0bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1268379
milestone49.0a1
Bug 1268379 - Delay WMF checks in GMPParent - r=jesup The WMF HasAAC/HasH264 checks were done off the main thread, as soon as the plugin was loaded, which was way too soon in the overall startup process, when the WMF subsystem may not have been properly initialized yet, or may be in the middle of it. The solution here is to delay these checks until they are actually needed to respond to a format-support request, as they come later in the process. Note: This may not be the ideal solution yet, as we are still relying on some magic sequencing of events. Other avenues have been explored unsuccessfully yet, but we may want to revisit this issue after this urgent patch has landed. MozReview-Commit-ID: JVgINc5FLFx
dom/media/gmp/GMPParent.cpp
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -570,16 +570,33 @@ GMPParent::SupportsAPI(const nsCString& 
 {
   for (uint32_t i = 0; i < mCapabilities.Length(); i++) {
     if (!mCapabilities[i].mAPIName.Equals(aAPI)) {
       continue;
     }
     nsTArray<nsCString>& tags = mCapabilities[i].mAPITags;
     for (uint32_t j = 0; j < tags.Length(); j++) {
       if (tags[j].Equals(aTag)) {
+#ifdef XP_WIN
+        // Clearkey on Windows advertises that it can decode in its GMP info
+        // file, but uses Windows Media Foundation to decode. That's not present
+        // on Windows XP, and on some Vista, Windows N, and KN variants without
+        // certain services packs.
+        if (tags[j].EqualsLiteral("org.w3.clearkey")) {
+          if (mCapabilities[i].mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) {
+            if (!WMFDecoderModule::HasH264()) {
+              continue;
+            }
+          } else if (mCapabilities[i].mAPIName.EqualsLiteral(GMP_API_AUDIO_DECODER)) {
+            if (!WMFDecoderModule::HasAAC()) {
+              continue;
+            }
+          }
+        }
+#endif
         return true;
       }
     }
   }
   return false;
 }
 
 bool
@@ -883,35 +900,16 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFil
       // SSE2 isn't supported.
       if (cap.mAPITags.Contains(NS_LITERAL_CSTRING("com.adobe.primetime")) &&
           !mozilla::supports_sse2()) {
         return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
       }
 #endif // XP_WIN
     }
 
-#ifdef XP_WIN
-    // Clearkey on Windows advertises that it can decode in its GMP info
-    // file, but uses Windows Media Foundation to decode. That's not present
-    // on Windows XP, and on some Vista, Windows N, and KN variants without
-    // certain services packs. So don't add the decoding capability to
-    // gmp-clearkey's GMPParent if it's not going to be able to use WMF to
-    // decode.
-    if (cap.mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER) &&
-        cap.mAPITags.Contains(NS_LITERAL_CSTRING("org.w3.clearkey")) &&
-        !WMFDecoderModule::HasH264()) {
-      continue;
-    }
-    if (cap.mAPIName.EqualsLiteral(GMP_API_AUDIO_DECODER) &&
-        cap.mAPITags.Contains(NS_LITERAL_CSTRING("org.w3.clearkey")) &&
-        !WMFDecoderModule::HasAAC()) {
-      continue;
-    }
-#endif
-
     mCapabilities.AppendElement(Move(cap));
   }
 
   if (mCapabilities.IsEmpty()) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   return GenericPromise::CreateAndResolve(true, __func__);