浏览代码

UI: Initialize Stats window values after OBSInit/reset

When the statistics window starts up for the first time, it reset values
at that very moment so that stray lagged frames due to OBS' startup
wouldn't be displayed.  However, that's really a bad place to reset
those values because the user could want to view the stats window after
a long stream, and having those values reset when he/she views the
window for the first time would sort of make the point of viewing your
stats moot.

Instead, reset the values only when applicable, such as after OBSInit or
when video is reset.
jp9000 8 年之前
父节点
当前提交
96f746ce41
共有 3 个文件被更改,包括 15 次插入0 次删除
  1. 4 0
      UI/window-basic-main.cpp
  2. 9 0
      UI/window-basic-stats.cpp
  3. 2 0
      UI/window-basic-stats.hpp

+ 4 - 0
UI/window-basic-main.cpp

@@ -1463,6 +1463,8 @@ void OBSBasic::OBSInit()
 
 	if (config_get_bool(basicConfig, "General", "OpenStatsOnStartup"))
 		on_stats_triggered();
+
+	OBSBasicStats::InitializeValues();
 }
 
 void OBSBasic::InitHotkeys()
@@ -2772,6 +2774,8 @@ int OBSBasic::ResetVideo()
 			ResizeProgram(ovi.base_width, ovi.base_height);
 	}
 
+	OBSBasicStats::InitializeValues();
+
 	return ret;
 }
 

+ 9 - 0
UI/window-basic-stats.cpp

@@ -217,6 +217,15 @@ static uint32_t first_skipped = 0xFFFFFFFF;
 static uint32_t first_rendered = 0xFFFFFFFF;
 static uint32_t first_lagged = 0xFFFFFFFF;
 
+void OBSBasicStats::InitializeValues()
+{
+	video_t *video = obs_get_video();
+	first_encoded  = video_output_get_total_frames(video);
+	first_skipped  = video_output_get_skipped_frames(video);
+	first_rendered = obs_get_total_frames();
+	first_lagged   = obs_get_lagged_frames();
+}
+
 void OBSBasicStats::Update()
 {
 	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

+ 2 - 0
UI/window-basic-stats.hpp

@@ -57,4 +57,6 @@ class OBSBasicStats : public QWidget {
 public:
 	OBSBasicStats(QWidget *parent = nullptr);
 	~OBSBasicStats();
+
+	static void InitializeValues();
 };