summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms/wmf/WMFDecoderModule.cpp
diff options
context:
space:
mode:
authorCarsten Schoenert <c.schoenert@t-online.de>2019-05-22 20:42:44 +0200
committerCarsten Schoenert <c.schoenert@t-online.de>2019-05-22 20:42:44 +0200
commitf6dd130b8be04b7a49d04920386bef9da321ab72 (patch)
tree2acc6ef89d0753d535e8643bc3b0ca17d9c74a91 /dom/media/platforms/wmf/WMFDecoderModule.cpp
parent407d18c607a2540f5d9c4a086d7bec336f99b5a7 (diff)
New upstream version 60.7.0upstream/60.7.0
Diffstat (limited to 'dom/media/platforms/wmf/WMFDecoderModule.cpp')
-rw-r--r--dom/media/platforms/wmf/WMFDecoderModule.cpp79
1 files changed, 45 insertions, 34 deletions
diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp
index 8db98b4..98b70b0 100644
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -5,6 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WMFDecoderModule.h"
+#include <algorithm>
+#include <vector>
+#include "DriverCrashGuard.h"
#include "GfxDriverInfo.h"
#include "MFTDecoder.h"
#include "MP4Decoder.h"
@@ -22,22 +25,23 @@
#include "mozilla/StaticMutex.h"
#include "mozilla/WindowsVersion.h"
#include "mozilla/gfx/gfxVars.h"
+#include "mozilla/mscom/EnsureMTA.h"
#include "nsAutoPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsIGfxInfo.h"
#include "nsIWindowsRegKey.h"
+#include "nsIXULRuntime.h"
#include "nsServiceManagerUtils.h"
#include "nsWindowsHelpers.h"
#include "prsystem.h"
#include "nsIXULRuntime.h"
-#include "mozilla/mscom/EnsureMTA.h"
extern const GUID CLSID_WebmMfVpxDec;
-extern const GUID CLSID_AMDWebmMfVp9Dec;
namespace mozilla {
static Atomic<bool> sDXVAEnabled(false);
+static Atomic<bool> sUsableVPXMFT(false);
WMFDecoderModule::~WMFDecoderModule() {
if (mWMFInitialized) {
@@ -46,22 +50,54 @@ WMFDecoderModule::~WMFDecoderModule() {
}
}
+static bool CanCreateMFTDecoder(const GUID& aGuid) {
+ // The IMFTransform interface used by MFTDecoder is documented to require to
+ // run on an MTA thread.
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ee892371(v=vs.85).aspx#components
+ // Note: our normal SharedThreadPool task queues are initialized to MTA, but
+ // the main thread (which calls in here from our CanPlayType implementation)
+ // is not.
+ bool canCreateDecoder = false;
+ mozilla::mscom::EnsureMTA([&]() -> void {
+ if (FAILED(wmf::MFStartup())) {
+ return;
+ }
+ RefPtr<MFTDecoder> decoder(new MFTDecoder());
+ canCreateDecoder = SUCCEEDED(decoder->Create(aGuid));
+ wmf::MFShutdown();
+ });
+ return canCreateDecoder;
+}
+
/* static */
void WMFDecoderModule::Init() {
+ MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
+ bool testForVPx;
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
// should disable DXVA
sDXVAEnabled = !MediaPrefs::PDMUseGPUDecoder();
+ // We need to test for VPX in the content process as the GPUDecoderModule
+ // directly calls WMFDecoderModule::Supports in the content process.
+ // This unnecessary requirement will be fixed in bug 1534815.
+ testForVPx = true;
} else if (XRE_IsGPUProcess()) {
// Always allow DXVA in the GPU process.
- sDXVAEnabled = true;
+ testForVPx = sDXVAEnabled = true;
} else {
// Only allow DXVA in the UI process if we aren't in e10s Firefox
- sDXVAEnabled = !mozilla::BrowserTabsRemoteAutostart();
+ testForVPx = sDXVAEnabled = !mozilla::BrowserTabsRemoteAutostart();
}
sDXVAEnabled = sDXVAEnabled && gfx::gfxVars::CanUseHardwareVideoDecoding();
+ testForVPx = testForVPx && gfx::gfxVars::CanUseHardwareVideoDecoding();
+ if (testForVPx && gfxPrefs::PDMWMFVP9DecoderEnabled()) {
+ gfx::WMFVPXVideoCrashGuard guard;
+ if (!guard.Crashed()) {
+ sUsableVPXMFT = CanCreateMFTDecoder(CLSID_WebmMfVpxDec);
+ }
+ }
}
/* static */
@@ -122,25 +158,6 @@ already_AddRefed<MediaDataDecoder> WMFDecoderModule::CreateAudioDecoder(
return decoder.forget();
}
-static bool CanCreateMFTDecoder(const GUID& aGuid) {
- // The IMFTransform interface used by MFTDecoder is documented to require to
- // run on an MTA thread.
- // https://msdn.microsoft.com/en-us/library/windows/desktop/ee892371(v=vs.85).aspx#components
- // Note: our normal SharedThreadPool task queues are initialized to MTA, but
- // the main thread (which calls in here from our CanPlayType implementation)
- // is not.
- bool canCreateDecoder = false;
- mozilla::mscom::EnsureMTA([&]() -> void {
- if (FAILED(wmf::MFStartup())) {
- return;
- }
- RefPtr<MFTDecoder> decoder(new MFTDecoder());
- canCreateDecoder = SUCCEEDED(decoder->Create(aGuid));
- wmf::MFShutdown();
- });
- return canCreateDecoder;
-}
-
template <const GUID& aGuid>
static bool CanCreateWMFDecoder() {
static StaticMutex sMutex;
@@ -188,18 +205,12 @@ bool WMFDecoderModule::Supports(const TrackInfo& aTrackInfo,
CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>()) {
return true;
}
- if (MediaPrefs::PDMWMFVP9DecoderEnabled()) {
+ if (sUsableVPXMFT) {
static const uint32_t VP8_USABLE_BUILD = 16287;
- if (VPXDecoder::IsVP8(aTrackInfo.mMimeType) &&
- IsWindowsBuildOrLater(VP8_USABLE_BUILD) &&
- CanCreateWMFDecoder<CLSID_WebmMfVpxDec>()) {
- return true;
- }
- if (VPXDecoder::IsVP9(aTrackInfo.mMimeType) &&
- ((gfxPrefs::PDMWMFAMDVP9DecoderEnabled() &&
- CanCreateWMFDecoder<CLSID_AMDWebmMfVp9Dec>()) ||
- CanCreateWMFDecoder<CLSID_WebmMfVpxDec>())) {
- return true;
+ if ((VPXDecoder::IsVP8(aTrackInfo.mMimeType) &&
+ IsWindowsBuildOrLater(VP8_USABLE_BUILD)) ||
+ VPXDecoder::IsVP9(aTrackInfo.mMimeType)) {
+ return CanCreateWMFDecoder<CLSID_WebmMfVpxDec>();
}
}