obs-qsv11: Fix crash in QSV test process

The code assumed MFXCreateSession would always succeed, but it fails on
systems with no QSV implementations, causing a crash when we call
MFXClose later. Additional success checks for the other API calls were
also added.
This commit is contained in:
Richard Stanway 2023-08-19 02:17:56 +02:00 • committed by Lain
commit 609b1ab011

View file

@ -162,7 +162,13 @@ try {
throw "CreateDXGIFactory1 failed";
mfxLoader loader = MFXLoad();
if (!loader)
throw "MFXLoad failed";
mfxConfig cfg = MFXCreateConfig(loader);
if (!cfg)
throw "MFXCreateConfig failed";
mfxVariant impl;
// Low latency is disabled due to encoding capabilities not being provided before TGL for VPL
@ -171,14 +177,16 @@ try {
MFXSetConfigFilterProperty(
cfg, (const mfxU8 *)"mfxImplDescription.Impl", impl);
mfxSession m_session;
mfxSession m_session = nullptr;
mfxStatus sts = MFXCreateSession(loader, 0, &m_session);
uint32_t idx = 0;
while (get_adapter_caps(factory, loader, m_session, idx++) == true)
;
MFXClose(m_session);
if (m_session)
MFXClose(m_session);
MFXUnload(loader);
for (auto &[idx, caps] : adapter_info) {