From 4f0116ae0f596341ac4b895a23c252f28f4543fb Mon Sep 17 00:00:00 2001 From: HolographicWings Date: Tue, 16 May 2023 04:55:59 +0200 Subject: [PATCH] Fixed potential issue Fixed potential bug when when stop and re-starting a game. Removed useless line. --- src/video_core/host1x/codecs/codec.cpp | 9 ++------- src/video_core/host1x/codecs/codec.h | 2 ++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/video_core/host1x/codecs/codec.cpp b/src/video_core/host1x/codecs/codec.cpp index f52cbfebe3..3d5fcbb5d2 100644 --- a/src/video_core/host1x/codecs/codec.cpp +++ b/src/video_core/host1x/codecs/codec.cpp @@ -278,8 +278,6 @@ void Codec::Decode() { } } -std::chrono::steady_clock::time_point last_frame_time = std::chrono::steady_clock::now(); - AVFramePtr Codec::GetCurrentFrame() { // Sometimes VIC will request more frames than have been decoded. // in this case, return a nullptr and don't overwrite previous frame data @@ -292,15 +290,12 @@ AVFramePtr Codec::GetCurrentFrame() { if (Settings::values.use_video_framerate.GetValue()) { std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); - std::chrono::microseconds elapsed = - std::chrono::duration_cast(now - last_frame_time); - std::chrono::microseconds min_frame_interval = - std::chrono::microseconds(1000 / Settings::values.video_framerate.GetValue() * 1000); + std::chrono::microseconds elapsed = std::chrono::duration_cast(now - last_frame_time); + std::chrono::microseconds min_frame_interval = std::chrono::microseconds(1000 / Settings::values.video_framerate.GetValue() * 1000); if (elapsed < min_frame_interval) { std::this_thread::sleep_for(min_frame_interval - elapsed); now = std::chrono::steady_clock::now(); - elapsed = std::chrono::duration_cast(now - last_frame_time); } last_frame_time = now; diff --git a/src/video_core/host1x/codecs/codec.h b/src/video_core/host1x/codecs/codec.h index 0d45fb7fe7..33621ac3dd 100644 --- a/src/video_core/host1x/codecs/codec.h +++ b/src/video_core/host1x/codecs/codec.h @@ -58,6 +58,8 @@ public: /// Return name of the current codec [[nodiscard]] std::string_view GetCurrentCodecName() const; + std::chrono::steady_clock::time_point last_frame_time = std::chrono::steady_clock::now(); + private: void InitializeAvCodecContext();