Fix encoder probing when no display is active
This commit is contained in:
12
src/main.cpp
12
src/main.cpp
@@ -318,7 +318,7 @@ 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
|
// Create a temporary virtual display for encoder capability probing if no active display was found
|
||||||
if (!video::allow_encoder_probing() && proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
if (!video::allow_encoder_probing()) {
|
||||||
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;
|
||||||
@@ -340,15 +340,19 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Probe again anyways
|
// Probe again anyways
|
||||||
if (video::probe_encoders()) {
|
if (video::probe_encoders()) {
|
||||||
BOOST_LOG(error) << "Video failed to find working encoder"sv;
|
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 {
|
||||||
BOOST_LOG(error) << "Video failed to find working encoder"sv;
|
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||||
|
BOOST_LOG(error) << "Video failed to find working encoder: allow probing but failed"sv;
|
||||||
|
} else {
|
||||||
|
BOOST_LOG(error) << "Video failed to find working encoder: probe failed and virtual display driver isn't initialized"sv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
BOOST_LOG(error) << "Video failed to find working encoder"sv;
|
BOOST_LOG(error) << "Video failed to find working encoder: probing failed."sv;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ extern "C" {
|
|||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include "platform/windows/virtual_display.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavutil/hwcontext_d3d11va.h>
|
#include <libavutil/hwcontext_d3d11va.h>
|
||||||
}
|
}
|
||||||
@@ -48,10 +49,19 @@ namespace video {
|
|||||||
bool allow_encoder_probing() {
|
bool allow_encoder_probing() {
|
||||||
const auto devices {display_device::enumerate_devices()};
|
const auto devices {display_device::enumerate_devices()};
|
||||||
|
|
||||||
// If there are no devices, then either the API is not working correctly or OS does not support the lib.
|
// // If there are no devices, then either the API is not working correctly or OS does not support the lib.
|
||||||
// Either way we should not block the probing in this case as we can't tell what's wrong.
|
// // Either way we should not block the probing in this case as we can't tell what's wrong.
|
||||||
|
// if (devices.empty()) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
if (devices.empty()) {
|
if (devices.empty()) {
|
||||||
return true;
|
// We'll create a temporary virtual display for probing anyways.
|
||||||
|
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since Windows 11 24H2, it is possible that there will be no active devices present
|
// Since Windows 11 24H2, it is possible that there will be no active devices present
|
||||||
|
|||||||
Reference in New Issue
Block a user