From 7e263ab77591e3582e49ab40418cda0b0ff7e357 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Thu, 11 Mar 2021 21:07:09 -0800 Subject: [PATCH] win-capture: Better laptop test for auto-selection Only auto-select WGC for desktop capture if a battery exists and multiple GPU adapters are present. May false-positive on desktops with a smart UPS attached, but we don't know of a better test. --- .../win-capture/duplicator-monitor-capture.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/duplicator-monitor-capture.c b/plugins/win-capture/duplicator-monitor-capture.c index bdd4c45a6..70215f56e 100644 --- a/plugins/win-capture/duplicator-monitor-capture.c +++ b/plugins/win-capture/duplicator-monitor-capture.c @@ -159,8 +159,22 @@ choose_method(enum display_capture_method method, bool wgc_supported, obs_leave_graphics(); } - if (method == METHOD_AUTO) - method = (*dxgi_index == -1) ? METHOD_WGC : METHOD_DXGI; + if (method == METHOD_AUTO) { + method = METHOD_DXGI; + if (*dxgi_index == -1) { + method = METHOD_WGC; + } else { + SYSTEM_POWER_STATUS status; + if (GetSystemPowerStatus(&status) && + status.BatteryFlag < 128) { + obs_enter_graphics(); + const uint32_t count = gs_get_adapter_count(); + obs_leave_graphics(); + if (count >= 2) + method = METHOD_WGC; + } + } + } return method; }