Browse Source

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.
jpark37 4 years ago
parent
commit
7e263ab775
1 changed files with 16 additions and 2 deletions
  1. 16 2
      plugins/win-capture/duplicator-monitor-capture.c

+ 16 - 2
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;
 }