From 96f746ce4185dd7aa08ec90528a09fd48732f440 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 19 Jun 2017 15:33:12 -0700 Subject: [PATCH] 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. --- UI/window-basic-main.cpp | 4 ++++ UI/window-basic-stats.cpp | 9 +++++++++ UI/window-basic-stats.hpp | 2 ++ 3 files changed, 15 insertions(+) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index e9178aa87..b93756423 100644 --- a/UI/window-basic-main.cpp +++ b/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; } diff --git a/UI/window-basic-stats.cpp b/UI/window-basic-stats.cpp index dbc4c92a6..d3dcbe3ab 100644 --- a/UI/window-basic-stats.cpp +++ b/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(App()->GetMainWindow()); diff --git a/UI/window-basic-stats.hpp b/UI/window-basic-stats.hpp index 1527628b0..d6502d53e 100644 --- a/UI/window-basic-stats.hpp +++ b/UI/window-basic-stats.hpp @@ -57,4 +57,6 @@ class OBSBasicStats : public QWidget { public: OBSBasicStats(QWidget *parent = nullptr); ~OBSBasicStats(); + + static void InitializeValues(); };