From dd80c0e33274bc9092c8870277ccdf32c6a927b2 Mon Sep 17 00:00:00 2001 From: HolographicWings Date: Mon, 15 May 2023 22:03:41 +0200 Subject: [PATCH] Fix framerate limit setting --- src/video_core/host1x/codecs/codec.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video_core/host1x/codecs/codec.cpp b/src/video_core/host1x/codecs/codec.cpp index 51bcf0227d..f52cbfebe3 100644 --- a/src/video_core/host1x/codecs/codec.cpp +++ b/src/video_core/host1x/codecs/codec.cpp @@ -279,7 +279,7 @@ void Codec::Decode() { } std::chrono::steady_clock::time_point last_frame_time = std::chrono::steady_clock::now(); -std::chrono::microseconds min_call_interval = std::chrono::microseconds(1000/Settings::values.video_framerate.GetValue()*1000); + 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 @@ -294,9 +294,11 @@ AVFramePtr Codec::GetCurrentFrame() { 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); - if (elapsed < min_call_interval) { - std::this_thread::sleep_for(min_call_interval - elapsed); + 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); }