Automatically use virtual display if no active display is detected

This commit is contained in:
Yukino Song
2025-05-12 21:31:14 +08:00
parent e231803ec2
commit 8aff38cf7c
3 changed files with 38 additions and 29 deletions

View File

@@ -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();

View File

@@ -41,7 +41,6 @@ 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.
@@ -70,7 +69,6 @@ namespace video {
BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders."; BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders.";
return false; return false;
} }
} // namespace
void free_ctx(AVCodecContext *ctx) { void free_ctx(AVCodecContext *ctx) {
avcodec_free_context(&ctx); avcodec_free_context(&ctx);

View File

@@ -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