Bug 1521370 - Ensure WMF PDM is always initialized on the right thread. r=mattwoodrow,gerald.
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 13 Mar 2019 06:16:52 +0000
changeset 521662 303a1f4c20e8d4fadb267a97573ea672f56279f6
parent 521661 ee3013ee7a6d5ed6025796836a81c7fdda7014b7
child 521663 52e8296f4d36045c377e78d9f348b445db46b1cb
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, gerald
bugs1521370
milestone67.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 1521370 - Ensure WMF PDM is always initialized on the right thread. r=mattwoodrow,gerald. And only do it once. Depends on D22874 Differential Revision: https://phabricator.services.mozilla.com/D23247
dom/media/ipc/VideoDecoderParent.cpp
dom/media/platforms/PDMFactory.cpp
dom/media/platforms/PDMFactory.h
--- a/dom/media/ipc/VideoDecoderParent.cpp
+++ b/dom/media/ipc/VideoDecoderParent.cpp
@@ -6,16 +6,17 @@
 #include "VideoDecoderParent.h"
 #include "mozilla/Unused.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "base/thread.h"
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/VideoBridgeChild.h"
 #include "mozilla/layers/ImageClient.h"
 #include "MediaInfo.h"
+#include "PDMFactory.h"
 #include "VideoDecoderManagerParent.h"
 #ifdef XP_WIN
 #  include "WMFDecoderModule.h"
 #endif
 
 namespace mozilla {
 
 using base::Thread;
@@ -59,19 +60,21 @@ VideoDecoderParent::VideoDecoderParent(
   mIPDLSelfRef = this;
 
   mKnowsCompositor->IdentifyTextureHost(aIdentifier);
 
 #ifdef XP_WIN
   using Option = CreateDecoderParams::Option;
   using OptionSet = CreateDecoderParams::OptionSet;
 
+  // Ensure everything is properly initialized on the right thread.
+  PDMFactory::EnsureInit();
+
   // TODO: Ideally we wouldn't hardcode the WMF PDM, and we'd use the normal PDM
   // factory logic for picking a decoder.
-  WMFDecoderModule::Init();
   RefPtr<WMFDecoderModule> pdm(new WMFDecoderModule());
   pdm->Startup();
 
   CreateDecoderParams params(aVideoInfo);
   params.mTaskQueue = mDecodeTaskQueue;
   params.mKnowsCompositor = mKnowsCompositor;
   params.mImageContainer = new layers::ImageContainer();
   params.mRate = CreateDecoderParams::VideoFrameRate(aFramerate);
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -152,17 +152,18 @@ class SupportChecker {
 PDMFactory::PDMFactory() {
   EnsureInit();
   CreatePDMs();
   CreateNullPDM();
 }
 
 PDMFactory::~PDMFactory() {}
 
-void PDMFactory::EnsureInit() const {
+/* static */
+void PDMFactory::EnsureInit() {
   {
     StaticMutexAutoLock mon(sMonitor);
     if (sInstance) {
       // Quick exit if we already have an instance.
       return;
     }
   }
 
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -67,17 +67,18 @@ class PDMFactory final {
   nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
   RefPtr<PlatformDecoderModule> mEMEPDM;
   RefPtr<PlatformDecoderModule> mNullPDM;
 
   bool mWMFFailedToLoad = false;
   bool mFFmpegFailedToLoad = false;
   bool mGMPPDMFailedToStartup = false;
 
-  void EnsureInit() const;
+  friend class VideoDecoderParent;
+  static void EnsureInit();
   template <class T>
   friend class StaticAutoPtr;
   static StaticAutoPtr<PDMFactoryImpl> sInstance;
   static StaticMutex sMonitor;
 };
 
 }  // namespace mozilla