[host] nvfbc: retry on failure to init

@quantum has observed nvfbc under rare circumstances fail to initialize,
this adds a retry to the init with a short delay to hopefully recover
from this situation.
This commit is contained in:
Geoffrey McRae 2022-12-08 21:24:11 +11:00
parent 60ac03ebaf
commit 8619f787b9

View file

@ -316,6 +316,10 @@ static bool nvfbc_init(void)
}
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
bool created = false;
for(int retry = 0; retry < 2; ++retry)
{
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
// causes a substantial performance pentalty even if it fails! As such we only
// attempt NvFBC as a last resort, or if configured via the app:capture
@ -335,19 +339,27 @@ static bool nvfbc_init(void)
&this->maxWidth, &this->maxHeight))
{
adapterIndex = i;
created = true;
break;
}
}
IDirect3D9_Release(d3d);
if (adapterIndex < 0)
{
free(privData);
return false;
}
}
else
{
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
continue;
created = true;
}
if (created)
break;
//10ms delay before retry
nsleep(10000000);
}
if (!created)
{
free(privData);
return false;