Browse Source

UI: Prevent video init with bad video settings

A lot of people had the problem where they'd initialize video settings
with 0 width or height on their output resolution value.  This just
changes it so that the user always has a valid resolution so video
initialization doesn't just outright fail.
jp9000 9 years ago
parent
commit
292e893a2d
1 changed files with 16 additions and 0 deletions
  1. 16 0
      obs/window-basic-main.cpp

+ 16 - 0
obs/window-basic-main.cpp

@@ -2262,6 +2262,22 @@ int OBSBasic::ResetVideo()
 	ovi.gpu_conversion = true;
 	ovi.scale_type     = GetScaleType(basicConfig);
 
+	if (ovi.base_width == 0 || ovi.base_height == 0) {
+		ovi.base_width = 1920;
+		ovi.base_height = 1080;
+		config_set_uint(basicConfig, "Video", "BaseCX", 1920);
+		config_set_uint(basicConfig, "Video", "BaseCY", 1080);
+	}
+
+	if (ovi.output_width == 0 || ovi.output_height == 0) {
+		ovi.output_width = ovi.base_width;
+		ovi.output_height = ovi.base_height;
+		config_set_uint(basicConfig, "Video", "OutputCX",
+				ovi.base_width);
+		config_set_uint(basicConfig, "Video", "OutputCY",
+				ovi.base_height);
+	}
+
 	ret = AttemptToResetVideo(&ovi);
 	if (IS_WIN32 && ret != OBS_VIDEO_SUCCESS) {
 		/* Try OpenGL if DirectX fails on windows */