From 743211e6d10bc1af76c7d25bd908d4fea42c3d39 Mon Sep 17 00:00:00 2001 From: HolographicWings Date: Wed, 24 May 2023 00:35:30 +0200 Subject: [PATCH] Added a watchdog of 1 second to avoid freezes --- src/video_core/host1x/codecs/codec.cpp | 2 +- src/video_core/host1x/codecs/codec.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/video_core/host1x/codecs/codec.cpp b/src/video_core/host1x/codecs/codec.cpp index fba947e8b3..0f58c2e3d4 100644 --- a/src/video_core/host1x/codecs/codec.cpp +++ b/src/video_core/host1x/codecs/codec.cpp @@ -295,7 +295,7 @@ AVFramePtr Codec::GetCurrentFrame() { std::chrono::microseconds min_frame_interval = std::chrono::microseconds(1000 / Settings::values.video_framerate.GetValue() * 1000); - if (elapsed < min_frame_interval) { + if (elapsed < min_frame_interval || elapsed > watchdog_waitFrameTimeout) { std::this_thread::sleep_for(min_frame_interval - elapsed); now = std::chrono::steady_clock::now(); } diff --git a/src/video_core/host1x/codecs/codec.h b/src/video_core/host1x/codecs/codec.h index 33621ac3dd..4fcacd1257 100644 --- a/src/video_core/host1x/codecs/codec.h +++ b/src/video_core/host1x/codecs/codec.h @@ -60,6 +60,9 @@ public: std::chrono::steady_clock::time_point last_frame_time = std::chrono::steady_clock::now(); + const std::chrono::microseconds watchdog_waitFrameTimeout = + std::chrono::microseconds(1000000); // 1 second + private: void InitializeAvCodecContext();