Ver Fonte

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 há 8 anos atrás
pai
commit
96f746ce41
3 ficheiros alterados com 15 adições e 0 exclusões
  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"))
 	if (config_get_bool(basicConfig, "General", "OpenStatsOnStartup"))
 		on_stats_triggered();
 		on_stats_triggered();
+
+	OBSBasicStats::InitializeValues();
 }
 }
 
 
 void OBSBasic::InitHotkeys()
 void OBSBasic::InitHotkeys()
@@ -2772,6 +2774,8 @@ int OBSBasic::ResetVideo()
 			ResizeProgram(ovi.base_width, ovi.base_height);
 			ResizeProgram(ovi.base_width, ovi.base_height);
 	}
 	}
 
 
+	OBSBasicStats::InitializeValues();
+
 	return ret;
 	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_rendered = 0xFFFFFFFF;
 static uint32_t first_lagged = 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()
 void OBSBasicStats::Update()
 {
 {
 	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
 	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

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

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