Skip to content

Commit

Permalink
obs-qsv11: Fix crash in QSV test process
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
notr1ch authored and Lain-B committed Aug 19, 2023
1 parent 8ace9e6 commit 609b1ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 609b1ab

Please sign in to comment.