Automatically use virtual display if no active display is detected
This commit is contained in:
@@ -223,7 +223,12 @@ namespace proc {
|
|||||||
});
|
});
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (config::video.headless_mode || launch_session->virtual_display || _app.virtual_display) {
|
if (
|
||||||
|
config::video.headless_mode // Headless mode
|
||||||
|
|| launch_session->virtual_display // User requested virtual display
|
||||||
|
|| _app.virtual_display // App is configured to use virtual display
|
||||||
|
|| !video::allow_encoder_probing() // No active display presents
|
||||||
|
) {
|
||||||
if (vDisplayDriverStatus != VDISPLAY::DRIVER_STATUS::OK) {
|
if (vDisplayDriverStatus != VDISPLAY::DRIVER_STATUS::OK) {
|
||||||
// Try init driver again
|
// Try init driver again
|
||||||
initVDisplayDriver();
|
initVDisplayDriver();
|
||||||
|
|||||||
@@ -41,36 +41,34 @@ using namespace std::literals;
|
|||||||
|
|
||||||
namespace video {
|
namespace video {
|
||||||
|
|
||||||
namespace {
|
/**
|
||||||
/**
|
* @brief Check if we can allow probing for the encoders.
|
||||||
* @brief Check if we can allow probing for the encoders.
|
* @return True if there should be no issues with the probing, false if we should prevent it.
|
||||||
* @return True if there should be no issues with the probing, false if we should prevent it.
|
*/
|
||||||
*/
|
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()) {
|
if (devices.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Since Windows 11 24H2, it is possible that there will be no active devices present
|
|
||||||
// for some reason (probably a bug). Trying to probe encoders in such a state locks/breaks the DXGI
|
|
||||||
// and also the display device for Windows. So we must have at least 1 active device.
|
|
||||||
const bool at_least_one_device_is_active = std::any_of(std::begin(devices), std::end(devices), [](const auto &device) {
|
|
||||||
// If device has additional info, it is active.
|
|
||||||
return static_cast<bool>(device.m_info);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (at_least_one_device_is_active) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders.";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
// Since Windows 11 24H2, it is possible that there will be no active devices present
|
||||||
|
// for some reason (probably a bug). Trying to probe encoders in such a state locks/breaks the DXGI
|
||||||
|
// and also the display device for Windows. So we must have at least 1 active device.
|
||||||
|
const bool at_least_one_device_is_active = std::any_of(std::begin(devices), std::end(devices), [](const auto &device) {
|
||||||
|
// If device has additional info, it is active.
|
||||||
|
return static_cast<bool>(device.m_info);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (at_least_one_device_is_active) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void free_ctx(AVCodecContext *ctx) {
|
void free_ctx(AVCodecContext *ctx) {
|
||||||
avcodec_free_context(&ctx);
|
avcodec_free_context(&ctx);
|
||||||
|
|||||||
@@ -349,6 +349,12 @@ namespace video {
|
|||||||
|
|
||||||
bool validate_encoder(encoder_t &encoder, bool expect_failure);
|
bool validate_encoder(encoder_t &encoder, bool expect_failure);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if we can allow probing for the encoders.
|
||||||
|
* @return True if there should be no issues with the probing, false if we should prevent it.
|
||||||
|
*/
|
||||||
|
bool allow_encoder_probing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Probe encoders and select the preferred encoder.
|
* @brief Probe encoders and select the preferred encoder.
|
||||||
* This is called once at startup and each time a stream is launched to
|
* This is called once at startup and each time a stream is launched to
|
||||||
|
|||||||
Reference in New Issue
Block a user