diff options
Diffstat (limited to 'dom/media/platforms/wmf/WMFDecoderModule.cpp')
-rw-r--r-- | dom/media/platforms/wmf/WMFDecoderModule.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp index b3aae1e750..79556b061b 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.cpp +++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp @@ -85,13 +85,9 @@ static bool IsRemoteAcceleratedCompositor( ident.mParentProcessType == GeckoProcessType_GPU; } -static Atomic<bool> sSupportedTypesInitialized(false); -static EnumSet<WMFStreamType> sSupportedTypes; -static EnumSet<WMFStreamType> sLackOfExtensionTypes; - /* static */ void WMFDecoderModule::Init(Config aConfig) { - MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread()); + // TODO : add an assertion to prevent this from running on main thread. if (XRE_IsContentProcess()) { // If we're in the content process and the UseGPUDecoder pref is set, it // means that we've given up on the GPU process (it's been crashing) so we @@ -134,6 +130,7 @@ void WMFDecoderModule::Init(Config aConfig) { sDXVAEnabled = sDXVAEnabled && hwVideo; mozilla::mscom::EnsureMTA([&]() { + StaticMutexAutoLock lock(sMutex); // Store the supported MFT decoders. sSupportedTypes.clear(); sLackOfExtensionTypes.clear(); @@ -163,7 +160,10 @@ void WMFDecoderModule::Init(Config aConfig) { } }); - sSupportedTypesInitialized = true; + { + StaticMutexAutoLock lock(sMutex); + sSupportedTypesInitialized = true; + } WmfDecoderModuleMarkerAndLog("WMFInit Result", "WMFDecoderModule::Init finishing"); @@ -270,15 +270,13 @@ HRESULT WMFDecoderModule::CreateMFTDecoder(const WMFStreamType& aType, /* static */ bool WMFDecoderModule::CanCreateMFTDecoder(const WMFStreamType& aType) { MOZ_ASSERT(WMFStreamType::Unknown < aType && aType < WMFStreamType::SENTINEL); - if (!sSupportedTypesInitialized) { - if (NS_IsMainThread()) { - Init(); - } else { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableFunction("WMFDecoderModule::Init", [&]() { Init(); }); - SyncRunnable::DispatchToThread(GetMainThreadSerialEventTarget(), - runnable); - } + bool hasInitialized = false; + { + StaticMutexAutoLock lock(sMutex); + hasInitialized = sSupportedTypesInitialized; + } + if (!hasInitialized) { + Init(); } // Check prefs here rather than CreateMFTDecoder so that prefs aren't baked @@ -324,7 +322,7 @@ bool WMFDecoderModule::CanCreateMFTDecoder(const WMFStreamType& aType) { break; } } - + StaticMutexAutoLock lock(sMutex); return sSupportedTypes.contains(aType); } @@ -380,6 +378,7 @@ media::DecodeSupportSet WMFDecoderModule::Supports( return media::DecodeSupport::SoftwareDecode; } } + StaticMutexAutoLock lock(sMutex); return sLackOfExtensionTypes.contains(type) ? media::DecodeSupport::UnsureDueToLackOfExtension : media::DecodeSupportSet{}; @@ -486,6 +485,9 @@ bool WMFDecoderModule::IsHEVCSupported() { return sForceEnableHEVC || StaticPrefs::media_wmf_hevc_enabled() == 1; } +/* static */ +void WMFDecoderModule::DisableForceEnableHEVC() { sForceEnableHEVC = false; } + } // namespace mozilla #undef WFM_DECODER_MODULE_STATUS_MARKER |