Always create temporary virtual display when initial probing fails

This commit is contained in:
Yukino Song
2025-07-16 01:51:55 +08:00
parent 1fd920ef1d
commit 95c61a2b9e

View File

@@ -323,8 +323,10 @@ int main(int argc, char *argv[]) {
if (video::probe_encoders()) { if (video::probe_encoders()) {
#ifdef _WIN32 #ifdef _WIN32
// Create a temporary virtual display for encoder capability probing if no active display was found bool allow_probing = !video::allow_encoder_probing();
if (!video::allow_encoder_probing()) { bool probe_result = false;
// Create a temporary virtual display for encoder capability probing
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
std::string probe_uuid_str = PROBE_DISPLAY_UUID; std::string probe_uuid_str = PROBE_DISPLAY_UUID;
auto probe_uuid = uuid_util::uuid_t::parse(probe_uuid_str); auto probe_uuid = uuid_util::uuid_t::parse(probe_uuid_str);
auto* probe_guid = (GUID*)(void*)&probe_uuid; auto* probe_guid = (GUID*)(void*)&probe_uuid;
@@ -344,17 +346,22 @@ int main(int argc, char *argv[]) {
*probe_guid *probe_guid
); );
std::this_thread::sleep_for(500ms);
// Probe again anyways // Probe again anyways
if (video::probe_encoders()) { probe_result = video::probe_encoders();
BOOST_LOG(error) << "Video failed to find working encoder even after attempted with a virtual display"sv;
}
VDISPLAY::removeVirtualDisplay(*probe_guid); VDISPLAY::removeVirtualDisplay(*probe_guid);
} else { } else if (!allow_probing) {
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) { BOOST_LOG(error) << "Video failed to find working encoder: probe failed and virtual display driver isn't initialized"sv;
}
// When probing still fails somehow
if (allow_probing && probe_result) {
if (allow_probing) {
BOOST_LOG(error) << "Video failed to find working encoder: allow probing but failed"sv; BOOST_LOG(error) << "Video failed to find working encoder: allow probing but failed"sv;
} else { } else {
BOOST_LOG(error) << "Video failed to find working encoder: probe failed and virtual display driver isn't initialized"sv; BOOST_LOG(error) << "Video failed to find working encoder even after attempted with a virtual display"sv;
} }
} }
#else #else