Bug 1271525 - Factor out data used by FindD3D11BlacklistedDLL() into arguments passed in. r?kentuckyfriedtakahe
This enables us to use the existing D3D11 blacklist code to create a D3D9
blacklist by just passing in a new blacklist cache.
MozReview-Commit-ID: GyQ8o8U1jwg
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -148,64 +148,65 @@ WMFVideoMFTManager::GetMediaSubtypeGUID(
switch (mStreamType) {
case H264: return MFVideoFormat_H264;
case VP8: return MFVideoFormat_VP80;
case VP9: return MFVideoFormat_VP90;
default: return GUID_NULL;
};
}
-struct D3D11BlacklistingCache
+struct D3DDLLBlacklistingCache
{
- // D3D11-blacklist pref last seen.
+ // Blacklist pref value last seen.
nsCString mBlacklistPref;
- // Non-empty if a D3D11-blacklisted DLL was found.
+ // Non-empty if a blacklisted DLL was found.
nsCString mBlacklistedDLL;
};
-StaticAutoPtr<D3D11BlacklistingCache> sD3D11BlacklistingCache;
+StaticAutoPtr<D3DDLLBlacklistingCache> sD3D11BlacklistingCache;
// If a blacklisted DLL is found, return its information, otherwise "".
static const nsACString&
-FindD3D11BlacklistedDLL()
+FindDXVABlacklistedDLL(StaticAutoPtr<D3DDLLBlacklistingCache>& aDLLBlacklistingCache,
+ const char* aDLLBlacklistPrefName)
{
NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
- if (!sD3D11BlacklistingCache) {
+ if (!aDLLBlacklistingCache) {
// First time here, create persistent data that will be reused in all
// D3D11-blacklisting checks.
- sD3D11BlacklistingCache = new D3D11BlacklistingCache();
- ClearOnShutdown(&sD3D11BlacklistingCache);
+ aDLLBlacklistingCache = new D3DDLLBlacklistingCache();
+ ClearOnShutdown(&aDLLBlacklistingCache);
}
- nsAdoptingCString blacklist =
- Preferences::GetCString("media.wmf.disable-d3d11-for-dlls");
+ nsAdoptingCString blacklist = Preferences::GetCString(aDLLBlacklistPrefName);
if (blacklist.IsEmpty()) {
// Empty blacklist -> No blacklisting.
- sD3D11BlacklistingCache->mBlacklistPref.SetLength(0);
- sD3D11BlacklistingCache->mBlacklistedDLL.SetLength(0);
- return sD3D11BlacklistingCache->mBlacklistedDLL;
+ aDLLBlacklistingCache->mBlacklistPref.SetLength(0);
+ aDLLBlacklistingCache->mBlacklistedDLL.SetLength(0);
+ return aDLLBlacklistingCache->mBlacklistedDLL;
}
// Detect changes in pref.
- if (sD3D11BlacklistingCache->mBlacklistPref.Equals(blacklist)) {
+ if (aDLLBlacklistingCache->mBlacklistPref.Equals(blacklist)) {
// Same blacklist -> Return same result (i.e., don't check DLLs again).
- return sD3D11BlacklistingCache->mBlacklistedDLL;
+ return aDLLBlacklistingCache->mBlacklistedDLL;
}
// Adopt new pref now, so we don't work on it again.
- sD3D11BlacklistingCache->mBlacklistPref = blacklist;
+ aDLLBlacklistingCache->mBlacklistPref = blacklist;
- // media.wmf.disable-d3d11-for-dlls format: (whitespace is trimmed)
+ // media.wmf.disable-d3d*-for-dlls format: (whitespace is trimmed)
// "dll1.dll: 1.2.3.4[, more versions...][; more dlls...]"
nsTArray<nsCString> dlls;
SplitAt(";", blacklist, dlls);
for (const auto& dll : dlls) {
nsTArray<nsCString> nameAndVersions;
SplitAt(":", dll, nameAndVersions);
if (nameAndVersions.Length() != 2) {
- NS_WARNING("Skipping incorrect 'media.wmf.disable-d3d11-for-dlls' dll:versions format");
+ NS_WARNING(nsPrintfCString("Skipping incorrect '%s' dll:versions format",
+ aDLLBlacklistPrefName).get());
continue;
}
nameAndVersions[0].CompressWhitespace();
NS_ConvertUTF8toUTF16 name(nameAndVersions[0]);
WCHAR systemPath[MAX_PATH + 1];
if (!ConstructSystem32Path(name.get(), systemPath, MAX_PATH + 1)) {
// Cannot build path -> Assume it's not the blacklisted DLL.
@@ -230,17 +231,18 @@ FindD3D11BlacklistedDLL()
}
nsTArray<nsCString> versions;
SplitAt(",", nameAndVersions[1], versions);
for (const auto& version : versions) {
nsTArray<nsCString> numberStrings;
SplitAt(".", version, numberStrings);
if (numberStrings.Length() != 4) {
- NS_WARNING("Skipping incorrect 'media.wmf.disable-d3d11-for-dlls' a.b.c.d version format");
+ NS_WARNING(nsPrintfCString("Skipping incorrect '%s' a.b.c.d version format",
+ aDLLBlacklistPrefName).get());
continue;
}
DWORD numbers[4];
nsresult errorCode = NS_OK;
for (int i = 0; i < 4; ++i) {
numberStrings[i].CompressWhitespace();
numbers[i] = DWORD(numberStrings[i].ToInteger(&errorCode));
if (NS_FAILED(errorCode)) {
@@ -248,35 +250,42 @@ FindD3D11BlacklistedDLL()
}
if (numbers[i] > UINT16_MAX) {
errorCode = NS_ERROR_FAILURE;
break;
}
}
if (NS_FAILED(errorCode)) {
- NS_WARNING("Skipping incorrect 'media.wmf.disable-d3d11-for-dlls' a.b.c.d version format");
+ NS_WARNING(nsPrintfCString("Skipping incorrect '%s' a.b.c.d version format",
+ aDLLBlacklistPrefName).get());
continue;
}
if (vInfo->dwFileVersionMS == ((numbers[0] << 16) | numbers[1])
&& vInfo->dwFileVersionLS == ((numbers[2] << 16) | numbers[3])) {
// Blacklisted! Record bad DLL.
- sD3D11BlacklistingCache->mBlacklistedDLL.SetLength(0);
- sD3D11BlacklistingCache->mBlacklistedDLL.AppendPrintf(
+ aDLLBlacklistingCache->mBlacklistedDLL.SetLength(0);
+ aDLLBlacklistingCache->mBlacklistedDLL.AppendPrintf(
"%s (%lu.%lu.%lu.%lu)",
nameAndVersions[0].get(), numbers[0], numbers[1], numbers[2], numbers[3]);
- return sD3D11BlacklistingCache->mBlacklistedDLL;
+ return aDLLBlacklistingCache->mBlacklistedDLL;
}
}
}
// No blacklisted DLL.
- sD3D11BlacklistingCache->mBlacklistedDLL.SetLength(0);
- return sD3D11BlacklistingCache->mBlacklistedDLL;
+ aDLLBlacklistingCache->mBlacklistedDLL.SetLength(0);
+ return aDLLBlacklistingCache->mBlacklistedDLL;
+}
+
+static const nsACString&
+FindD3D11BlacklistedDLL() {
+ return FindDXVABlacklistedDLL(sD3D11BlacklistingCache,
+ "media.wmf.disable-d3d11-for-dlls");
}
class CreateDXVAManagerEvent : public Runnable {
public:
CreateDXVAManagerEvent(LayersBackend aBackend, nsCString& aFailureReason)
: mBackend(aBackend)
, mFailureReason(aFailureReason)
{}