Browse Source

obs-ffmpeg: Fix blacklisted adapter check

The quadro P5000 would incorrectly be considered blacklisted because it
used a string search for the P500, which is an earlier quadro variant
that does not have NVENC support.

To fix this, instead of just doing a string search, additionally check
to make sure that there preceding or trailing numbers on the adapter
name.
jp9000 6 years ago
parent
commit
c18aab29ee
1 changed files with 22 additions and 1 deletions
  1. 22 1
      plugins/obs-ffmpeg/obs-ffmpeg.c

+ 22 - 1
plugins/obs-ffmpeg/obs-ffmpeg.c

@@ -181,11 +181,32 @@ static const wchar_t *blacklisted_adapters[] = {
 static const size_t num_blacklisted =
 	sizeof(blacklisted_adapters) / sizeof(blacklisted_adapters[0]);
 
+static bool is_adapter(const wchar_t *name, const wchar_t *adapter)
+{
+	const wchar_t *find = wstrstri(name, adapter);
+	if (!find) {
+		return false;
+	}
+
+	/* check before string for potential numeric mismatch */
+	if (find > name && iswdigit(find[-1]) && iswdigit(find[0])) {
+		return false;
+	}
+
+	/* check after string for potential numeric mismatch */
+	size_t len = wcslen(adapter);
+	if (iswdigit(find[len - 1]) && iswdigit(find[len])) {
+		return false;
+	}
+
+	return true;
+}
+
 static bool is_blacklisted(const wchar_t *name)
 {
 	for (size_t i = 0; i < num_blacklisted; i++) {
 		const wchar_t *blacklisted_adapter = blacklisted_adapters[i];
-		if (wstrstri(name, blacklisted_adapter)) {
+		if (is_adapter(name, blacklisted_adapter)) {
 			return true;
 		}
 	}