From d1efdd44191d980df8481d258681900d7ad60691 Mon Sep 17 00:00:00 2001 From: David Engel Date: Tue, 22 Feb 2022 15:22:41 -0600 Subject: [PATCH] Fix the counting of frames played. DisplayNormalFrame() doesn't always process a frame but VideoLoop() unconditionally increments the frames played counter every time. This leads to inflated counts. Fix the problem by returning an indication that a frame was processed and only increment the count when it is set. (cherry picked from commit c032b280a758ca51cca86887e294439d4853800e) --- mythtv/libs/libmythtv/mythplayerui.cpp | 28 +++++++++++++++----------- mythtv/libs/libmythtv/mythplayerui.h | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mythtv/libs/libmythtv/mythplayerui.cpp b/mythtv/libs/libmythtv/mythplayerui.cpp index cd4eb6520d4..7041fa996fe 100644 --- a/mythtv/libs/libmythtv/mythplayerui.cpp +++ b/mythtv/libs/libmythtv/mythplayerui.cpp @@ -477,15 +477,17 @@ bool MythPlayerUI::VideoLoop() if (m_videoPaused || m_isDummy) DisplayPauseFrame(); - else - DisplayNormalFrame(); - - if (FlagIsSet(kVideoIsNull) && m_decoder) - m_decoder->UpdateFramesPlayed(); - else if (m_decoder && m_decoder->GetEof() != kEofStateNone) - ++m_framesPlayed; - else - m_framesPlayed = static_cast(m_videoOutput->GetFramesPlayed()); + else if (DisplayNormalFrame()) + { + if (FlagIsSet(kVideoIsNull) && m_decoder) + m_decoder->UpdateFramesPlayed(); + else if (m_decoder && m_decoder->GetEof() != kEofStateNone) + ++m_framesPlayed; + else + m_framesPlayed = static_cast( + m_videoOutput->GetFramesPlayed()); + } + return !IsErrored(); } @@ -641,13 +643,13 @@ void MythPlayerUI::DisplayPauseFrame() RenderVideoFrame(nullptr, scan, true, 0ms); } -void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer) +bool MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer) { if (m_allPaused) - return; + return false; if (CheckPrebuffer && !PrebufferEnoughFrames()) - return; + return false; // clear the buffering state SetBuffering(false); @@ -688,6 +690,8 @@ void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer) DoDisplayVideoFrame(frame, due); m_videoOutput->DoneDisplayingFrame(frame); m_outputJmeter.RecordCycleTime(); + + return true; } void MythPlayerUI::SetVideoParams(int Width, int Height, double FrameRate, float Aspect, diff --git a/mythtv/libs/libmythtv/mythplayerui.h b/mythtv/libs/libmythtv/mythplayerui.h index 20f84039b59..67211d8f5eb 100644 --- a/mythtv/libs/libmythtv/mythplayerui.h +++ b/mythtv/libs/libmythtv/mythplayerui.h @@ -45,7 +45,7 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerEditorUI, public MythVideoScanT protected: void InitFrameInterval() override; virtual void DisplayPauseFrame(); - virtual void DisplayNormalFrame(bool CheckPrebuffer = true); + virtual bool DisplayNormalFrame(bool CheckPrebuffer = true); void FileChanged(); void RefreshPauseFrame();