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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user